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
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,33 @@ test.describe(
const jobId = await startAsyncExport(page);

await test.step('Jobs tray surfaces the export job', async () => {
await page
.getByRole('button', { name: /Background jobs|jobs running/ })
.click();
// PR #30615 added a useEffect that calls setOpen(true) when a job
// reaches a terminal state, auto-opening the tray and hiding the
// launcher button ({!open && !isEmpty(visibleJobs) && ...} renders
// nothing once open=true).
//
// Race: right after startAsyncExport, visibleJobs may still be
// empty (socket event not yet received), so neither the launcher
// nor the tray has rendered yet. A bare click() on the launcher
// fails during this window.
//
// Fix: wait for whichever surface appears first, then open the tray
// only if it has not already been auto-opened.
const launcherButton = page.getByRole('button', {
Comment thread
gitar-bot[bot] marked this conversation as resolved.
Resolved
name: /Background jobs|jobs running/,
});
const trayPopover = page.locator('.csv-jobs-tray-popover');

// Block until the launcher (job in progress) or the tray (job
// completed and auto-opened by the useEffect) is in the DOM.
await expect(launcherButton.or(trayPopover)).toBeVisible();

// Open the tray only if it has not already been auto-opened.
// When the job finished fast, the tray is already visible and the
// launcher is gone from the DOM — clicking it would throw.
if (!(await trayPopover.isVisible())) {
await launcherButton.click();
}

await expect(
page.getByText(/Exporting|Exported/).first()
Expand Down
Loading