Skip the contract checks the running app drives itself

The app sets contact sonar on every frame (src/cyberSonarEngine.js), so a
value the contract suite sets never survives to its next frame inside the
app. qa-contract-suite.mjs reports such checks as skipped, naming their
owner, instead of failing them.
This commit is contained in:
German Khokhlov committed 2026-11-07 01:24:50 +04:00
1 parent 9daa4bd2db
commit 59a233db51
1 file changed
+40 -13
+40 -13
View File
@@ -32,6 +32,13 @@ if (!origin) {
}
const engines = (option('engine') ?? 'cesium,navara').split(',');
// Checks of state the running app drives itself, by name prefix, with the
// owner. The app sets contact sonar on every frame (src/cyberSonarEngine.js),
// so a value the suite sets does not survive to its next frame.
const APP_OWNED = Object.freeze([
['render.setContactSonar', 'src/cyberSonarEngine.js sets it every frame'],
]);
async function runOn(browser, kind) {
const page = await browser.newPage();
await page.setViewport({ width: 1280, height: 800 });
@@ -79,7 +86,7 @@ async function runOn(browser, kind) {
await page.mouse.move(...at);
}
});
const results = await page.evaluate(async () => {
const results = await page.evaluate(async (appOwned) => {
const { engine } = window.__godsEyeView;
const waitFrames = (count) =>
new Promise((resolve) => {
@@ -95,18 +102,31 @@ async function runOn(browser, kind) {
click: (x, y) => window.__contractPointer('click', x, y),
move: (x, y) => window.__contractPointer('move', x, y),
};
const { runContractSuite } =
const { createContractSuite } =
await import('/src/globe/testing/contractSuite.mjs');
const outcome = await runContractSuite(engine, {
const outcome = [];
for (const { name, run } of createContractSuite(engine, {
waitFrames,
pointer,
});
return outcome.map(({ name, ok, error }) => ({
name,
ok,
error: error ? String(error.message ?? error) : undefined,
}));
});
})) {
const owner = appOwned.find(([prefix]) => name.startsWith(prefix));
if (owner) {
outcome.push({ name, skipped: owner[1] });
continue;
}
try {
await run();
outcome.push({ name, ok: true });
} catch (error) {
outcome.push({
name,
ok: false,
error: String(error?.message ?? error),
});
}
}
return outcome;
}, APP_OWNED);
await page.close();
return { engine: kind, results, pageErrors };
}
@@ -122,10 +142,13 @@ try {
for (const kind of engines) {
const run = await runOn(browser, kind);
report.push(run);
const failed = run.results.filter(({ ok }) => !ok);
const ran = run.results.filter(({ skipped }) => !skipped);
const failed = ran.filter(({ ok }) => !ok);
console.log(
`${kind}: ${run.results.length - failed.length}/${run.results.length} checks pass`,
`${kind}: ${ran.length - failed.length}/${ran.length} checks pass`,
);
for (const { name, skipped } of run.results)
if (skipped) console.log(` skipped ${name}: ${skipped}`);
for (const { name, error } of failed)
console.log(` FAIL ${name}: ${error}`);
for (const message of run.pageErrors)
@@ -137,5 +160,9 @@ try {
const json = option('json');
if (json) fs.writeFileSync(json, `${JSON.stringify(report, null, 2)}\n`);
process.exit(
report.every(({ results }) => results.every(({ ok }) => ok)) ? 0 : 1,
report.every(({ results }) =>
results.every(({ ok, skipped }) => ok || skipped),
)
? 0
: 1,
);