browser-commander 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +104 -0
- package/examples/pdf-generation.js +7 -4
- package/package.json +1 -1
- package/scripts/run-tests.mjs +19 -1
- package/src/README.md +13 -0
- package/src/bindings.js +8 -0
- package/src/browser/connector.js +163 -0
- package/src/browser/launcher.js +17 -0
- package/src/browser/navigation.js +58 -0
- package/src/browser/real-browser.js +439 -0
- package/src/browser/storage-state.js +133 -0
- package/src/core/navigation-manager.js +57 -24
- package/src/exports.js +4 -0
- package/tests/e2e/playwright.e2e.test.js +19 -0
- package/tests/e2e/puppeteer.e2e.test.js +19 -0
- package/tests/helpers/mocks.js +3 -0
- package/tests/unit/bindings.test.js +4 -0
- package/tests/unit/browser/connector.test.js +129 -0
- package/tests/unit/browser/navigation.test.js +61 -0
- package/tests/unit/browser/real-browser.test.js +165 -0
- package/tests/unit/browser/storage-state.test.js +148 -0
- package/tests/unit/core/navigation-manager.test.js +62 -0
- package/tests/unit/scripts/ci-workflow-policy.test.js +73 -0
- package/tests/unit/scripts/npm-release-helpers.test.js +20 -7
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import assert from 'node:assert/strict';
|
|
5
|
+
import { describe, it } from 'node:test';
|
|
6
|
+
|
|
7
|
+
import { checkWorkflow } from '../../../../scripts/check-ci-workflows.mjs';
|
|
8
|
+
|
|
9
|
+
function withWorkflow(content, callback) {
|
|
10
|
+
const directory = mkdtempSync(join(tmpdir(), 'browser-commander-ci-'));
|
|
11
|
+
const filePath = join(directory, 'workflow.yml');
|
|
12
|
+
writeFileSync(filePath, content);
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
return callback(filePath);
|
|
16
|
+
} finally {
|
|
17
|
+
rmSync(directory, { force: true, recursive: true });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe('CI workflow policy', () => {
|
|
22
|
+
it('accepts bounded job-scoped checks', () => {
|
|
23
|
+
const workflow = `name: Test
|
|
24
|
+
on: push
|
|
25
|
+
permissions:
|
|
26
|
+
contents: read
|
|
27
|
+
env:
|
|
28
|
+
GIT_CONFIG_KEY_0: init.defaultBranch
|
|
29
|
+
jobs:
|
|
30
|
+
test:
|
|
31
|
+
runs-on: ubuntu-latest
|
|
32
|
+
timeout-minutes: 5
|
|
33
|
+
concurrency:
|
|
34
|
+
group: \${{ github.workflow }}-\${{ github.ref }}-test
|
|
35
|
+
cancel-in-progress: true
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v6
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
withWorkflow(workflow, (filePath) => {
|
|
41
|
+
assert.equal(checkWorkflow(filePath), 0);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('rejects workflow-wide cancellation and unbounded jobs', () => {
|
|
46
|
+
const workflow = `name: Test
|
|
47
|
+
on: push
|
|
48
|
+
concurrency:
|
|
49
|
+
group: test
|
|
50
|
+
cancel-in-progress: true
|
|
51
|
+
jobs:
|
|
52
|
+
test:
|
|
53
|
+
runs-on: ubuntu-latest
|
|
54
|
+
steps:
|
|
55
|
+
- uses: actions/checkout@v6
|
|
56
|
+
- run: npm install
|
|
57
|
+
- run: echo "\${{ github.head_ref }}"
|
|
58
|
+
- uses: codecov/codecov-action@v6
|
|
59
|
+
with:
|
|
60
|
+
file: coverage.xml
|
|
61
|
+
`;
|
|
62
|
+
const originalError = console.error;
|
|
63
|
+
console.error = () => {};
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
withWorkflow(workflow, (filePath) => {
|
|
67
|
+
assert.equal(checkWorkflow(filePath), 7);
|
|
68
|
+
});
|
|
69
|
+
} finally {
|
|
70
|
+
console.error = originalError;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -127,12 +127,25 @@ describe('test runner helper', () => {
|
|
|
127
127
|
reporter: 'spec',
|
|
128
128
|
targets: ['tests/unit'],
|
|
129
129
|
});
|
|
130
|
-
assert.deepEqual(
|
|
131
|
-
'
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
130
|
+
assert.deepEqual(
|
|
131
|
+
buildNodeTestArgs(options, ['tests/unit/a.test.js'], '24.18.0'),
|
|
132
|
+
[
|
|
133
|
+
'--test',
|
|
134
|
+
'--test-isolation=none',
|
|
135
|
+
'--experimental-test-coverage',
|
|
136
|
+
'--test-reporter',
|
|
137
|
+
'spec',
|
|
138
|
+
'tests/unit/a.test.js',
|
|
139
|
+
]
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('keeps process isolation on Node versions without isolation controls', () => {
|
|
144
|
+
const options = parseTestRunnerArgs(['tests/unit']);
|
|
145
|
+
|
|
146
|
+
assert.deepEqual(
|
|
147
|
+
buildNodeTestArgs(options, ['tests/unit/a.test.js'], '20.20.2'),
|
|
148
|
+
['--test', 'tests/unit/a.test.js']
|
|
149
|
+
);
|
|
137
150
|
});
|
|
138
151
|
});
|