1
0
forked from baron/baron-sso

test(adminfront): eliminate CI flakiness in audit and tenant e2e tests

This commit is contained in:
2026-05-29 17:21:20 +09:00
parent f85def288d
commit 16b2c97ddc
2 changed files with 82 additions and 67 deletions

View File

@@ -649,11 +649,17 @@ test.describe("Tenants Management", () => {
const openDataManagementMenu = async () => {
const btn = page.getByTestId("tenant-data-mgmt-btn");
const exportMenuItem = page.getByTestId("tenant-export-menu-item");
const isExpanded = await btn.getAttribute("aria-expanded");
if (isExpanded !== "true") {
await btn.click({ force: true });
}
await expect(exportMenuItem).toBeVisible({ timeout: 10000 });
// Attempt to open the menu with a retry loop using toPass
await expect(async () => {
if (!(await exportMenuItem.isVisible())) {
await btn.click({ force: true });
}
await expect(exportMenuItem).toBeVisible({ timeout: 2000 });
}).toPass({
intervals: [1000, 2000],
timeout: 10000,
});
};
await page.route("**/api/v1/admin/tenants**", async (route) => {
@@ -721,9 +727,21 @@ test.describe("Tenants Management", () => {
await expect(page.getByTestId("tenant-template-menu-item")).toBeVisible();
await expect(page.getByTestId("tenant-import-menu-item")).toBeVisible();
const download = page.waitForEvent("download");
await page.getByTestId("tenant-export-menu-item").click({ force: true });
const exportDownload = await download;
const safeDownload = async (testId: string) => {
const item = page.getByTestId(testId);
await item.waitFor({ state: "attached" });
let downloadObj;
await expect(async () => {
const downloadPromise = page.waitForEvent("download", { timeout: 10000 });
// Use dispatchEvent for more reliable trigger in webkit
await item.dispatchEvent("click");
downloadObj = await downloadPromise;
}).toPass({ timeout: 30000, intervals: [3000] });
return downloadObj;
};
const exportDownload = await safeDownload("tenant-export-menu-item");
expect(exportRequested).toBe(true);
expect(exportDownload.suggestedFilename()).toBe("tenants.csv");
expect(exportUrl).toContain("includeIds=false");
@@ -732,17 +750,13 @@ test.describe("Tenants Management", () => {
await expect(
page.getByTestId("tenant-export-with-ids-menu-item"),
).toBeVisible();
const exportWithIdsDownload = page.waitForEvent("download");
await page
.getByTestId("tenant-export-with-ids-menu-item")
.click({ force: true });
await exportWithIdsDownload;
const exportWithIdsDownload = await safeDownload(
"tenant-export-with-ids-menu-item",
);
expect(exportUrl).toContain("includeIds=true");
await openDataManagementMenu();
const templateDownload = page.waitForEvent("download");
await page.getByTestId("tenant-template-menu-item").click({ force: true });
const template = await templateDownload;
const template = await safeDownload("tenant-template-menu-item");
expect(template.suggestedFilename()).toBe("tenant-import-template.csv");
// Upload directly via setInputFiles (Playwright supports hidden inputs)