Skip to content

Commit 1ca18c4

Browse files
authored
Introduce WebkitHeadless browser testing (#8491)
* Introduce WebkitHeadless browser testing Replace Safari with WebkitHeadless in list of supported karma browsers Install playwright browsers in CI Set WEBKIT_HEADLESS_BIN Update launcher version Run firestore test changed on push Fix Don't use in test-changed-firestore Ignore failing tests * Formatting * Respond to review comments
1 parent d6fa588 commit 1ca18c4

File tree

7 files changed

+188
-16
lines changed

7 files changed

+188
-16
lines changed

.github/workflows/test-changed-auth.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,28 @@ jobs:
102102
run: xvfb-run yarn test:changed auth
103103
env:
104104
BROWSERS: 'Firefox'
105+
106+
test-webkit:
107+
name: Test Auth on Webkit if Changed
108+
runs-on: macos-latest
109+
110+
steps:
111+
- name: Checkout Repo
112+
uses: actions/checkout@v4
113+
with:
114+
fetch-depth: 0
115+
- name: Set up Node (20)
116+
uses: actions/setup-node@v3
117+
with:
118+
node-version: 20.x
119+
- name: Test setup and yarn install
120+
run: |
121+
cp config/ci.config.json config/project.json
122+
yarn
123+
npx playwright install webkit
124+
- name: build
125+
run: yarn build:changed auth
126+
- name: Run tests on changed packages
127+
run: yarn test:changed auth
128+
env:
129+
BROWSERS: 'WebkitHeadless'

.github/workflows/test-changed-firestore.yml

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,62 @@ jobs:
231231
BROWSERS: 'Firefox'
232232
EXPERIMENTAL_MODE: true
233233

234+
compat-test-webkit:
235+
name: Test Firestore Compatible on Webkit
236+
runs-on: macos-latest
237+
needs: build
238+
if: ${{ needs.build.outputs.changed == 'true'}}
239+
steps:
240+
- name: Set up Node (20)
241+
uses: actions/setup-node@v3
242+
with:
243+
node-version: 20.x
244+
- name: Download build archive
245+
uses: actions/download-artifact@v3
246+
with:
247+
name: build.tar.gz
248+
- name: Unzip build artifact
249+
run: tar xf build.tar.gz
250+
- name: Test setup
251+
run: |
252+
cp config/ci.config.json config/project.json
253+
npx playwright install webkit
254+
- name: Run compat tests
255+
run: cd packages/firestore-compat && yarn run test:ci
256+
env:
257+
BROWSERS: 'WebkitHeadless'
258+
259+
test-webkit:
260+
name: Test Firestore on Webkit
261+
strategy:
262+
matrix:
263+
# TODO (dlarocque): Add test:travis once the browser tests are isolated
264+
# Exclude test:travis for now, since it includes node tests, which are failing for
265+
# some reason.
266+
test-name: ["test:browser", "test:lite:browser", "test:browser:prod:nameddb", "test:lite:browser:nameddb"]
267+
runs-on: macos-latest
268+
needs: build
269+
if: ${{ needs.build.outputs.changed == 'true'}}
270+
steps:
271+
- name: Download build archive
272+
uses: actions/download-artifact@v3
273+
with:
274+
name: build.tar.gz
275+
- name: Unzip build artifact
276+
run: tar xf build.tar.gz
277+
- name: Set up Node (20)
278+
uses: actions/setup-node@v3
279+
with:
280+
node-version: 20.x
281+
- name: Test setup
282+
run: |
283+
cp config/ci.config.json config/project.json
284+
npx playwright install webkit
285+
- name: Run tests
286+
run: cd packages/firestore && yarn run ${{ matrix.test-name }}
287+
env:
288+
BROWSERS: 'WebkitHeadless'
289+
EXPERIMENTAL_MODE: true
234290
# A job that fails if any required job in the test matrix fails,
235291
# to be used as a required check for merging.
236292
check-required-tests:
@@ -241,4 +297,4 @@ jobs:
241297
steps:
242298
- name: Check test matrix
243299
if: needs.build.result == 'failure' || needs.test-chrome.result == 'failure' || needs.compat-test-chrome.result == 'failure'
244-
run: exit 1
300+
run: exit 1

.github/workflows/test-changed.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,29 @@ jobs:
7878
run: xvfb-run yarn test:changed core
7979
env:
8080
BROWSERS: 'Firefox'
81+
82+
83+
test-webkit:
84+
name: Test Packages With Changed Files in Webkit
85+
runs-on: macos-latest
86+
87+
steps:
88+
- name: Checkout Repo
89+
uses: actions/checkout@v4
90+
with:
91+
fetch-depth: 0
92+
- name: Set up Node (20)
93+
uses: actions/setup-node@v3
94+
with:
95+
node-version: 20.x
96+
- name: Test setup and yarn install
97+
run: |
98+
cp config/ci.config.json config/project.json
99+
yarn
100+
npx playwright install webkit
101+
- name: build
102+
run: yarn build:changed core
103+
- name: Run tests on changed packages
104+
run: yarn test:changed core
105+
env:
106+
BROWSERS: 'WebkitHeadless'

config/karma.base.js

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,33 @@ const path = require('path');
2020
const webpackTestConfig = require('./webpack.test');
2121
const { argv } = require('yargs');
2222

23+
function determineBrowsers() {
24+
const supportedBrowsers = ['ChromeHeadless', 'WebkitHeadless', 'Firefox'];
25+
26+
if (process.env.BROWSERS) {
27+
const browsers = process.env.BROWSERS.split(',');
28+
29+
const validBrowsers = browsers.filter(browser =>
30+
supportedBrowsers.includes(browser)
31+
);
32+
if (validBrowsers.length === 0) {
33+
console.error(
34+
`The \'BROWSER\' environment variable was set, but no supported browsers were listed. The supported browsers are ${JSON.stringify(
35+
supportedBrowsers
36+
)}.`
37+
);
38+
return [];
39+
} else {
40+
return validBrowsers;
41+
}
42+
} else {
43+
console.log(
44+
"The 'BROWSER' environment variable is undefined. Defaulting to 'ChromeHeadless'."
45+
);
46+
return ['ChromeHeadless'];
47+
}
48+
}
49+
2350
const config = {
2451
// disable watcher
2552
autoWatch: false,
@@ -57,10 +84,11 @@ const config = {
5784
// changes
5885
autoWatch: false,
5986

60-
// start these browsers
61-
// available browser launchers:
62-
// https://npmjs.org/browse/keyword/karma-launcher
63-
browsers: process.env?.BROWSERS?.split(',') ?? ['ChromeHeadless'],
87+
// Browsers to launch for testing
88+
// To use a custom set of browsers, define the BROWSERS environment variable as a comma-seperated list.
89+
// Supported browsers are 'ChromeHeadless', 'WebkitHeadless', and 'Firefox'.
90+
// See: https://karma-runner.github.io/6.4/config/browsers.html
91+
browsers: determineBrowsers(),
6492

6593
webpack: webpackTestConfig,
6694

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@
120120
"karma-firefox-launcher": "2.1.3",
121121
"karma-mocha": "2.0.1",
122122
"karma-mocha-reporter": "2.2.5",
123-
"karma-safari-launcher": "1.0.0",
124123
"karma-sourcemap-loader": "0.4.0",
125124
"karma-spec-reporter": "0.0.36",
126125
"karma-summary-reporter": "3.1.1",
126+
"karma-webkit-launcher": "2.6.0",
127127
"karma-webpack": "5.0.0",
128128
"lcov-result-merger": "3.3.0",
129129
"lerna": "4.0.0",
@@ -139,6 +139,7 @@
139139
"nyc": "15.1.0",
140140
"ora": "5.4.1",
141141
"patch-package": "7.0.2",
142+
"playwright": "1.46.1",
142143
"postinstall-postinstall": "2.1.0",
143144
"prettier": "2.8.7",
144145
"protractor": "5.4.2",

scripts/ci-test/testConfig.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,25 @@ export interface TestConfig {
2828
alwaysIncludePackages?: string[];
2929
}
3030

31+
// These tests are flaky on WebkitHeadless for some reason, so skip them.
32+
// TODO (dlarocque): Fix the flakes and remove this
33+
const ignoredWebkitCoreTests = process.env?.BROWSERS?.includes('WebkitHeadless')
34+
? [
35+
'@firebase/app-check',
36+
'@firebase/installations',
37+
'@firebase/storage',
38+
'@firebase/storage-compat',
39+
'@firebase/database',
40+
'@firebase/database-compat'
41+
]
42+
: [];
43+
3144
export const testConfig: {
3245
[key: string]: TestConfig | undefined;
3346
} = {
3447
'core': {
3548
'ignorePackages': [
49+
...ignoredWebkitCoreTests,
3650
'@firebase/firestore',
3751
'@firebase/firestore-compat',
3852
'firebase-firestore-integration-test',

yarn.lock

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8653,6 +8653,11 @@ fs.realpath@^1.0.0:
86538653
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
86548654
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
86558655

8656+
[email protected], fsevents@^2.3.2, fsevents@~2.3.2:
8657+
version "2.3.2"
8658+
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
8659+
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
8660+
86568661
fsevents@^1.2.7:
86578662
version "1.2.13"
86588663
resolved "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz"
@@ -8661,11 +8666,6 @@ fsevents@^1.2.7:
86618666
bindings "^1.5.0"
86628667
nan "^2.12.1"
86638668

8664-
fsevents@^2.3.2, fsevents@~2.3.2:
8665-
version "2.3.2"
8666-
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
8667-
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
8668-
86698669
ftp@^0.3.10:
86708670
version "0.3.10"
86718671
resolved "https://registry.npmjs.org/ftp/-/ftp-0.3.10.tgz"
@@ -11339,11 +11339,6 @@ [email protected]:
1133911339
dependencies:
1134011340
minimist "^1.2.3"
1134111341

11342-
11343-
version "1.0.0"
11344-
resolved "https://registry.npmjs.org/karma-safari-launcher/-/karma-safari-launcher-1.0.0.tgz"
11345-
integrity sha1-lpgqLMR9BmquccVTursoMZEVos4=
11346-
1134711342
1134811343
version "0.4.0"
1134911344
resolved "https://registry.npmjs.org/karma-sourcemap-loader/-/karma-sourcemap-loader-0.4.0.tgz"
@@ -11414,6 +11409,14 @@ [email protected]:
1141411409
util "^0.12.1"
1141511410
vm-browserify "^1.1.2"
1141611411

11412+
11413+
version "2.6.0"
11414+
resolved "https://registry.npmjs.org/karma-webkit-launcher/-/karma-webkit-launcher-2.6.0.tgz#2e3ba096b69139e608d9ce6e89816a17f358b700"
11415+
integrity sha512-IDURopxJ1SbuqnvPaE+lP2qiP2Ie7I+ojwJRBpr0tfGwObsaVdjMkUkmZ1BcXUtYRt5ogs9cyCH2Wb9sNv0BbQ==
11416+
dependencies:
11417+
is-ci "^3.0.1"
11418+
uuid "^10.0.0"
11419+
1141711420
1141811421
version "5.0.0"
1141911422
resolved "https://registry.npmjs.org/karma-webpack/-/karma-webpack-5.0.0.tgz"
@@ -14119,6 +14122,20 @@ pkg-dir@^4.1.0, pkg-dir@^4.2.0:
1411914122
dependencies:
1412014123
find-up "^4.0.0"
1412114124

14125+
14126+
version "1.46.1"
14127+
resolved "https://registry.npmjs.org/playwright-core/-/playwright-core-1.46.1.tgz#28f3ab35312135dda75b0c92a3e5c0e7edb9cc8b"
14128+
integrity sha512-h9LqIQaAv+CYvWzsZ+h3RsrqCStkBHlgo6/TJlFst3cOTlLghBQlJwPOZKQJTKNaD3QIB7aAVQ+gfWbN3NXB7A==
14129+
14130+
14131+
version "1.46.1"
14132+
resolved "https://registry.npmjs.org/playwright/-/playwright-1.46.1.tgz#ea562bc48373648e10420a10c16842f0b227c218"
14133+
integrity sha512-oPcr1yqoXLCkgKtD5eNUPLiN40rYEM39odNpIb6VE6S7/15gJmA1NzVv6zJYusV0e7tzvkU/utBFNa/Kpxmwng==
14134+
dependencies:
14135+
playwright-core "1.46.1"
14136+
optionalDependencies:
14137+
fsevents "2.3.2"
14138+
1412214139
plugin-error@^1.0.1:
1412314140
version "1.0.1"
1412414141
resolved "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz"
@@ -17657,6 +17674,11 @@ [email protected]:
1765717674
resolved "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz"
1765817675
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=
1765917676

17677+
uuid@^10.0.0:
17678+
version "10.0.0"
17679+
resolved "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz#5a95aa454e6e002725c79055fd42aaba30ca6294"
17680+
integrity sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==
17681+
1766017682
uuid@^3.3.2, uuid@^3.3.3:
1766117683
version "3.4.0"
1766217684
resolved "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz"

0 commit comments

Comments
 (0)