Add smoke test for flight fixture (#28350)
Sebastian Silbermann committed
Feb 21, 2024 at 23:47 UTC
81d2a51a97ca8ea7cfbce885ecab070a668732ab
6 files changed
+132
-2
.circleci/config.yml
+50
@@ -236,6 +236,53 @@ jobs:
236
RELEASE_CHANNEL: experimental
237
command: ./scripts/circleci/run_devtools_e2e_tests.js
238
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
+
286
run_devtools_tests_for_versions:
287
docker: *docker
288
environment: *environment
@@ -516,6 +563,9 @@ workflows:
563
- run_devtools_e2e_tests:
564
requires:
565
- build_devtools_and_process_artifacts
566
+ - run_fixtures_flight_tests:
567
+ requires:
568
+ - yarn_build
569
570
devtools_regression_tests:
571
unless: << pipeline.parameters.prerelease_commit_sha >>
fixtures/flight/.gitignore
+2
@@ -7,6 +7,8 @@
7
8
# testing
9
/coverage
10
+/playwright-report
11
+/test-results
12
13
# production
14
/build
fixtures/flight/__tests__/__e2e__/smoke.test.js
new
+20
@@ -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
@@ -3,6 +3,9 @@
3
"type": "module",
4
"version": "0.1.0",
5
"private": true,
6
+ "devEngines": {
7
+ "node": "20.x || 21.x"
8
+ },
9
"dependencies": {
10
"@babel/core": "^7.16.0",
11
"@babel/plugin-proposal-private-property-in-object": "^7.18.6",
@@ -60,6 +63,9 @@
63
"webpack-hot-middleware": "^2.25.3",
64
"webpack-manifest-plugin": "^4.0.2"
65
},
66
+ "devDependencies": {
67
+ "@playwright/test": "^1.41.2"
68
+ },
69
"scripts": {
70
"predev": "cp -r ../../build/oss-experimental/* ./node_modules/",
71
"prebuild": "cp -r ../../build/oss-experimental/* ./node_modules/",
@@ -70,7 +76,7 @@
76
"start:global": "NODE_ENV=production node --experimental-loader ./loader/global.js server/global",
77
"start:region": "NODE_ENV=production node --experimental-loader ./loader/region.js --conditions=react-server server/region",
78
"build": "node scripts/build.js",
73
- "test": "node scripts/test.js --env=jsdom"
79
+ "test": "playwright test"
80
},
81
"browserslist": {
82
"production": [
fixtures/flight/playwright.config.js
new
+31
@@ -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
@@ -2689,6 +2689,13 @@
2689
"@nodelib/fs.scandir" "2.1.3"
2690
fastq "^1.6.0"
2691
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
+
2699
"@pmmmwh/react-refresh-webpack-plugin@0.5.7":
2700
version "0.5.7"
2701
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:
4892
version "1.0.0"
4893
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
4894
4888
-fsevents@^2.3.2, fsevents@~2.3.2:
4895
+fsevents@2.3.2, fsevents@^2.3.2, fsevents@~2.3.2:
4896
version "2.3.2"
4897
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
4898
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
@@ -6644,6 +6651,20 @@ pkg-up@^3.1.0:
6651
dependencies:
6652
find-up "^3.0.0"
6653
6654
+playwright-core@1.41.2:
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
+playwright@1.41.2:
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
+
6668
postcss-attribute-case-insensitive@^5.0.2:
6669
version "5.0.2"
6670
resolved "https://registry.yarnpkg.com/postcss-attribute-case-insensitive/-/postcss-attribute-case-insensitive-5.0.2.tgz#03d761b24afc04c09e757e92ff53716ae8ea2741"