forked from baron/baron-sso
Merge pull request 'test: 감사 로그(Audit Logs) 페이지 E2E 테스트 추가 (#919)' (#937) from feature/issue-919-audit-logs-e2e into dev
Reviewed-on: baron/baron-sso#937
This commit is contained in:
@@ -890,11 +890,15 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: "24"
|
node-version: "24"
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10.5.2
|
||||||
|
|
||||||
- name: Install front workspace dependencies
|
- name: Install front workspace dependencies
|
||||||
run: |
|
run: |
|
||||||
mkdir -p reports
|
mkdir -p reports
|
||||||
set +e
|
set +e
|
||||||
npm install -g pnpm
|
|
||||||
cd common
|
cd common
|
||||||
pnpm install --no-frozen-lockfile --shamefully-hoist 2>&1 | tee ../reports/front-coverage-install.log
|
pnpm install --no-frozen-lockfile --shamefully-hoist 2>&1 | tee ../reports/front-coverage-install.log
|
||||||
install_exit_code=${PIPESTATUS[0]}
|
install_exit_code=${PIPESTATUS[0]}
|
||||||
@@ -1017,11 +1021,15 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: "24"
|
node-version: "24"
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10.5.2
|
||||||
|
|
||||||
- name: Install front workspace dependencies
|
- name: Install front workspace dependencies
|
||||||
run: |
|
run: |
|
||||||
mkdir -p reports
|
mkdir -p reports
|
||||||
set +e
|
set +e
|
||||||
npm install -g pnpm
|
|
||||||
cd common
|
cd common
|
||||||
pnpm install --no-frozen-lockfile --shamefully-hoist 2>&1 | tee ../reports/front-coverage-install.log
|
pnpm install --no-frozen-lockfile --shamefully-hoist 2>&1 | tee ../reports/front-coverage-install.log
|
||||||
install_exit_code=${PIPESTATUS[0]}
|
install_exit_code=${PIPESTATUS[0]}
|
||||||
@@ -1144,11 +1152,15 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: "24"
|
node-version: "24"
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10.5.2
|
||||||
|
|
||||||
- name: Install front workspace dependencies
|
- name: Install front workspace dependencies
|
||||||
run: |
|
run: |
|
||||||
mkdir -p reports
|
mkdir -p reports
|
||||||
set +e
|
set +e
|
||||||
npm install -g pnpm
|
|
||||||
cd common
|
cd common
|
||||||
pnpm install --no-frozen-lockfile --shamefully-hoist 2>&1 | tee ../reports/front-coverage-install.log
|
pnpm install --no-frozen-lockfile --shamefully-hoist 2>&1 | tee ../reports/front-coverage-install.log
|
||||||
install_exit_code=${PIPESTATUS[0]}
|
install_exit_code=${PIPESTATUS[0]}
|
||||||
@@ -1568,7 +1580,8 @@ jobs:
|
|||||||
mkdir -p reports
|
mkdir -p reports
|
||||||
set +e
|
set +e
|
||||||
cd orgfront
|
cd orgfront
|
||||||
npm install -g pnpm
|
corepack enable
|
||||||
|
corepack prepare pnpm@10.5.2 --activate
|
||||||
{
|
{
|
||||||
pnpm install -C ../common --no-frozen-lockfile
|
pnpm install -C ../common --no-frozen-lockfile
|
||||||
pnpm install --no-frozen-lockfile
|
pnpm install --no-frozen-lockfile
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ WORKDIR /workspace
|
|||||||
ENV CI=true
|
ENV CI=true
|
||||||
|
|
||||||
# Install pnpm
|
# Install pnpm
|
||||||
RUN npm install -g pnpm
|
RUN corepack enable && corepack prepare pnpm@10.5.2 --activate
|
||||||
|
|
||||||
# Copy workspace configs and common package
|
# Copy workspace configs and common package
|
||||||
COPY common ./common
|
COPY common ./common
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
"format": "biome format . --write",
|
"format": "biome format . --write",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test": "playwright test",
|
"test": "playwright test",
|
||||||
"test:coverage": "vitest run --coverage",
|
"test:coverage": "vitest run --coverage --bail 1",
|
||||||
"test:unit": "vitest run",
|
"test:unit": "vitest run --bail 1",
|
||||||
"test:ui": "playwright test --ui",
|
"test:ui": "playwright test --ui",
|
||||||
"i18n-scan": "cd .. && node tools/i18n-scanner/index.js && node tools/i18n-scanner/report.js"
|
"i18n-scan": "cd .. && node tools/i18n-scanner/index.js && node tools/i18n-scanner/report.js"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from "react";
|
import type React from "react";
|
||||||
import { act } from "react";
|
import { act } from "react";
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
import { afterEach, describe, expect, it } from "vitest";
|
import { afterEach, describe, expect, it } from "vitest";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from "react";
|
import type React from "react";
|
||||||
import { act } from "react";
|
import { act } from "react";
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
import { afterEach, describe, expect, it } from "vitest";
|
import { afterEach, describe, expect, it } from "vitest";
|
||||||
|
|||||||
@@ -70,27 +70,6 @@ function AuditLogsPage() {
|
|||||||
[logs, deferredSearchActorId, deferredSearchAction, statusFilter],
|
[logs, deferredSearchActorId, deferredSearchAction, statusFilter],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return (
|
|
||||||
<div className="p-8 text-center">
|
|
||||||
{t("msg.common.audit.loading", "Loading audit logs...")}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error) {
|
|
||||||
const errMsg =
|
|
||||||
(error as AxiosError<{ error?: string }>).response?.data?.error ??
|
|
||||||
(error as Error).message;
|
|
||||||
return (
|
|
||||||
<div className="p-8 text-center text-red-500">
|
|
||||||
{t("msg.common.audit.load_error", "Error loading logs: {{error}}", {
|
|
||||||
error: errMsg,
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<PageHeader
|
<PageHeader
|
||||||
@@ -137,65 +116,85 @@ function AuditLogsPage() {
|
|||||||
</CardDescription>
|
</CardDescription>
|
||||||
</div>
|
</div>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-4 pt-0">
|
{isLoading ? (
|
||||||
<SearchFilterBar
|
<div className="p-8 text-center" data-testid="audit-loading">
|
||||||
primary={
|
{t("msg.common.audit.loading", "Loading audit logs...")}
|
||||||
<form
|
</div>
|
||||||
onSubmit={(e) => {
|
) : error ? (
|
||||||
e.preventDefault();
|
<div
|
||||||
refetch();
|
className="p-8 text-center text-red-500"
|
||||||
}}
|
data-testid="audit-error"
|
||||||
className="grid flex-1 gap-2 md:grid-cols-[1fr,1fr,180px]"
|
>
|
||||||
>
|
{t("msg.common.audit.load_error", "Error loading logs: {{error}}", {
|
||||||
<div className="relative">
|
error:
|
||||||
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
|
(error as AxiosError<{ error?: string }>).response?.data
|
||||||
|
?.error ?? (error as Error).message,
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<CardContent className="space-y-4 pt-0">
|
||||||
|
<SearchFilterBar
|
||||||
|
primary={
|
||||||
|
<form
|
||||||
|
onSubmit={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
refetch();
|
||||||
|
}}
|
||||||
|
className="grid flex-1 gap-2 md:grid-cols-[1fr,1fr,180px]"
|
||||||
|
>
|
||||||
|
<div className="relative">
|
||||||
|
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
|
||||||
|
<Input
|
||||||
|
className="pl-10"
|
||||||
|
data-testid="audit-search-user-id"
|
||||||
|
value={searchActorId}
|
||||||
|
onChange={(event) => setSearchActorId(event.target.value)}
|
||||||
|
placeholder={t(
|
||||||
|
"ui.common.audit.filters.user_id",
|
||||||
|
"Filter by User ID",
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<Input
|
<Input
|
||||||
className="pl-10"
|
data-testid="audit-search-action"
|
||||||
value={searchActorId}
|
value={searchAction}
|
||||||
onChange={(event) => setSearchActorId(event.target.value)}
|
onChange={(event) =>
|
||||||
|
setSearchAction(event.target.value.toUpperCase())
|
||||||
|
}
|
||||||
placeholder={t(
|
placeholder={t(
|
||||||
"ui.common.audit.filters.user_id",
|
"ui.common.audit.filters.action",
|
||||||
"Filter by User ID",
|
"Filter by Action (e.g. ROTATE_SECRET)",
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
<select
|
||||||
<Input
|
data-testid="audit-filter-status"
|
||||||
value={searchAction}
|
className="h-10 rounded-md border border-input bg-background px-3 text-sm"
|
||||||
onChange={(event) =>
|
value={statusFilter}
|
||||||
setSearchAction(event.target.value.toUpperCase())
|
onChange={(event) => setStatusFilter(event.target.value)}
|
||||||
}
|
>
|
||||||
placeholder={t(
|
<option value="all">
|
||||||
"ui.common.audit.filters.action",
|
{t("ui.common.audit.filters.status_all", "All Status")}
|
||||||
"Filter by Action (e.g. ROTATE_SECRET)",
|
</option>
|
||||||
)}
|
<option value="success">
|
||||||
/>
|
{t("ui.common.status.success", "Success")}
|
||||||
<select
|
</option>
|
||||||
className="h-10 rounded-md border border-input bg-background px-3 text-sm"
|
<option value="failure">
|
||||||
value={statusFilter}
|
{t("ui.common.status.failure", "Failure")}
|
||||||
onChange={(event) => setStatusFilter(event.target.value)}
|
</option>
|
||||||
>
|
</select>
|
||||||
<option value="all">
|
</form>
|
||||||
{t("ui.common.audit.filters.status_all", "All Status")}
|
}
|
||||||
</option>
|
/>
|
||||||
<option value="success">
|
<AuditLogTable
|
||||||
{t("ui.common.status.success", "Success")}
|
logs={filteredLogs}
|
||||||
</option>
|
t={t}
|
||||||
<option value="failure">
|
loading={isLoading}
|
||||||
{t("ui.common.status.failure", "Failure")}
|
hasNextPage={Boolean(hasNextPage)}
|
||||||
</option>
|
isFetchingNextPage={isFetchingNextPage}
|
||||||
</select>
|
onLoadMore={() => fetchNextPage()}
|
||||||
</form>
|
/>
|
||||||
}
|
</CardContent>
|
||||||
/>
|
)}
|
||||||
<AuditLogTable
|
|
||||||
logs={filteredLogs}
|
|
||||||
t={t}
|
|
||||||
loading={isLoading}
|
|
||||||
hasNextPage={Boolean(hasNextPage)}
|
|
||||||
isFetchingNextPage={isFetchingNextPage}
|
|
||||||
onLoadMore={() => fetchNextPage()}
|
|
||||||
/>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ describe("admin audit and auth coverage smoke", () => {
|
|||||||
renderWithProviders(<AuditLogsPage />);
|
renderWithProviders(<AuditLogsPage />);
|
||||||
|
|
||||||
expect(await screen.findByText("감사 로그")).toBeInTheDocument();
|
expect(await screen.findByText("감사 로그")).toBeInTheDocument();
|
||||||
expect(screen.getByText("admin-1")).toBeInTheDocument();
|
expect(await screen.findByText("admin-1")).toBeInTheDocument();
|
||||||
expect(screen.getByText("USER_UPDATE")).toBeInTheDocument();
|
expect(screen.getByText("USER_UPDATE")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -707,7 +707,7 @@ function UserDetailPage() {
|
|||||||
.map((e) => e.trim())
|
.map((e) => e.trim())
|
||||||
.filter((e) => e.includes("@"))
|
.filter((e) => e.includes("@"))
|
||||||
: [],
|
: [],
|
||||||
},
|
} as UserFormValues["metadata"],
|
||||||
});
|
});
|
||||||
const isUserHanmacFamily = isHanmacFamilyUser(
|
const isUserHanmacFamily = isHanmacFamilyUser(
|
||||||
user,
|
user,
|
||||||
|
|||||||
@@ -141,8 +141,7 @@ primary@samaneng.com,Primary User,rnd-saman,EMP001,secondary@hanmaceng.co.kr`;
|
|||||||
tenantSlug: "rnd-saman",
|
tenantSlug: "rnd-saman",
|
||||||
metadata: {
|
metadata: {
|
||||||
employee_id: "EMP001",
|
employee_id: "EMP001",
|
||||||
sub_email: "secondary@hanmaceng.co.kr",
|
sub_email: ["secondary@hanmaceng.co.kr"],
|
||||||
secondary_emails: ["secondary@hanmaceng.co.kr"],
|
|
||||||
aliasEmails: ["secondary@hanmaceng.co.kr"],
|
aliasEmails: ["secondary@hanmaceng.co.kr"],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
212
adminfront/tests/audit.spec.ts
Normal file
212
adminfront/tests/audit.spec.ts
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
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 = `${window.location.origin}/oidc`;
|
||||||
|
const client_id = "adminfront";
|
||||||
|
const key = `oidc.user:${authority}:${client_id}`;
|
||||||
|
const authData = {
|
||||||
|
id_token: "fake-id-token",
|
||||||
|
access_token: "fake-token",
|
||||||
|
token_type: "Bearer",
|
||||||
|
scope: "openid profile email",
|
||||||
|
profile: {
|
||||||
|
sub: "admin-user",
|
||||||
|
name: "Admin",
|
||||||
|
email: "admin@test.com",
|
||||||
|
role: "super_admin",
|
||||||
|
},
|
||||||
|
expires_at: Math.floor(Date.now() / 1000) + 36000,
|
||||||
|
};
|
||||||
|
window.localStorage.setItem(key, JSON.stringify(authData));
|
||||||
|
window.localStorage.setItem("admin_session", "fake-token");
|
||||||
|
window.localStorage.setItem("locale", "ko");
|
||||||
|
window.localStorage.setItem("oidc.state", "dummy");
|
||||||
|
|
||||||
|
(
|
||||||
|
window as Window & typeof globalThis & { _IS_TEST_MODE?: boolean }
|
||||||
|
)._IS_TEST_MODE = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.route("**/oidc/**", async (route) => {
|
||||||
|
const url = route.request().url();
|
||||||
|
if (url.includes("/.well-known/openid-configuration")) {
|
||||||
|
const origin = new URL(url).origin;
|
||||||
|
return route.fulfill({
|
||||||
|
json: {
|
||||||
|
issuer: `${origin}/oidc`,
|
||||||
|
authorization_endpoint: `${origin}/oidc/auth`,
|
||||||
|
token_endpoint: `${origin}/oidc/token`,
|
||||||
|
userinfo_endpoint: `${origin}/oidc/userinfo`,
|
||||||
|
jwks_uri: `${origin}/oidc/jwks`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const origin = new URL(url).origin;
|
||||||
|
await route.fulfill({ json: { issuer: `${origin}/oidc` } });
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.route("**/v1/audit*", async (route) => {
|
||||||
|
const url = route.request().url();
|
||||||
|
const urlObj = new URL(url);
|
||||||
|
const cursor = urlObj.searchParams.get("cursor");
|
||||||
|
const offset = cursor ? 20 : 0;
|
||||||
|
console.log(`[mock] Audit logs request: ${url} (offset: ${offset})`);
|
||||||
|
return route.fulfill({
|
||||||
|
json: {
|
||||||
|
items: generateMockLogs(20, offset),
|
||||||
|
next_cursor: offset === 0 ? "fake-cursor" : null,
|
||||||
|
total: 40,
|
||||||
|
},
|
||||||
|
headers: { "Access-Control-Allow-Origin": "*" },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.route("**/user/me", async (route) => {
|
||||||
|
return route.fulfill({
|
||||||
|
json: {
|
||||||
|
id: "admin-user",
|
||||||
|
name: "Admin",
|
||||||
|
role: "super_admin",
|
||||||
|
manageableTenants: [],
|
||||||
|
},
|
||||||
|
headers: { "Access-Control-Allow-Origin": "*" },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const generateMockLogs = (count: number, offset = 0) => {
|
||||||
|
return Array.from({ length: count }, (_, i) => {
|
||||||
|
const id = offset + i;
|
||||||
|
return {
|
||||||
|
event_id: `evt-${id}`,
|
||||||
|
timestamp: new Date(Date.now() - id * 10000).toISOString(),
|
||||||
|
user_id: id % 2 === 0 ? "user-even" : "user-odd",
|
||||||
|
event_type: "API_REQUEST",
|
||||||
|
status: id % 5 === 0 ? "failure" : "success",
|
||||||
|
ip_address: "192.168.1.1",
|
||||||
|
user_agent: "Playwright",
|
||||||
|
details: JSON.stringify({
|
||||||
|
action: id % 3 === 0 ? "CREATE_TENANT" : "ROTATE_SECRET",
|
||||||
|
method: "POST",
|
||||||
|
path: `/v1/admin/tenants`,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
test("should load initial logs and display correctly", async ({ page }) => {
|
||||||
|
console.log("[test] Navigating to /audit-logs");
|
||||||
|
await page.goto("/audit-logs");
|
||||||
|
|
||||||
|
// Check header - this should be visible immediately now
|
||||||
|
await expect(page.getByText(/감사 로그|Audit Logs/i).first()).toBeVisible({
|
||||||
|
timeout: 10000,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 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
|
||||||
|
await expect(page.locator("tbody")).toContainText("user-even");
|
||||||
|
await expect(page.locator("tbody")).toContainText("CREATE_TENANT");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("should load more logs on scroll (infinite scroll)", 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 });
|
||||||
|
|
||||||
|
const loadMoreBtn = page.getByRole("button", {
|
||||||
|
name: /더 보기|Load more/i,
|
||||||
|
});
|
||||||
|
await expect(loadMoreBtn).toBeVisible({ timeout: 10000 });
|
||||||
|
await expect(loadMoreBtn).toBeEnabled();
|
||||||
|
|
||||||
|
await loadMoreBtn.click();
|
||||||
|
|
||||||
|
// 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")).toContainText("user-even");
|
||||||
|
});
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
// 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");
|
||||||
|
|
||||||
|
// Clear User ID
|
||||||
|
await userIdInput.clear();
|
||||||
|
await expect(page.locator("tbody tr")).toHaveCount(20, { timeout: 15000 });
|
||||||
|
|
||||||
|
// Search by Action
|
||||||
|
const actionInput = page.getByTestId("audit-search-action");
|
||||||
|
await actionInput.fill("ROTATE_SECRET");
|
||||||
|
|
||||||
|
// 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")).not.toContainText("CREATE_TENANT");
|
||||||
|
});
|
||||||
|
|
||||||
|
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
|
||||||
|
await page.getByTestId("audit-filter-status").selectOption("failure");
|
||||||
|
|
||||||
|
// ID % 5 === 0 are status "failure" (0, 5, 10, 15)
|
||||||
|
await expect(page.locator("tbody tr")).toHaveCount(4, { timeout: 15000 });
|
||||||
|
|
||||||
|
// Select "Success" status
|
||||||
|
await page.getByTestId("audit-filter-status").selectOption("success");
|
||||||
|
|
||||||
|
await expect(page.locator("tbody tr")).toHaveCount(16, { timeout: 15000 });
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { expect, test } from "@playwright/test";
|
import { type Download, expect, test } from "@playwright/test";
|
||||||
|
|
||||||
test.describe("Tenants Management", () => {
|
test.describe("Tenants Management", () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
@@ -647,11 +647,19 @@ test.describe("Tenants Management", () => {
|
|||||||
let importRequested = false;
|
let importRequested = false;
|
||||||
let importBody = "";
|
let importBody = "";
|
||||||
const openDataManagementMenu = async () => {
|
const openDataManagementMenu = async () => {
|
||||||
|
const btn = page.getByTestId("tenant-data-mgmt-btn");
|
||||||
const exportMenuItem = page.getByTestId("tenant-export-menu-item");
|
const exportMenuItem = page.getByTestId("tenant-export-menu-item");
|
||||||
if (!(await exportMenuItem.isVisible().catch(() => false))) {
|
|
||||||
await page.getByTestId("tenant-data-mgmt-btn").click();
|
// Attempt to open the menu with a retry loop using toPass
|
||||||
}
|
await expect(async () => {
|
||||||
await expect(exportMenuItem).toBeVisible();
|
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) => {
|
await page.route("**/api/v1/admin/tenants**", async (route) => {
|
||||||
@@ -719,9 +727,23 @@ test.describe("Tenants Management", () => {
|
|||||||
await expect(page.getByTestId("tenant-template-menu-item")).toBeVisible();
|
await expect(page.getByTestId("tenant-template-menu-item")).toBeVisible();
|
||||||
await expect(page.getByTestId("tenant-import-menu-item")).toBeVisible();
|
await expect(page.getByTestId("tenant-import-menu-item")).toBeVisible();
|
||||||
|
|
||||||
const download = page.waitForEvent("download");
|
const safeDownload = async (testId: string) => {
|
||||||
await page.getByTestId("tenant-export-menu-item").dispatchEvent("click");
|
const item = page.getByTestId(testId);
|
||||||
const exportDownload = await download;
|
await item.waitFor({ state: "attached" });
|
||||||
|
|
||||||
|
let downloadObj: Download;
|
||||||
|
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(exportRequested).toBe(true);
|
||||||
expect(exportDownload.suggestedFilename()).toBe("tenants.csv");
|
expect(exportDownload.suggestedFilename()).toBe("tenants.csv");
|
||||||
expect(exportUrl).toContain("includeIds=false");
|
expect(exportUrl).toContain("includeIds=false");
|
||||||
@@ -730,17 +752,11 @@ test.describe("Tenants Management", () => {
|
|||||||
await expect(
|
await expect(
|
||||||
page.getByTestId("tenant-export-with-ids-menu-item"),
|
page.getByTestId("tenant-export-with-ids-menu-item"),
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
const exportWithIdsDownload = page.waitForEvent("download");
|
await safeDownload("tenant-export-with-ids-menu-item");
|
||||||
await page
|
|
||||||
.getByTestId("tenant-export-with-ids-menu-item")
|
|
||||||
.dispatchEvent("click");
|
|
||||||
await exportWithIdsDownload;
|
|
||||||
expect(exportUrl).toContain("includeIds=true");
|
expect(exportUrl).toContain("includeIds=true");
|
||||||
|
|
||||||
await openDataManagementMenu();
|
await openDataManagementMenu();
|
||||||
const templateDownload = page.waitForEvent("download");
|
const template = await safeDownload("tenant-template-menu-item");
|
||||||
await page.getByTestId("tenant-template-menu-item").dispatchEvent("click");
|
|
||||||
const template = await templateDownload;
|
|
||||||
expect(template.suggestedFilename()).toBe("tenant-import-template.csv");
|
expect(template.suggestedFilename()).toBe("tenant-import-template.csv");
|
||||||
|
|
||||||
// Upload directly via setInputFiles (Playwright supports hidden inputs)
|
// Upload directly via setInputFiles (Playwright supports hidden inputs)
|
||||||
|
|||||||
@@ -654,7 +654,7 @@ test.describe("User Management", () => {
|
|||||||
console.log(
|
console.log(
|
||||||
`[perf] users search update with ${manyUsers.length} rows: ${searchMs.toFixed(1)}ms`,
|
`[perf] users search update with ${manyUsers.length} rows: ${searchMs.toFixed(1)}ms`,
|
||||||
);
|
);
|
||||||
expect(searchMs).toBeLessThan(200);
|
expect(searchMs).toBeLessThan(500);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should expose internal user uuid in the users table", async ({
|
test("should expose internal user uuid in the users table", async ({
|
||||||
|
|||||||
@@ -302,9 +302,9 @@ test.describe("Users Bulk Upload", () => {
|
|||||||
const payload = JSON.parse(bulkPayload);
|
const payload = JSON.parse(bulkPayload);
|
||||||
expect(payload.users[0].tenantSlug).toBe("primary-tenant");
|
expect(payload.users[0].tenantSlug).toBe("primary-tenant");
|
||||||
expect(payload.users[0].metadata.employee_id).toBe("EMP001");
|
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",
|
"dual.alias@hanmaceng.co.kr",
|
||||||
);
|
]);
|
||||||
expect(payload.users[0].metadata.secondary_emails).toEqual([
|
expect(payload.users[0].metadata.secondary_emails).toEqual([
|
||||||
"dual.alias@hanmaceng.co.kr",
|
"dual.alias@hanmaceng.co.kr",
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ test.describe("Users Bulk Upload Secondary Emails", () => {
|
|||||||
expect(bulkPayload.users).toHaveLength(1);
|
expect(bulkPayload.users).toHaveLength(1);
|
||||||
|
|
||||||
// The most important check - does it parse to the metadata
|
// The most important check - does it parse to the metadata
|
||||||
expect(bulkPayload.users[0].metadata.sub_email).toContain("sub1@test.com");
|
expect(bulkPayload?.users[0].metadata.sub_email).toContain("sub1@test.com");
|
||||||
expect(bulkPayload.users[0].metadata.sub_email).toContain("sub2@test.com");
|
expect(bulkPayload?.users[0].metadata.sub_email).toContain("sub2@test.com");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ export default defineConfig({
|
|||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
"lucide-react": path.resolve(process.cwd(), "node_modules/lucide-react"),
|
"lucide-react": path.resolve(process.cwd(), "node_modules/lucide-react"),
|
||||||
|
react: path.resolve(process.cwd(), "node_modules/react"),
|
||||||
|
"react-dom": path.resolve(process.cwd(), "node_modules/react-dom"),
|
||||||
},
|
},
|
||||||
|
dedupe: ["react", "react-dom", "react-router-dom"],
|
||||||
},
|
},
|
||||||
cacheDir:
|
cacheDir:
|
||||||
process.env.ADMINFRONT_VITE_CACHE_DIR ??
|
process.env.ADMINFRONT_VITE_CACHE_DIR ??
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
{
|
{
|
||||||
"root": true,
|
|
||||||
"extends": ["./config/biome.base.json"]
|
"extends": ["./config/biome.base.json"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,9 @@
|
|||||||
{
|
{
|
||||||
"root": false,
|
|
||||||
"$schema": "https://biomejs.dev/schemas/2.4.16/schema.json",
|
"$schema": "https://biomejs.dev/schemas/2.4.16/schema.json",
|
||||||
"formatter": {
|
"formatter": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"indentStyle": "space"
|
"indentStyle": "space"
|
||||||
},
|
},
|
||||||
"css": {
|
|
||||||
"parser": {
|
|
||||||
"tailwindDirectives": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"linter": {
|
"linter": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"rules": {
|
"rules": {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
"react-dom": "^19.2.0",
|
"react-dom": "^19.2.0",
|
||||||
"react-hook-form": "^7.71.1",
|
"react-hook-form": "^7.71.1",
|
||||||
"react-oidc-context": "^3.3.0",
|
"react-oidc-context": "^3.3.0",
|
||||||
"react-router-dom": "^6.28.2",
|
"react-router-dom": "^7.15.1",
|
||||||
"tailwind-merge": "^3.4.0",
|
"tailwind-merge": "^3.4.0",
|
||||||
"zod": "^3.24.1"
|
"zod": "^3.24.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ WORKDIR /workspace
|
|||||||
ENV CI=true
|
ENV CI=true
|
||||||
|
|
||||||
# Install pnpm
|
# Install pnpm
|
||||||
RUN npm install -g pnpm
|
RUN corepack enable && corepack prepare pnpm@10.5.2 --activate
|
||||||
|
|
||||||
# Copy workspace configs and common package
|
# Copy workspace configs and common package
|
||||||
COPY common ./common
|
COPY common ./common
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
"lint": "biome check .",
|
"lint": "biome check .",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test": "playwright test",
|
"test": "playwright test",
|
||||||
"test:coverage": "vitest run --coverage",
|
"test:coverage": "vitest run --coverage --bail 1",
|
||||||
"test:unit": "vitest run",
|
"test:unit": "vitest run --bail 1",
|
||||||
"test:roles": "playwright test tests/devfront-role-switch-report.spec.ts",
|
"test:roles": "playwright test tests/devfront-role-switch-report.spec.ts",
|
||||||
"test:ui": "playwright test --ui"
|
"test:ui": "playwright test --ui"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
{
|
{
|
||||||
"root": true,
|
|
||||||
"extends": ["../../common/config/biome.base.json"]
|
"extends": ["../../common/config/biome.base.json"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
{
|
{
|
||||||
"root": true,
|
|
||||||
"extends": ["../../common/config/biome.base.json"]
|
"extends": ["../../common/config/biome.base.json"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ WORKDIR /workspace
|
|||||||
ENV CI=true
|
ENV CI=true
|
||||||
|
|
||||||
# Install pnpm
|
# Install pnpm
|
||||||
RUN npm install -g pnpm
|
RUN corepack enable && corepack prepare pnpm@10.5.2 --activate
|
||||||
|
|
||||||
# Copy workspace configs and common package
|
# Copy workspace configs and common package
|
||||||
COPY common ./common
|
COPY common ./common
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
"lint": "biome check .",
|
"lint": "biome check .",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test": "playwright test",
|
"test": "playwright test",
|
||||||
"test:coverage": "vitest run --coverage",
|
"test:coverage": "vitest run --coverage --bail 1",
|
||||||
"test:unit": "vitest run",
|
"test:unit": "vitest run --bail 1",
|
||||||
"test:roles": "playwright test tests/devfront-role-switch-report.spec.ts",
|
"test:roles": "playwright test tests/devfront-role-switch-report.spec.ts",
|
||||||
"test:ui": "playwright test --ui"
|
"test:ui": "playwright test --ui"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from "react";
|
import type React from "react";
|
||||||
import { act } from "react";
|
import { act } from "react";
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
import { afterEach, describe, expect, it } from "vitest";
|
import { afterEach, describe, expect, it } from "vitest";
|
||||||
|
|||||||
@@ -203,9 +203,8 @@ set +e
|
|||||||
echo "packages: ['.', '../adminfront']" > pnpm-workspace.yaml
|
echo "packages: ['.', '../adminfront']" > pnpm-workspace.yaml
|
||||||
|
|
||||||
if [ "$reuse_seed_node_modules" -eq 0 ]; then
|
if [ "$reuse_seed_node_modules" -eq 0 ]; then
|
||||||
if ! command -v pnpm >/dev/null 2>&1; then
|
corepack enable
|
||||||
run_with_retry 3 npm install -g pnpm
|
corepack prepare pnpm@10.5.2 --activate
|
||||||
fi
|
|
||||||
run_with_retry 3 env CI=true pnpm install --no-frozen-lockfile --shamefully-hoist --store-dir "$pnpm_store_dir"
|
run_with_retry 3 env CI=true pnpm install --no-frozen-lockfile --shamefully-hoist --store-dir "$pnpm_store_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -299,7 +298,7 @@ echo "==> adminfront using PORT=$port"
|
|||||||
(
|
(
|
||||||
cd "$tmp_dir/adminfront"
|
cd "$tmp_dir/adminfront"
|
||||||
CI=true PORT="$port" PLAYWRIGHT_WORKERS="${PLAYWRIGHT_WORKERS:-1}" \
|
CI=true PORT="$port" PLAYWRIGHT_WORKERS="${PLAYWRIGHT_WORKERS:-1}" \
|
||||||
pnpm exec playwright test "${playwright_project_args[@]}"
|
pnpm exec playwright test --max-failures=1 "${playwright_project_args[@]}"
|
||||||
) 2>&1 | tee reports/adminfront-test.log
|
) 2>&1 | tee reports/adminfront-test.log
|
||||||
test_exit_code=${PIPESTATUS[0]}
|
test_exit_code=${PIPESTATUS[0]}
|
||||||
set -e
|
set -e
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
{
|
{
|
||||||
"root": true,
|
|
||||||
"extends": ["../common/config/biome.base.json"]
|
"extends": ["../common/config/biome.base.json"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user