forked from baron/baron-sso
test(adminfront): fix csv parser vitest failure and optimize audit spec for CI
This commit is contained in:
@@ -358,7 +358,7 @@ function applySecondaryEmailMetadata(
|
|||||||
...metadataEmailList(item.metadata.secondary_emails),
|
...metadataEmailList(item.metadata.secondary_emails),
|
||||||
...emails,
|
...emails,
|
||||||
]);
|
]);
|
||||||
item.metadata.sub_email = value;
|
item.metadata.sub_email = emails;
|
||||||
item.metadata.secondary_emails = uniqueSecondaryEmails;
|
item.metadata.secondary_emails = uniqueSecondaryEmails;
|
||||||
addWorksmobileAliasEmails(item, emails);
|
addWorksmobileAliasEmails(item, emails);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,11 +44,12 @@ test.describe("Audit Logs Management", () => {
|
|||||||
await route.fulfill({ json: { issuer: "http://localhost:5000/oidc" } });
|
await route.fulfill({ json: { issuer: "http://localhost:5000/oidc" } });
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.route(/.*\/api\/v1\/audit.*/, async (route) => {
|
await page.route("**/v1/audit*", async (route) => {
|
||||||
const url = route.request().url();
|
const url = route.request().url();
|
||||||
const urlObj = new URL(url);
|
const urlObj = new URL(url);
|
||||||
const cursor = urlObj.searchParams.get("cursor");
|
const cursor = urlObj.searchParams.get("cursor");
|
||||||
const offset = cursor ? 20 : 0;
|
const offset = cursor ? 20 : 0;
|
||||||
|
console.log(`[mock] Audit logs request: ${url} (offset: ${offset})`);
|
||||||
return route.fulfill({
|
return route.fulfill({
|
||||||
json: {
|
json: {
|
||||||
items: generateMockLogs(20, offset),
|
items: generateMockLogs(20, offset),
|
||||||
@@ -59,7 +60,7 @@ test.describe("Audit Logs Management", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.route(/.*\/api\/v1\/user\/me/, async (route) => {
|
await page.route("**/user/me", async (route) => {
|
||||||
return route.fulfill({
|
return route.fulfill({
|
||||||
json: {
|
json: {
|
||||||
id: "admin-user",
|
id: "admin-user",
|
||||||
@@ -70,9 +71,9 @@ test.describe("Audit Logs Management", () => {
|
|||||||
headers: { "Access-Control-Allow-Origin": "*" },
|
headers: { "Access-Control-Allow-Origin": "*" },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const generateMockLogs = (count: number, offset = 0) => {
|
const generateMockLogs = (count: number, offset = 0) => {
|
||||||
return Array.from({ length: count }, (_, i) => {
|
return Array.from({ length: count }, (_, i) => {
|
||||||
const id = offset + i;
|
const id = offset + i;
|
||||||
return {
|
return {
|
||||||
@@ -90,41 +91,30 @@ test.describe("Audit Logs Management", () => {
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
test("should load initial logs and display correctly", async ({ page }) => {
|
test("should load initial logs and display correctly", async ({ page }) => {
|
||||||
const responsePromise = page.waitForResponse(/.*\/api\/v1\/audit.*/);
|
console.log("[test] Navigating to /audit-logs");
|
||||||
await page.goto("/audit-logs");
|
await page.goto("/audit-logs");
|
||||||
await responsePromise;
|
|
||||||
|
|
||||||
// Check header
|
// Check header
|
||||||
await expect(page.getByText(/감사 로그|Audit Logs/i).first()).toBeVisible({
|
await expect(page.getByText(/감사 로그|Audit Logs/i).first()).toBeVisible({
|
||||||
timeout: 20000,
|
timeout: 20000,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Wait for the table to have at least one row
|
// Wait for the table row to appear (retry mechanism in expect will handle the async load)
|
||||||
const firstRow = page.locator("tbody tr").first();
|
await expect(page.locator("tbody tr")).toHaveCount(20, { timeout: 15000 });
|
||||||
await expect(firstRow).toBeVisible({ timeout: 15000 });
|
|
||||||
|
|
||||||
// Check if table rows are rendered
|
|
||||||
await expect(page.locator("tbody tr")).toHaveCount(20);
|
|
||||||
|
|
||||||
// Check specific data visible in the row
|
// Check specific data visible in the row
|
||||||
await expect(page.locator("tbody")).toContainText("user-even");
|
await expect(page.locator("tbody")).toContainText("user-even");
|
||||||
await expect(page.locator("tbody")).toContainText("CREATE_TENANT");
|
await expect(page.locator("tbody")).toContainText("CREATE_TENANT");
|
||||||
});
|
|
||||||
|
|
||||||
test("should load more logs on scroll (infinite scroll)", async ({
|
|
||||||
page,
|
|
||||||
}) => {
|
|
||||||
const responsePromise = page.waitForResponse(/.*\/api\/v1\/audit.*/);
|
|
||||||
await page.goto("/audit-logs");
|
|
||||||
await responsePromise;
|
|
||||||
|
|
||||||
await expect(page.locator("tbody tr").first()).toBeVisible({
|
|
||||||
timeout: 15000,
|
|
||||||
});
|
});
|
||||||
await expect(page.locator("tbody tr")).toHaveCount(20);
|
|
||||||
|
test("should load more logs on scroll (infinite scroll)", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await page.goto("/audit-logs");
|
||||||
|
await expect(page.locator("tbody tr")).toHaveCount(20, { timeout: 15000 });
|
||||||
|
|
||||||
const loadMoreBtn = page.getByRole("button", {
|
const loadMoreBtn = page.getByRole("button", {
|
||||||
name: /더 보기|Load more/i,
|
name: /더 보기|Load more/i,
|
||||||
@@ -132,24 +122,16 @@ test.describe("Audit Logs Management", () => {
|
|||||||
await expect(loadMoreBtn).toBeVisible({ timeout: 10000 });
|
await expect(loadMoreBtn).toBeVisible({ timeout: 10000 });
|
||||||
await expect(loadMoreBtn).toBeEnabled();
|
await expect(loadMoreBtn).toBeEnabled();
|
||||||
|
|
||||||
const nextResponsePromise = page.waitForResponse(/.*\/api\/v1\/audit.*/);
|
|
||||||
await loadMoreBtn.click();
|
await loadMoreBtn.click();
|
||||||
await nextResponsePromise;
|
|
||||||
|
|
||||||
// Wait for the next page to load (should reach 40)
|
// Wait for the next page to load (should reach 40)
|
||||||
await expect(page.locator("tbody tr")).toHaveCount(40, { timeout: 15000 });
|
await expect(page.locator("tbody tr")).toHaveCount(40, { timeout: 15000 });
|
||||||
await expect(page.locator("tbody")).toContainText("user-even");
|
await expect(page.locator("tbody")).toContainText("user-even");
|
||||||
});
|
|
||||||
|
|
||||||
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 responsePromise;
|
|
||||||
|
|
||||||
await expect(page.locator("tbody tr").first()).toBeVisible({
|
|
||||||
timeout: 15000,
|
|
||||||
});
|
});
|
||||||
await expect(page.locator("tbody tr")).toHaveCount(20);
|
|
||||||
|
test("should filter logs by Action and User ID locally", async ({ page }) => {
|
||||||
|
await page.goto("/audit-logs");
|
||||||
|
await expect(page.locator("tbody tr")).toHaveCount(20, { timeout: 15000 });
|
||||||
|
|
||||||
// Search by User ID
|
// Search by User ID
|
||||||
const userIdInput = page.getByTestId("audit-search-user-id");
|
const userIdInput = page.getByTestId("audit-search-user-id");
|
||||||
@@ -161,7 +143,6 @@ test.describe("Audit Logs Management", () => {
|
|||||||
|
|
||||||
// Clear User ID
|
// Clear User ID
|
||||||
await userIdInput.clear();
|
await userIdInput.clear();
|
||||||
await userIdInput.press("Enter");
|
|
||||||
await expect(page.locator("tbody tr")).toHaveCount(20, { timeout: 15000 });
|
await expect(page.locator("tbody tr")).toHaveCount(20, { timeout: 15000 });
|
||||||
|
|
||||||
// Search by Action
|
// Search by Action
|
||||||
@@ -171,17 +152,11 @@ test.describe("Audit Logs Management", () => {
|
|||||||
// Check that we only see ROTATE_SECRET (20 - 7 = 13)
|
// Check that we only see ROTATE_SECRET (20 - 7 = 13)
|
||||||
await expect(page.locator("tbody tr")).toHaveCount(13, { timeout: 15000 });
|
await expect(page.locator("tbody tr")).toHaveCount(13, { timeout: 15000 });
|
||||||
await expect(page.locator("tbody")).not.toContainText("CREATE_TENANT");
|
await expect(page.locator("tbody")).not.toContainText("CREATE_TENANT");
|
||||||
});
|
|
||||||
|
|
||||||
test("should filter logs by Status locally", async ({ page }) => {
|
|
||||||
const responsePromise = page.waitForResponse(/.*\/api\/v1\/audit.*/);
|
|
||||||
await page.goto("/audit-logs");
|
|
||||||
await responsePromise;
|
|
||||||
|
|
||||||
await expect(page.locator("tbody tr").first()).toBeVisible({
|
|
||||||
timeout: 15000,
|
|
||||||
});
|
});
|
||||||
await expect(page.locator("tbody tr")).toHaveCount(20);
|
|
||||||
|
test("should filter logs by Status locally", async ({ page }) => {
|
||||||
|
await page.goto("/audit-logs");
|
||||||
|
await expect(page.locator("tbody tr")).toHaveCount(20, { timeout: 15000 });
|
||||||
|
|
||||||
// Select "Failure" status
|
// Select "Failure" status
|
||||||
await page.getByTestId("audit-filter-status").selectOption("failure");
|
await page.getByTestId("audit-filter-status").selectOption("failure");
|
||||||
@@ -193,5 +168,5 @@ test.describe("Audit Logs Management", () => {
|
|||||||
await page.getByTestId("audit-filter-status").selectOption("success");
|
await page.getByTestId("audit-filter-status").selectOption("success");
|
||||||
|
|
||||||
await expect(page.locator("tbody tr")).toHaveCount(16, { timeout: 15000 });
|
await expect(page.locator("tbody tr")).toHaveCount(16, { timeout: 15000 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user