fix(tests): simplify back/cancel button handling in cross-browser import tests

This commit is contained in:
GitHub Actions
2026-03-02 21:02:34 +00:00
parent 4a60400af9
commit 2f90d936bf

View File

@@ -496,22 +496,11 @@ test.describe('Caddy Import - Cross-Browser @cross-browser', () => {
}
});
// 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);
// 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();
}
});
await test.step(`[${browserName}] Verify session cleared`, async () => {