Overlay 2.0 (#12)

This commit is contained in:
2026-03-01 02:36:51 -08:00
committed by GitHub
parent 45df3c466b
commit 44c7761c7c
397 changed files with 15139 additions and 7127 deletions
+40 -2
View File
@@ -33,13 +33,51 @@ test('sendToVisibleOverlayRuntime restores visibility flag when opening hidden o
assert.deepEqual(sent, [['runtime-options:open']]);
});
test('sendToVisibleOverlayRuntime waits for overlay page before sending open command', () => {
const sent: unknown[][] = [];
const restoreSet = new Set<'runtime-options' | 'subsync'>();
let loading = true;
let currentURL = '';
const finishCallbacks: Array<() => void> = [];
const ok = sendToVisibleOverlayRuntime({
mainWindow: {
isDestroyed: () => false,
webContents: {
isLoading: () => loading,
getURL: () => currentURL,
send: (...args: unknown[]) => {
sent.push(args);
},
once: (_event: string, callback: () => void) => {
finishCallbacks.push(callback);
},
},
} as unknown as Electron.BrowserWindow,
visibleOverlayVisible: false,
setVisibleOverlayVisible: () => {},
channel: 'runtime-options:open',
restoreOnModalClose: 'runtime-options',
restoreVisibleOverlayOnModalClose: restoreSet,
});
assert.equal(ok, true);
assert.deepEqual(sent, []);
assert.equal(restoreSet.has('runtime-options'), true);
loading = false;
currentURL = 'file:///overlay/index.html?layer=visible';
assert.ok(finishCallbacks[0]);
finishCallbacks[0]!();
assert.deepEqual(sent, [['runtime-options:open']]);
});
test('createFieldGroupingCallbackRuntime cancels when overlay request cannot be sent', async () => {
let resolver: ((choice: KikuFieldGroupingChoice) => void) | null = null;
const callback = createFieldGroupingCallbackRuntime<'runtime-options' | 'subsync'>({
getVisibleOverlayVisible: () => false,
getInvisibleOverlayVisible: () => false,
setVisibleOverlayVisible: () => {},
setInvisibleOverlayVisible: () => {},
getResolver: () => resolver,
setResolver: (next) => {
resolver = next;