Skip to content

Commit 71f7ab3

Browse files
committed
fix(e2e): wait for download file to be fully written before checking size
The save-large-labelmap test could fail on CI when the file watcher resolved before Chrome finished flushing the download. Poll for non-zero file size before asserting.
1 parent 8ff0e2a commit 71f7ab3

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/specs/save-large-labelmap.e2e.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,21 @@ describe('Save large labelmap', function () {
159159
throw new Error(`Save error:\n${errorDetails}`);
160160
}
161161

162+
// Wait for the file to be fully written (Chrome may create it before flushing)
163+
await browser.waitUntil(
164+
() => {
165+
try {
166+
return fs.statSync(downloadedPath).size > 0;
167+
} catch {
168+
return false;
169+
}
170+
},
171+
{
172+
timeout: 30_000,
173+
interval: 500,
174+
timeoutMsg: 'Downloaded file remained 0 bytes',
175+
}
176+
);
162177
const stat = fs.statSync(downloadedPath);
163178
expect(stat.size).toBeGreaterThan(0);
164179
});

0 commit comments

Comments
 (0)