forked from baron/baron-sso
fix(ci): stabilize pnpm installation and ensure fail-fast testing
This commit is contained in:
@@ -2,8 +2,10 @@ import { expect, test } from "@playwright/test";
|
||||
|
||||
test.describe("Audit Logs Management", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
page.on("console", (msg) => console.log(`[PAGE] ${msg.text()}`));
|
||||
|
||||
await page.addInitScript(() => {
|
||||
const authority = "http://localhost:5000/oidc";
|
||||
const authority = `${window.location.origin}/oidc`;
|
||||
const client_id = "adminfront";
|
||||
const key = `oidc.user:${authority}:${client_id}`;
|
||||
const authData = {
|
||||
@@ -30,18 +32,21 @@ test.describe("Audit Logs Management", () => {
|
||||
});
|
||||
|
||||
await page.route("**/oidc/**", async (route) => {
|
||||
if (route.request().url().includes("/.well-known/openid-configuration")) {
|
||||
const url = route.request().url();
|
||||
if (url.includes("/.well-known/openid-configuration")) {
|
||||
const origin = new URL(url).origin;
|
||||
return route.fulfill({
|
||||
json: {
|
||||
issuer: "http://localhost:5000/oidc",
|
||||
authorization_endpoint: "http://localhost:5000/oidc/auth",
|
||||
token_endpoint: "http://localhost:5000/oidc/token",
|
||||
userinfo_endpoint: "http://localhost:5000/oidc/userinfo",
|
||||
jwks_uri: "http://localhost:5000/oidc/jwks",
|
||||
issuer: `${origin}/oidc`,
|
||||
authorization_endpoint: `${origin}/oidc/auth`,
|
||||
token_endpoint: `${origin}/oidc/token`,
|
||||
userinfo_endpoint: `${origin}/oidc/userinfo`,
|
||||
jwks_uri: `${origin}/oidc/jwks`,
|
||||
},
|
||||
});
|
||||
}
|
||||
await route.fulfill({ json: { issuer: "http://localhost:5000/oidc" } });
|
||||
const origin = new URL(url).origin;
|
||||
await route.fulfill({ json: { issuer: `${origin}/oidc` } });
|
||||
});
|
||||
|
||||
await page.route("**/v1/audit*", async (route) => {
|
||||
@@ -97,12 +102,29 @@ test.describe("Audit Logs Management", () => {
|
||||
console.log("[test] Navigating to /audit-logs");
|
||||
await page.goto("/audit-logs");
|
||||
|
||||
// Check header
|
||||
// Check header - this should be visible immediately now
|
||||
await expect(page.getByText(/감사 로그|Audit Logs/i).first()).toBeVisible({
|
||||
timeout: 20000,
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
// Wait for the table row to appear (retry mechanism in expect will handle the async load)
|
||||
// Ensure we are not stuck in a global loading state (AppLayout)
|
||||
await expect(page.locator(".animate-spin")).not.toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
// Check for audit page specific error
|
||||
const errorEl = page.getByTestId("audit-error");
|
||||
if (await errorEl.isVisible()) {
|
||||
const errorText = await errorEl.innerText();
|
||||
throw new Error(`Audit log page showed error: ${errorText}`);
|
||||
}
|
||||
|
||||
// Wait for loading to finish
|
||||
await expect(page.getByTestId("audit-loading")).not.toBeVisible({
|
||||
timeout: 15000,
|
||||
});
|
||||
|
||||
// Wait for the table row to appear
|
||||
await expect(page.locator("tbody tr")).toHaveCount(20, { timeout: 15000 });
|
||||
|
||||
// Check specific data visible in the row
|
||||
@@ -114,6 +136,12 @@ test.describe("Audit Logs Management", () => {
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/audit-logs");
|
||||
await expect(page.locator(".animate-spin")).not.toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
await expect(page.getByTestId("audit-loading")).not.toBeVisible({
|
||||
timeout: 15000,
|
||||
});
|
||||
await expect(page.locator("tbody tr")).toHaveCount(20, { timeout: 15000 });
|
||||
|
||||
const loadMoreBtn = page.getByRole("button", {
|
||||
@@ -131,13 +159,19 @@ test.describe("Audit Logs Management", () => {
|
||||
|
||||
test("should filter logs by Action and User ID locally", async ({ page }) => {
|
||||
await page.goto("/audit-logs");
|
||||
await expect(page.locator(".animate-spin")).not.toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
await expect(page.getByTestId("audit-loading")).not.toBeVisible({
|
||||
timeout: 15000,
|
||||
});
|
||||
await expect(page.locator("tbody tr")).toHaveCount(20, { timeout: 15000 });
|
||||
|
||||
// Search by User ID
|
||||
const userIdInput = page.getByTestId("audit-search-user-id");
|
||||
await userIdInput.fill("user-even");
|
||||
|
||||
// Playwright expect will retry, so it will wait for deferred value
|
||||
// Wait for deferred value to apply
|
||||
await expect(page.locator("tbody tr")).toHaveCount(10, { timeout: 15000 });
|
||||
await expect(page.locator("tbody")).not.toContainText("user-odd");
|
||||
|
||||
@@ -156,6 +190,12 @@ test.describe("Audit Logs Management", () => {
|
||||
|
||||
test("should filter logs by Status locally", async ({ page }) => {
|
||||
await page.goto("/audit-logs");
|
||||
await expect(page.locator(".animate-spin")).not.toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
await expect(page.getByTestId("audit-loading")).not.toBeVisible({
|
||||
timeout: 15000,
|
||||
});
|
||||
await expect(page.locator("tbody tr")).toHaveCount(20, { timeout: 15000 });
|
||||
|
||||
// Select "Failure" status
|
||||
|
||||
@@ -302,9 +302,9 @@ test.describe("Users Bulk Upload", () => {
|
||||
const payload = JSON.parse(bulkPayload);
|
||||
expect(payload.users[0].tenantSlug).toBe("primary-tenant");
|
||||
expect(payload.users[0].metadata.employee_id).toBe("EMP001");
|
||||
expect(payload.users[0].metadata.sub_email).toBe(
|
||||
expect(payload.users[0].metadata.sub_email).toEqual([
|
||||
"dual.alias@hanmaceng.co.kr",
|
||||
);
|
||||
]);
|
||||
expect(payload.users[0].metadata.secondary_emails).toEqual([
|
||||
"dual.alias@hanmaceng.co.kr",
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user