@ai-ecoverse/slicc-shared-web 1.11.0 → 1.12.1
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/README.md +2 -1
- package/bin/slicc-lint-comments.sh +1 -1
- package/harness/chrome.mjs +15 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Install it from npm, and pin the reusable workflow to the matching `vX.Y.Z` tag.
|
|
|
20
20
|
npm install --save-dev --save-exact @ai-ecoverse/slicc-shared-web
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
The hooks expect two scripts in each repo: `test:unit`, which writes `coverage/unit/lcov.info` (unit tests stay out of git), and, in TypeScript repos, `typecheck`. The reusable workflow expects `lint`, plus `test` for the integration tests, with a `pretest` that installs Chromium (`playwright-core install --no-shell chromium`). The diff-coverage hook runs `diff-cover` through `uvx`, so install [uv](https://docs.astral.sh/uv/) once.
|
|
23
|
+
The hooks expect two scripts in each repo: `test:unit`, which writes `coverage/unit/lcov.info` (unit tests stay out of git), and, in TypeScript repos, `typecheck`. The reusable workflow expects `lint`, plus `test` for the integration tests, with a `pretest` that installs Chromium (`playwright-core install --no-shell chromium`). Its inputs `lint`, `test`, `chromium` and `node-version` override those, and `timeout-minutes` (20 by default) gives a long job, such as a background-tab measurement, more time. The diff-coverage hook runs `diff-cover` through `uvx`, so install [uv](https://docs.astral.sh/uv/) once.
|
|
24
24
|
|
|
25
25
|
## Rules every repo follows
|
|
26
26
|
|
|
@@ -67,6 +67,7 @@ test('boots', async (t) => {
|
|
|
67
67
|
| `timeout` | How long `page.until` polls and `page.evaluate` waits, in ms | `30000` |
|
|
68
68
|
| `stallAfter` | How long one evaluation may run before the harness probes the test's targets, in ms | `30000` |
|
|
69
69
|
| `profile` | Record a CPU profile of every target, sampled every 100 µs | `true` if `SLICC_PROFILE=1`, else `false` |
|
|
70
|
+
| `realistic` | Run Chrome as a user would: headed, and without `--disable-background-timer-throttling`, `--disable-backgrounding-occluded-windows` and `--disable-renderer-backgrounding`, so a tab behind another one is hidden and throttled. For measuring background tabs. It needs a display: on CI, run the tests under `xvfb-run -a` | `false` |
|
|
70
71
|
|
|
71
72
|
`chrome.page(t)` opens a tab and returns the page API: `goto(path)`, `reload()`, `evaluate(fn, ...args)`, `until(fn, ...args)`, `press(key, ...modifiers)` (a key name like `Enter` or `F5`, or a single character typed with its US-layout key code), `type(text)`, `insert(text)`, `enter()`, `init(fn)` (runs in every new document), `expose(name, handler)` (a binding the page calls with a JSON string), `screenshot(file)`, `tab()` (another tab in the same context), `close()`, `send(method, params, ms)` (a raw CDP call in the tab's session), `errors`, `responses` and `dir` (the test's artifact directory). `chrome.pid` is the browser's process id and `chrome.profile` its `slicc-harness-*` profile directory in `$TMPDIR`. `goto` and `reload` wait until the new document is complete and no longer `about:blank`, and retry the navigation once if that never happens. `until` polls until the function returns a truthy value (not only strict `true`) and resolves with that value; the timeout error names the last result. `within(ms, fn, ...args)` is `until` with its own deadline, for a stage that should take a known time. Both stop at the deadline even if one evaluation never answers. Every CDP call has a deadline: `connect(url).send(method, params, sessionId, ms)` rejects with `<method>: no answer in <ms> ms` (60 s unless given), so a stuck page fails its test instead of hanging the run. A crash fails it at once instead:
|
|
72
73
|
- when the browser dies, every pending and later call rejects with `<method>: browser exited with <signal>` (or `with code <n>`);
|
package/harness/chrome.mjs
CHANGED
|
@@ -32,9 +32,20 @@ export const flags = [
|
|
|
32
32
|
'--window-size=1280,800',
|
|
33
33
|
];
|
|
34
34
|
|
|
35
|
-
export
|
|
35
|
+
export const unrealistic = [
|
|
36
|
+
'--headless',
|
|
37
|
+
'--disable-background-timer-throttling',
|
|
38
|
+
'--disable-backgrounding-occluded-windows',
|
|
39
|
+
'--disable-renderer-backgrounding',
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
export function commandLine(profile, extensions = [], extra = [], realistic = false) {
|
|
36
43
|
const loaded = extensions.length > 0;
|
|
37
|
-
const
|
|
44
|
+
const dropped = new Set([
|
|
45
|
+
...(loaded ? ['--disable-extensions'] : []),
|
|
46
|
+
...(realistic ? unrealistic : []),
|
|
47
|
+
]);
|
|
48
|
+
const base = flags.filter((flag) => !dropped.has(flag));
|
|
38
49
|
const load = loaded ? ['--enable-unsafe-extension-debugging'] : [];
|
|
39
50
|
return [...base, ...load, ...extra, `--user-data-dir=${profile}`, 'about:blank'];
|
|
40
51
|
}
|
|
@@ -225,6 +236,7 @@ export async function launch({
|
|
|
225
236
|
timeout,
|
|
226
237
|
stallAfter,
|
|
227
238
|
profile = inherited.SLICC_PROFILE === '1',
|
|
239
|
+
realistic = false,
|
|
228
240
|
} = {}) {
|
|
229
241
|
pruning ??= prune();
|
|
230
242
|
await pruning;
|
|
@@ -238,7 +250,7 @@ export async function launch({
|
|
|
238
250
|
const dumps = await crashpad();
|
|
239
251
|
const { child, exited, stderr } = await start(
|
|
240
252
|
userData,
|
|
241
|
-
commandLine(userData, loaded, args),
|
|
253
|
+
commandLine(userData, loaded, args, realistic),
|
|
242
254
|
chromium.executablePath(),
|
|
243
255
|
dumps.env
|
|
244
256
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-shared-web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"description": "Shared Renovate, Biome, TypeScript, lefthook and GitHub Actions configuration, plus the CDP integration-test harness, for SLICC's web repos",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|