mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +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
+56
-1
@@ -1,6 +1,10 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { MACOS_CHROME, chromeExecutablePath } from '../scripts/qa-chrome.mjs';
|
||||
import {
|
||||
MACOS_CHROME,
|
||||
chromeExecutablePath,
|
||||
captureQaScreenshot,
|
||||
} from '../scripts/qa-chrome.mjs';
|
||||
|
||||
test('gates keep macOS Chrome where it is installed', () => {
|
||||
assert.equal(
|
||||
@@ -25,3 +29,54 @@ test('an explicit executable path wins', () => {
|
||||
'C:\\Chrome\\chrome.exe',
|
||||
);
|
||||
});
|
||||
|
||||
test('screenshots restore minimized test windows before capture and detach their session', async () => {
|
||||
const calls = [];
|
||||
const session = {
|
||||
send: async (method, params) => {
|
||||
calls.push([method, params]);
|
||||
return { windowId: 7, bounds: { windowState: 'minimized' } };
|
||||
},
|
||||
detach: async () => calls.push(['detach']),
|
||||
};
|
||||
const page = {
|
||||
createCDPSession: async () => session,
|
||||
bringToFront: async () => calls.push(['front']),
|
||||
screenshot: async (options) => {
|
||||
calls.push(['capture', options]);
|
||||
return 'pixels';
|
||||
},
|
||||
};
|
||||
assert.equal(
|
||||
await captureQaScreenshot(page, { path: 'proof.png' }),
|
||||
'pixels',
|
||||
);
|
||||
assert.deepEqual(
|
||||
calls.map((c) => c[0]),
|
||||
[
|
||||
'Browser.getWindowForTarget',
|
||||
'Browser.setWindowBounds',
|
||||
'front',
|
||||
'detach',
|
||||
'capture',
|
||||
],
|
||||
);
|
||||
assert.deepEqual(calls[1][1], {
|
||||
windowId: 7,
|
||||
bounds: { windowState: 'normal' },
|
||||
});
|
||||
});
|
||||
|
||||
test('headless capture does not manipulate a native window', async () => {
|
||||
const options = { path: 'proof.png' };
|
||||
const page = {
|
||||
screenshot: async (supplied) => {
|
||||
assert.equal(supplied, options);
|
||||
return 'pixels';
|
||||
},
|
||||
};
|
||||
assert.equal(
|
||||
await captureQaScreenshot(page, options, { headful: false }),
|
||||
'pixels',
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user