Skip to content

Commit 56c2e4b

Browse files
Merge pull request #10 from precise-alloy/tests/coverage
Tests/coverage
2 parents a7b4bf2 + b822471 commit 56c2e4b

39 files changed

Lines changed: 4580 additions & 410 deletions
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
module.exports = async (page, scenario, viewport, isReference, browserContext) => {
2+
if (scenario.bypassCsp) {
3+
const browser = browserContext.browser();
4+
const browserName = browser ? browser.browserType().name() : undefined;
5+
6+
if (browserName === 'chromium') {
7+
const session = await browserContext.newCDPSession(page);
8+
await session.send('Page.setBypassCSP', { enabled: true });
9+
} else {
10+
console.warn(`Playwright bypassCsp is only supported with chromium. Current browser: ${browserName ?? 'unknown'}`);
11+
}
12+
}
13+
214
await require('./loadCookies')(browserContext, scenario);
315
};

.engine_scripts/puppet/ignoreCSP.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Allows `ignoreHTTPSErrors: true` BUT... requires `debugWindow: true`
77
*
88
* see https://github.com/GoogleChrome/puppeteer/issues/1229#issuecomment-380133332
9-
* this is the workaround until Page.setBypassCSP lands... https://github.com/GoogleChrome/puppeteer/pull/2324
9+
* this is the workaround until native page CSP bypass lands... https://github.com/GoogleChrome/puppeteer/pull/2324
1010
*
1111
* @param {REQUEST} request
1212
* @return {VOID}
@@ -23,7 +23,7 @@
2323
const fetch = require('node-fetch');
2424
const https = require('https');
2525
const agent = new https.Agent({
26-
rejectUnauthorized: false
26+
rejectUnauthorized: false,
2727
});
2828

2929
module.exports = async function (page, scenario) {
@@ -33,14 +33,14 @@ module.exports = async function (page, scenario) {
3333
// FIND TARGET URL REQUEST
3434
if (requestUrl === targetUrl) {
3535
const cookiesList = await page.cookies(requestUrl);
36-
const cookies = cookiesList.map(cookie => `${cookie.name}=${cookie.value}`).join('; ');
36+
const cookies = cookiesList.map((cookie) => `${cookie.name}=${cookie.value}`).join('; ');
3737
const headers = Object.assign(request.headers(), { cookie: cookies });
3838
const options = {
3939
headers,
4040
body: request.postData(),
4141
method: request.method(),
4242
follow: 20,
43-
agent
43+
agent,
4444
};
4545

4646
const result = await fetch(requestUrl, options);
@@ -51,15 +51,15 @@ module.exports = async function (page, scenario) {
5151
await request.respond({
5252
body: buffer,
5353
headers: cleanedHeaders,
54-
status: result.status
54+
status: result.status,
5555
});
5656
} else {
5757
request.continue();
5858
}
5959
};
6060

6161
await page.setRequestInterception(true);
62-
page.on('request', req => {
62+
page.on('request', (req) => {
6363
intercept(req, scenario.url);
6464
});
6565
};

.github/workflows/check-bun-windows.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ concurrency:
1313

1414
jobs:
1515
build:
16-
timeout-minutes: 5
16+
timeout-minutes: 20
1717
runs-on: windows-2022
1818
steps:
1919
- name: Checkout code
@@ -26,5 +26,14 @@ jobs:
2626
- name: Install dependencies
2727
run: bun install
2828

29-
- name: Tests
29+
- name: Build
30+
run: bun run build
31+
32+
- name: Unit tests with coverage gate
33+
run: bun run test:ci
34+
35+
- name: Install browsers
36+
run: bun run install:browsers
37+
38+
- name: Smoke reference generation
3039
run: bun run ref -- --test-suite alloy

.github/workflows/check-node-windows.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ concurrency:
1313

1414
jobs:
1515
build:
16-
timeout-minutes: 5
16+
timeout-minutes: 20
1717
runs-on: windows-2022
1818
steps:
1919
- name: Checkout code
@@ -26,7 +26,16 @@ jobs:
2626
registry-url: 'https://registry.npmjs.org'
2727

2828
- name: Install dependencies
29-
run: npm install
29+
run: npm ci
3030

31-
- name: Tests
31+
- name: Build
32+
run: npm run build
33+
34+
- name: Unit tests with coverage gate
35+
run: npm run test:ci
36+
37+
- name: Install browsers
38+
run: npm run install:browsers
39+
40+
- name: Smoke reference generation
3241
run: npm run ref -- --test-suite alloy

.github/workflows/deploy.yml

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ permissions:
1818
contents: read
1919

2020
jobs:
21-
build:
22-
timeout-minutes: 5
23-
runs-on: ubuntu-latest
21+
validate:
22+
timeout-minutes: 20
23+
runs-on: windows-2022
2424
steps:
2525
- name: Checkout code
2626
uses: actions/checkout@v5
@@ -30,14 +30,39 @@ jobs:
3030
with:
3131
node-version: '24.x'
3232

33-
# Ensure the latest npm is installed
34-
- run: npm install -g npm@latest
35-
3633
- name: Install dependencies
3734
run: npm ci
3835

3936
- name: Build
4037
run: npm run build
4138

42-
- name: Publish to NPM
39+
- name: Unit tests with coverage gate
40+
run: npm run test:ci
41+
42+
- name: Install browsers
43+
run: npm run install:browsers
44+
45+
- name: Smoke reference generation
46+
run: npm run ref -- --test-suite alloy
47+
48+
publish:
49+
needs: validate
50+
timeout-minutes: 10
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Checkout code
54+
uses: actions/checkout@v5
55+
56+
- name: Set up Node.js
57+
uses: actions/setup-node@v5
58+
with:
59+
node-version: '24.x'
60+
61+
- name: Install dependencies
62+
run: npm ci
63+
64+
- name: Build package
65+
run: npm run build
66+
67+
- name: Publish to npm
4368
run: npm publish --access public --provenance

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ common/**/*
1515
!common/_replacement-profiles.yaml
1616
!common/replacement-profiles-schema.json
1717
!common/test-schema.json
18+
!common/regressify-schema.json
1819

1920
visual_tests/**/*
2021
!visual_tests/alloy.tests.yaml

0 commit comments

Comments
 (0)