1
0
forked from baron/baron-sso

test(adminfront): further stabilize audit logs test and fix bulk secondary email test

This commit is contained in:
2026-05-29 18:20:56 +09:00
parent b74bab4161
commit bdca346baa
2 changed files with 23 additions and 17 deletions

View File

@@ -44,7 +44,7 @@ test.describe("Audit Logs Management", () => {
await route.fulfill({ json: { issuer: "http://localhost:5000/oidc" } });
});
await page.route(/\/v1\/audit/, async (route) => {
await page.route(/.*\/api\/v1\/audit.*/, async (route) => {
const url = route.request().url();
const urlObj = new URL(url);
const cursor = urlObj.searchParams.get("cursor");
@@ -59,7 +59,7 @@ test.describe("Audit Logs Management", () => {
});
});
await page.route(/\/user\/me/, async (route) => {
await page.route(/.*\/api\/v1\/user\/me/, async (route) => {
return route.fulfill({
json: {
id: "admin-user",
@@ -93,14 +93,16 @@ test.describe("Audit Logs Management", () => {
};
test("should load initial logs and display correctly", async ({ page }) => {
const responsePromise = page.waitForResponse(/.*\/api\/v1\/audit.*/);
await page.goto("/audit-logs");
await responsePromise;
// Check header
await expect(page.getByText(/감사 로그|Audit Logs/i).first()).toBeVisible({
timeout: 20000,
});
// Wait for the table to have at least one row, ensuring data is loaded
// Wait for the table to have at least one row
const firstRow = page.locator("tbody tr").first();
await expect(firstRow).toBeVisible({ timeout: 15000 });
@@ -115,20 +117,22 @@ test.describe("Audit Logs Management", () => {
test("should load more logs on scroll (infinite scroll)", async ({
page,
}) => {
const responsePromise = page.waitForResponse(/.*\/api\/v1\/audit.*/);
await page.goto("/audit-logs");
await expect(page.locator("tbody tr").first()).toBeVisible({
timeout: 15000,
});
await responsePromise;
await expect(page.locator("tbody tr").first()).toBeVisible({ timeout: 15000 });
await expect(page.locator("tbody tr")).toHaveCount(20);
const loadMoreBtn = page.getByRole("button", {
name: /더 보기|Load more/i,
});
await expect(loadMoreBtn).toBeVisible({ timeout: 10000 });
// Explicitly wait for the button to be enabled
await expect(loadMoreBtn).toBeEnabled();
const nextResponsePromise = page.waitForResponse(/.*\/api\/v1\/audit.*/);
await loadMoreBtn.click();
await nextResponsePromise;
// Wait for the next page to load (should reach 40)
await expect(page.locator("tbody tr")).toHaveCount(40, { timeout: 15000 });
@@ -136,10 +140,11 @@ test.describe("Audit Logs Management", () => {
});
test("should filter logs by Action and User ID locally", async ({ page }) => {
const responsePromise = page.waitForResponse(/.*\/api\/v1\/audit.*/);
await page.goto("/audit-logs");
await expect(page.locator("tbody tr").first()).toBeVisible({
timeout: 15000,
});
await responsePromise;
await expect(page.locator("tbody tr").first()).toBeVisible({ timeout: 15000 });
await expect(page.locator("tbody tr")).toHaveCount(20);
// Search by User ID
@@ -152,7 +157,7 @@ test.describe("Audit Logs Management", () => {
// Clear User ID
await userIdInput.clear();
await userIdInput.press("Enter"); // Trigger potential refetch or blur
await userIdInput.press("Enter");
await expect(page.locator("tbody tr")).toHaveCount(20, { timeout: 15000 });
// Search by Action
@@ -165,10 +170,11 @@ test.describe("Audit Logs Management", () => {
});
test("should filter logs by Status locally", async ({ page }) => {
const responsePromise = page.waitForResponse(/.*\/api\/v1\/audit.*/);
await page.goto("/audit-logs");
await expect(page.locator("tbody tr").first()).toBeVisible({
timeout: 15000,
});
await responsePromise;
await expect(page.locator("tbody tr").first()).toBeVisible({ timeout: 15000 });
await expect(page.locator("tbody tr")).toHaveCount(20);
// Select "Failure" status

View File

@@ -118,7 +118,7 @@ test.describe("Users Bulk Upload Secondary Emails", () => {
expect(bulkPayload.users).toHaveLength(1);
// The most important check - does it parse to the metadata
expect(payloadUsers[0].metadata.sub_email).toContain("sub1@test.com");
expect(payloadUsers[0].metadata.sub_email).toContain("sub2@test.com");
expect(bulkPayload!.users[0].metadata.sub_email).toContain("sub1@test.com");
expect(bulkPayload!.users[0].metadata.sub_email).toContain("sub2@test.com");
});
});