Skip to content

Commit 3357bea

Browse files
eps1lonAndyPengc12
authored andcommitted
Add smoke test for flight fixture (facebook#28350)
1 parent 0873658 commit 3357bea

File tree

6 files changed

+132
-2
lines changed

6 files changed

+132
-2
lines changed

.circleci/config.yml

+50
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,53 @@ jobs:
236236
RELEASE_CHANNEL: experimental
237237
command: ./scripts/circleci/run_devtools_e2e_tests.js
238238

239+
run_fixtures_flight_tests:
240+
docker:
241+
- image: cimg/openjdk:20.0-node
242+
environment: *environment
243+
steps:
244+
- checkout
245+
- attach_workspace:
246+
at: .
247+
# Fixture copies some built packages from the workroot after install.
248+
# That means dependencies of the built packages are not installed.
249+
# We need to install dependencies of the workroot to fulfill all dependency constraints
250+
- setup_node_modules
251+
- restore_cache:
252+
name: Restore yarn cache of fixture
253+
keys:
254+
- v2-yarn_cache_fixtures_flight-{{ arch }}-{{ checksum "yarn.lock" }}
255+
- run:
256+
name: Install fixture dependencies
257+
working_directory: fixtures/flight
258+
command: |
259+
yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
260+
if [ $? -ne 0 ]; then
261+
yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
262+
fi
263+
- save_cache:
264+
name: Save yarn cache of fixture
265+
key: v2-yarn_cache_fixtures_flight-{{ arch }}-{{ checksum "yarn.lock" }}
266+
paths:
267+
- ~/.cache/yarn
268+
- run:
269+
working_directory: fixtures/flight
270+
name: Playwright install deps
271+
command: |
272+
npx playwright install
273+
sudo npx playwright install-deps
274+
- run:
275+
name: Run tests
276+
working_directory: fixtures/flight
277+
command: yarn test
278+
environment:
279+
# Otherwise the webserver is a blackbox
280+
DEBUG: pw:webserver
281+
- store_artifacts:
282+
path: fixtures/flight/playwright-report
283+
- store_artifacts:
284+
path: fixtures/flight/test-results
285+
239286
run_devtools_tests_for_versions:
240287
docker: *docker
241288
environment: *environment
@@ -516,6 +563,9 @@ workflows:
516563
- run_devtools_e2e_tests:
517564
requires:
518565
- build_devtools_and_process_artifacts
566+
- run_fixtures_flight_tests:
567+
requires:
568+
- yarn_build
519569

520570
devtools_regression_tests:
521571
unless: << pipeline.parameters.prerelease_commit_sha >>

fixtures/flight/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
# testing
99
/coverage
10+
/playwright-report
11+
/test-results
1012

1113
# production
1214
/build
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {test, expect} from '@playwright/test';
2+
3+
test('smoke test', async ({page}) => {
4+
const consoleErrors = [];
5+
page.on('console', msg => {
6+
const type = msg.type();
7+
if (type === 'warn' || type === 'error') {
8+
consoleErrors.push({type: type, text: msg.text()});
9+
}
10+
});
11+
const pageErrors = [];
12+
page.on('pageerror', error => {
13+
pageErrors.push(error.stack);
14+
});
15+
await page.goto('/');
16+
await expect(page.locator('h1')).toHaveText('Hello World');
17+
18+
await expect(consoleErrors).toEqual([]);
19+
await expect(pageErrors).toEqual([]);
20+
});

fixtures/flight/package.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"type": "module",
44
"version": "0.1.0",
55
"private": true,
6+
"devEngines": {
7+
"node": "20.x || 21.x"
8+
},
69
"dependencies": {
710
"@babel/core": "^7.16.0",
811
"@babel/plugin-proposal-private-property-in-object": "^7.18.6",
@@ -60,6 +63,9 @@
6063
"webpack-hot-middleware": "^2.25.3",
6164
"webpack-manifest-plugin": "^4.0.2"
6265
},
66+
"devDependencies": {
67+
"@playwright/test": "^1.41.2"
68+
},
6369
"scripts": {
6470
"predev": "cp -r ../../build/oss-experimental/* ./node_modules/",
6571
"prebuild": "cp -r ../../build/oss-experimental/* ./node_modules/",
@@ -70,7 +76,7 @@
7076
"start:global": "NODE_ENV=production node --experimental-loader ./loader/global.js server/global",
7177
"start:region": "NODE_ENV=production node --experimental-loader ./loader/region.js --conditions=react-server server/region",
7278
"build": "node scripts/build.js",
73-
"test": "node scripts/test.js --env=jsdom"
79+
"test": "playwright test"
7480
},
7581
"browserslist": {
7682
"production": [

fixtures/flight/playwright.config.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import {defineConfig, devices} from '@playwright/test';
2+
3+
const isCI = Boolean(process.env.CI);
4+
5+
export default defineConfig({
6+
// relative to this configuration file.
7+
testDir: '__tests__/__e2e__',
8+
fullyParallel: true,
9+
// Fail the build on CI if you accidentally left test.only in the source code.
10+
forbidOnly: !isCI,
11+
retries: isCI ? 2 : 0,
12+
// Opt out of parallel tests on CI.
13+
workers: isCI ? 1 : undefined,
14+
reporter: 'html',
15+
use: {
16+
baseURL: 'http://localhost:3000',
17+
18+
trace: 'on-first-retry',
19+
},
20+
projects: [
21+
{
22+
name: 'chromium',
23+
use: {...devices['Desktop Chrome']},
24+
},
25+
],
26+
webServer: {
27+
command: 'FAST_REFRESH=false yarn dev',
28+
url: 'http://localhost:3000',
29+
reuseExistingServer: !isCI,
30+
},
31+
});

fixtures/flight/yarn.lock

+22-1
Original file line numberDiff line numberDiff line change
@@ -2689,6 +2689,13 @@
26892689
"@nodelib/fs.scandir" "2.1.3"
26902690
fastq "^1.6.0"
26912691

2692+
"@playwright/test@^1.41.2":
2693+
version "1.41.2"
2694+
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.41.2.tgz#bd9db40177f8fd442e16e14e0389d23751cdfc54"
2695+
integrity sha512-qQB9h7KbibJzrDpkXkYvsmiDJK14FULCCZgEcoe2AvFAS64oCirWTwzTlAYEbKaRxWs5TFesE1Na6izMv3HfGg==
2696+
dependencies:
2697+
playwright "1.41.2"
2698+
26922699
26932700
version "0.5.7"
26942701
resolved "https://registry.yarnpkg.com/@pmmmwh/react-refresh-webpack-plugin/-/react-refresh-webpack-plugin-0.5.7.tgz#58f8217ba70069cc6a73f5d7e05e85b458c150e2"
@@ -4885,7 +4892,7 @@ fs.realpath@^1.0.0:
48854892
version "1.0.0"
48864893
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
48874894

4888-
fsevents@^2.3.2, fsevents@~2.3.2:
4895+
fsevents@2.3.2, fsevents@^2.3.2, fsevents@~2.3.2:
48894896
version "2.3.2"
48904897
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
48914898
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
@@ -6644,6 +6651,20 @@ pkg-up@^3.1.0:
66446651
dependencies:
66456652
find-up "^3.0.0"
66466653

6654+
6655+
version "1.41.2"
6656+
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.41.2.tgz#db22372c708926c697acc261f0ef8406606802d9"
6657+
integrity sha512-VaTvwCA4Y8kxEe+kfm2+uUUw5Lubf38RxF7FpBxLPmGe5sdNkSg5e3ChEigaGrX7qdqT3pt2m/98LiyvU2x6CA==
6658+
6659+
6660+
version "1.41.2"
6661+
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.41.2.tgz#4e760b1c79f33d9129a8c65cc27953be6dd35042"
6662+
integrity sha512-v0bOa6H2GJChDL8pAeLa/LZC4feoAMbSQm1/jF/ySsWWoaNItvrMP7GEkvEEFyCTUYKMxjQKaTSg5up7nR6/8A==
6663+
dependencies:
6664+
playwright-core "1.41.2"
6665+
optionalDependencies:
6666+
fsevents "2.3.2"
6667+
66476668
postcss-attribute-case-insensitive@^5.0.2:
66486669
version "5.0.2"
66496670
resolved "https://registry.yarnpkg.com/postcss-attribute-case-insensitive/-/postcss-attribute-case-insensitive-5.0.2.tgz#03d761b24afc04c09e757e92ff53716ae8ea2741"

0 commit comments

Comments
 (0)