mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 10:24:02 +00:00
test: restore minimized Transit windows before screenshots
This commit is contained in:
1 parent
72f1625257
commit
56be69d065
6 files changed
+101
-15
No files matched your search
@@ -18,3 +18,30 @@ export function chromeExecutablePath({
|
||||
if (env.PUPPETEER_EXECUTABLE_PATH) return env.PUPPETEER_EXECUTABLE_PATH;
|
||||
return exists(MACOS_CHROME) ? MACOS_CHROME : undefined;
|
||||
}
|
||||
|
||||
/** Restore an owned test window before capture: focus emulation alone does not
|
||||
* unminimize the native compositor, so CDP screenshots can otherwise stall. */
|
||||
export async function captureQaScreenshot(
|
||||
page,
|
||||
options,
|
||||
{ headful = true } = {},
|
||||
) {
|
||||
if (headful) {
|
||||
const session = await page.createCDPSession();
|
||||
try {
|
||||
const { windowId, bounds } = await session.send(
|
||||
'Browser.getWindowForTarget',
|
||||
);
|
||||
if (bounds.windowState === 'minimized') {
|
||||
await session.send('Browser.setWindowBounds', {
|
||||
windowId,
|
||||
bounds: { windowState: 'normal' },
|
||||
});
|
||||
}
|
||||
await page.bringToFront();
|
||||
} finally {
|
||||
await session.detach();
|
||||
}
|
||||
}
|
||||
return page.screenshot(options);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/** Camera-jump regression against an existing server; never starts a server. */
|
||||
import puppeteer from 'puppeteer';
|
||||
import { chromeExecutablePath } from './qa-chrome.mjs';
|
||||
import { chromeExecutablePath, captureQaScreenshot } from './qa-chrome.mjs';
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { reduceTrailPixels } from '../src/layers/transit/qaMetrics.js';
|
||||
|
||||
@@ -307,7 +307,7 @@ try {
|
||||
result.pixelPass = pixels.pass;
|
||||
result.pixelDetails = pixels;
|
||||
result.errors = errors;
|
||||
await page.screenshot({ path: `${shots}/recovery.png` });
|
||||
await captureQaScreenshot(page, { path: `${shots}/recovery.png` });
|
||||
await writeFile(`${shots}/recovery.json`, JSON.stringify(result, null, 2));
|
||||
for (const key of ['on', 'off', 'onAgain', 'offAgain']) delete result[key];
|
||||
const pass =
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { captureQaScreenshot } from './qa-chrome.mjs';
|
||||
import { getRegisteredTransitFeed } from '../src/data/transitFeeds.js';
|
||||
|
||||
// Not registered or active: camera discovery and live polls never own this feed.
|
||||
@@ -219,7 +220,7 @@ export async function runFleetBudgets({
|
||||
allocations.layerFrameBytes / allocationTrace.rows.length <= 8192,
|
||||
`${allocations.layerFrameBytes / allocationTrace.rows.length} transit-authored bytes/frame; whole frame ${allocations.frameBytes / allocationTrace.rows.length}; top three ${JSON.stringify(details.topAllocatorsPerFrame)}; collected objects included. Full profile saved.`,
|
||||
);
|
||||
await page.screenshot({
|
||||
await captureQaScreenshot(page, {
|
||||
path: `${shots}/${tag}-fleet-${count}.jpg`,
|
||||
type: 'jpeg',
|
||||
quality: 85,
|
||||
@@ -392,7 +393,7 @@ export async function runBostonMatrix({
|
||||
JSON.stringify({ pixels, contrast }),
|
||||
{ unexercised: pixels.length < 6 },
|
||||
);
|
||||
await page.screenshot({
|
||||
await captureQaScreenshot(page, {
|
||||
path: `${shots}/${tag}-matrix-${background.name}-${look.name}-fleet.jpg`,
|
||||
type: 'jpeg',
|
||||
quality: 90,
|
||||
@@ -407,7 +408,7 @@ export async function runBostonMatrix({
|
||||
target.key,
|
||||
);
|
||||
await wait(500);
|
||||
await page.screenshot({
|
||||
await captureQaScreenshot(page, {
|
||||
path: `${shots}/${tag}-matrix-${background.name}-${look.name}-${target.route}-selected.jpg`,
|
||||
type: 'jpeg',
|
||||
quality: 90,
|
||||
@@ -431,7 +432,7 @@ export async function runBostonMatrix({
|
||||
);
|
||||
}
|
||||
await wait(300);
|
||||
await page.screenshot({
|
||||
await captureQaScreenshot(page, {
|
||||
path: `${shots}/${tag}-matrix-${background.name}-${look.name}-restored.jpg`,
|
||||
type: 'jpeg',
|
||||
quality: 90,
|
||||
@@ -579,7 +580,7 @@ export async function runBostonLive({
|
||||
JSON.stringify(selection),
|
||||
{ unexercised: !target },
|
||||
);
|
||||
await page.screenshot({
|
||||
await captureQaScreenshot(page, {
|
||||
path: `${shots}/${tag}-boston-live-${view.name}.jpg`,
|
||||
type: 'jpeg',
|
||||
quality: 90,
|
||||
@@ -1010,7 +1011,7 @@ export async function runTrailVisibility({
|
||||
stable: pixels.stable[i],
|
||||
eligible: pixels.eligible[i],
|
||||
}));
|
||||
await page.screenshot({
|
||||
await captureQaScreenshot(page, {
|
||||
path: `${shots}/${tag}-${altitude}m-trail-visible.jpg`,
|
||||
type: 'jpeg',
|
||||
quality: 95,
|
||||
|
||||
@@ -36,7 +36,7 @@ import {
|
||||
*/
|
||||
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
||||
import puppeteer from 'puppeteer';
|
||||
import { chromeExecutablePath } from './qa-chrome.mjs';
|
||||
import { chromeExecutablePath, captureQaScreenshot } from './qa-chrome.mjs';
|
||||
import { createTransitHistory } from '../server/providers/transitHistory.js';
|
||||
import { DETECTION_THEME_MAP } from '../src/overlays/worldOverlayTokens.js';
|
||||
import { transitModeTier } from '../src/data/transitPresetStyle.js';
|
||||
@@ -294,11 +294,13 @@ page.on('request', (request) => {
|
||||
});
|
||||
|
||||
const shot = (name, caption) =>
|
||||
page
|
||||
.screenshot({ path: `${SHOTS}/${name}`, type: 'jpeg', quality: 82 })
|
||||
.then(() => {
|
||||
console.log(` shot ${name} — ${caption}`);
|
||||
});
|
||||
captureQaScreenshot(page, {
|
||||
path: `${SHOTS}/${name}`,
|
||||
type: 'jpeg',
|
||||
quality: 82,
|
||||
}).then(() => {
|
||||
console.log(` shot ${name} — ${caption}`);
|
||||
});
|
||||
|
||||
const view = (city) =>
|
||||
`${BASE}/?welcome=0#lat=${city.lat}&lon=${city.lon}&alt=600&heading=${city.heading}&pitch=-45`;
|
||||
|
||||
Reference in new issue
Block a user