Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions apps/desktop/scripts/smoke-window.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,16 @@ export async function smokeWindow({ window, host, getLocale }) {
await waitFor(() => window.webContents.executeJavaScript(
"!!document.querySelector('.od-sidebar-project-select:not([aria-current]):not(:disabled)')"),
'No other editable project was available for rapid switching');
const rapidSwitchDeadline = performance.now() + 40_000;
for (let attempt = 0; attempt < 8; attempt++) {
const remaining = Math.floor(rapidSwitchDeadline - performance.now());
if (remaining <= 0) throw new Error('Rapid project switching exceeded its total wait budget');
const switchTimeout = Math.min(10_000, remaining);
const switched = await window.webContents.executeJavaScript(`(async () => {
const target = document.querySelector('.od-sidebar-project-select:not([aria-current]):not(:disabled)');
const canvas = document.querySelector('.react-flow');
for (let click = 0; click < 5; click++) target.click();
const deadline = performance.now() + 5000;
const deadline = performance.now() + ${switchTimeout};
do {
await new Promise(requestAnimationFrame);
if (document.querySelector('.canvas-loading-screen') ||
Expand All @@ -241,7 +245,9 @@ export async function smokeWindow({ window, host, getLocale }) {
} while (performance.now() < deadline);
return false;
})()`);
if (!switched) throw new Error('Rapid project switching did not settle');
if (!switched) {
throw new Error(`Rapid project switching did not settle on switch ${attempt + 1} of 8 within ${switchTimeout} ms`);
}
}
result.sidebarFinallyOpen = process.env.OPENDIRECTOR_DESKTOP_SMOKE_SIDEBAR === 'open';
if (await window.webContents.executeJavaScript("document.querySelector('.cw-workspace').dataset.desktopSidebar === 'open'") !== result.sidebarFinallyOpen) {
Expand Down
Loading