fix(tests): improve cancel session flow in cross-browser import tests

This commit is contained in:
GitHub Actions
2026-03-02 20:04:34 +00:00
parent e3b6693402
commit 273fb3cf21

View File

@@ -496,11 +496,23 @@ test.describe('Caddy Import - Cross-Browser @cross-browser', () => {
}
});
// Click back/cancel button (use first match to avoid strict mode violation)
const backButton = page.getByRole('button', { name: /back|cancel/i }).first();
if (await backButton.isVisible()) {
await backButton.click();
}
// Exit review mode first using the review table's own Back button.
const reviewTable = page.locator('[data-testid="import-review-table"]');
const backButton = reviewTable.getByRole('button', { name: /^back$/i });
await expect(backButton).toBeVisible({ timeout: 5000 });
await backButton.click();
// Then cancel the pending session from the import banner.
const banner = page.locator('[data-testid="import-banner"]');
await expect(banner).toBeVisible({ timeout: 5000 });
await banner.getByRole('button', { name: /^cancel$/i }).click();
// Verify cancel API was actually requested and session banner disappears.
await expect.poll(() => cancelRequested, {
timeout: 5000,
message: 'Expected /api/v1/import/cancel request to be sent',
}).toBe(true);
await expect(banner).not.toBeVisible({ timeout: 5000 });
});
await test.step(`[${browserName}] Verify session cleared`, async () => {