mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-15 15:52:21 +00:00
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:
1 parent
9daa4bd2db
commit
59a233db51
1 file changed
+40
-13
@@ -32,6 +32,13 @@ if (!origin) {
|
|||||||
}
|
}
|
||||||
const engines = (option('engine') ?? 'cesium,navara').split(',');
|
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) {
|
async function runOn(browser, kind) {
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
await page.setViewport({ width: 1280, height: 800 });
|
await page.setViewport({ width: 1280, height: 800 });
|
||||||
@@ -79,7 +86,7 @@ async function runOn(browser, kind) {
|
|||||||
await page.mouse.move(...at);
|
await page.mouse.move(...at);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const results = await page.evaluate(async () => {
|
const results = await page.evaluate(async (appOwned) => {
|
||||||
const { engine } = window.__godsEyeView;
|
const { engine } = window.__godsEyeView;
|
||||||
const waitFrames = (count) =>
|
const waitFrames = (count) =>
|
||||||
new Promise((resolve) => {
|
new Promise((resolve) => {
|
||||||
@@ -95,18 +102,31 @@ async function runOn(browser, kind) {
|
|||||||
click: (x, y) => window.__contractPointer('click', x, y),
|
click: (x, y) => window.__contractPointer('click', x, y),
|
||||||
move: (x, y) => window.__contractPointer('move', x, y),
|
move: (x, y) => window.__contractPointer('move', x, y),
|
||||||
};
|
};
|
||||||
const { runContractSuite } =
|
const { createContractSuite } =
|
||||||
await import('/src/globe/testing/contractSuite.mjs');
|
await import('/src/globe/testing/contractSuite.mjs');
|
||||||
const outcome = await runContractSuite(engine, {
|
const outcome = [];
|
||||||
|
for (const { name, run } of createContractSuite(engine, {
|
||||||
waitFrames,
|
waitFrames,
|
||||||
pointer,
|
pointer,
|
||||||
});
|
})) {
|
||||||
return outcome.map(({ name, ok, error }) => ({
|
const owner = appOwned.find(([prefix]) => name.startsWith(prefix));
|
||||||
name,
|
if (owner) {
|
||||||
ok,
|
outcome.push({ name, skipped: owner[1] });
|
||||||
error: error ? String(error.message ?? error) : undefined,
|
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();
|
await page.close();
|
||||||
return { engine: kind, results, pageErrors };
|
return { engine: kind, results, pageErrors };
|
||||||
}
|
}
|
||||||
@@ -122,10 +142,13 @@ try {
|
|||||||
for (const kind of engines) {
|
for (const kind of engines) {
|
||||||
const run = await runOn(browser, kind);
|
const run = await runOn(browser, kind);
|
||||||
report.push(run);
|
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(
|
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)
|
for (const { name, error } of failed)
|
||||||
console.log(` FAIL ${name}: ${error}`);
|
console.log(` FAIL ${name}: ${error}`);
|
||||||
for (const message of run.pageErrors)
|
for (const message of run.pageErrors)
|
||||||
@@ -137,5 +160,9 @@ try {
|
|||||||
const json = option('json');
|
const json = option('json');
|
||||||
if (json) fs.writeFileSync(json, `${JSON.stringify(report, null, 2)}\n`);
|
if (json) fs.writeFileSync(json, `${JSON.stringify(report, null, 2)}\n`);
|
||||||
process.exit(
|
process.exit(
|
||||||
report.every(({ results }) => results.every(({ ok }) => ok)) ? 0 : 1,
|
report.every(({ results }) =>
|
||||||
|
results.every(({ ok, skipped }) => ok || skipped),
|
||||||
|
)
|
||||||
|
? 0
|
||||||
|
: 1,
|
||||||
);
|
);
|
||||||
Reference in new issue
Block a user