forked from baron/baron-sso
권한부여 및 정합성 검사 추가
This commit is contained in:
@@ -143,9 +143,10 @@ test.describe("Bulk Actions and Tree Search", () => {
|
||||
const selectionBar = page.getByTestId("bulk-action-bar");
|
||||
await expect(selectionBar).toBeVisible({ timeout: 15000 });
|
||||
|
||||
// 활성화 버튼 확인
|
||||
const activeBtn = page.getByTestId("bulk-active-btn");
|
||||
await expect(activeBtn).toBeVisible({ timeout: 10000 });
|
||||
await expect(page.getByTestId("bulk-status-select")).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
await expect(page.getByTestId("bulk-apply-status-btn")).toBeVisible();
|
||||
|
||||
// 전체 선택
|
||||
await page.locator('table input[type="checkbox"]').first().click();
|
||||
@@ -158,7 +159,7 @@ test.describe("Bulk Actions and Tree Search", () => {
|
||||
await expect(selectionBar).not.toBeVisible({ timeout: 10000 });
|
||||
});
|
||||
|
||||
test("should let super admins promote selected users to super admin", async ({
|
||||
test("should apply selected bulk status to selected users", async ({
|
||||
page,
|
||||
}) => {
|
||||
let capturedPayload: unknown = null;
|
||||
@@ -182,7 +183,48 @@ test.describe("Bulk Actions and Tree Search", () => {
|
||||
const selectionBar = page.getByTestId("bulk-action-bar");
|
||||
await expect(selectionBar).toBeVisible({ timeout: 15000 });
|
||||
|
||||
await page.getByTestId("bulk-promote-super-admin-btn").click();
|
||||
await page.getByTestId("bulk-status-select").click();
|
||||
await page.getByRole("option", { name: /정지|Suspended/i }).click();
|
||||
await page.getByTestId("bulk-apply-status-btn").click();
|
||||
|
||||
await expect
|
||||
.poll(() => capturedPayload)
|
||||
.toEqual({
|
||||
userIds: ["u-1"],
|
||||
status: "suspended",
|
||||
});
|
||||
await expect(selectionBar).not.toBeVisible({ timeout: 10000 });
|
||||
});
|
||||
|
||||
test("should let super admins apply selected admin permission to selected users", async ({
|
||||
page,
|
||||
}) => {
|
||||
let capturedPayload: unknown = null;
|
||||
await page.route("**/api/v1/admin/users/bulk", async (route) => {
|
||||
if (route.request().method() === "PUT") {
|
||||
capturedPayload = route.request().postDataJSON();
|
||||
return route.fulfill({
|
||||
json: { results: [{ id: "u-1", success: true }] },
|
||||
headers: { "Access-Control-Allow-Origin": "*" },
|
||||
});
|
||||
}
|
||||
return route.fallback();
|
||||
});
|
||||
|
||||
await page.goto("/users");
|
||||
await expect(page.locator("table")).toContainText("User One", {
|
||||
timeout: 20000,
|
||||
});
|
||||
|
||||
await page.locator('table input[type="checkbox"]').nth(1).click();
|
||||
const selectionBar = page.getByTestId("bulk-action-bar");
|
||||
await expect(selectionBar).toBeVisible({ timeout: 15000 });
|
||||
|
||||
await page.getByTestId("bulk-permission-select").click();
|
||||
await page
|
||||
.getByRole("option", { name: /시스템 관리자|Super Admin/i })
|
||||
.click();
|
||||
await page.getByTestId("bulk-apply-permission-btn").click();
|
||||
|
||||
await expect
|
||||
.poll(() => capturedPayload)
|
||||
@@ -193,6 +235,65 @@ test.describe("Bulk Actions and Tree Search", () => {
|
||||
await expect(selectionBar).not.toBeVisible({ timeout: 10000 });
|
||||
});
|
||||
|
||||
test("should let canonical super admin aliases promote selected users", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.unroute("**/api/v1/**");
|
||||
await page.route("**/api/v1/**", async (route) => {
|
||||
const url = route.request().url();
|
||||
const headers = { "Access-Control-Allow-Origin": "*" };
|
||||
|
||||
if (url.includes("/user/me")) {
|
||||
return route.fulfill({
|
||||
json: {
|
||||
id: "admin",
|
||||
role: "super-admin",
|
||||
name: "Admin",
|
||||
manageableTenants: [],
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
if (url.includes("/admin/users")) {
|
||||
return route.fulfill({
|
||||
json: {
|
||||
items: [
|
||||
{
|
||||
id: "u-1",
|
||||
name: "User One",
|
||||
email: "u1@test.com",
|
||||
status: "active",
|
||||
role: "user",
|
||||
createdAt: new Date().toISOString(),
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
if (url.includes("/admin/tenants")) {
|
||||
return route.fulfill({
|
||||
json: { items: [], total: 0 },
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
return route.fulfill({ json: { items: [], total: 0 }, headers });
|
||||
});
|
||||
|
||||
await page.goto("/users");
|
||||
await expect(page.locator("table")).toContainText("User One", {
|
||||
timeout: 20000,
|
||||
});
|
||||
|
||||
await page.locator('table input[type="checkbox"]').nth(1).click();
|
||||
const selectionBar = page.getByTestId("bulk-action-bar");
|
||||
await expect(selectionBar).toBeVisible({ timeout: 15000 });
|
||||
await expect(page.getByTestId("bulk-permission-select")).toBeVisible();
|
||||
await expect(page.getByTestId("bulk-apply-permission-btn")).toBeVisible();
|
||||
});
|
||||
|
||||
test("should filter and highlight nodes in organization tree", async ({
|
||||
page,
|
||||
}) => {
|
||||
|
||||
151
adminfront/tests/data_integrity.spec.ts
Normal file
151
adminfront/tests/data_integrity.spec.ts
Normal file
@@ -0,0 +1,151 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test.describe("Data integrity management", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.addInitScript(() => {
|
||||
window.localStorage.setItem("locale", "ko");
|
||||
window.localStorage.setItem("admin_session", "fake-token");
|
||||
(
|
||||
window as Window & typeof globalThis & { _IS_TEST_MODE?: boolean }
|
||||
)._IS_TEST_MODE = true;
|
||||
|
||||
const authority = "http://localhost:5000/oidc";
|
||||
const clientId = "adminfront";
|
||||
const key = `oidc.user:${authority}:${clientId}`;
|
||||
window.localStorage.setItem(
|
||||
key,
|
||||
JSON.stringify({
|
||||
access_token: "fake-token",
|
||||
token_type: "Bearer",
|
||||
profile: {
|
||||
sub: "admin-user",
|
||||
name: "Admin",
|
||||
email: "admin@test.com",
|
||||
role: "super_admin",
|
||||
},
|
||||
expires_at: Math.floor(Date.now() / 1000) + 36000,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
await page.route("**/api/v1/user/me", async (route) => {
|
||||
await route.fulfill({
|
||||
json: {
|
||||
id: "admin-user",
|
||||
name: "Admin",
|
||||
email: "admin@test.com",
|
||||
role: "super_admin",
|
||||
manageableTenants: [],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/api/v1/admin/integrity", async (route) => {
|
||||
await route.fulfill({
|
||||
json: {
|
||||
status: "fail",
|
||||
checkedAt: "2026-05-14T00:00:00Z",
|
||||
summary: {
|
||||
totalChecks: 2,
|
||||
passed: 1,
|
||||
warnings: 0,
|
||||
failures: 1,
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
key: "tenant_integrity",
|
||||
label: "테넌트 정합성",
|
||||
status: "fail",
|
||||
checks: [
|
||||
{
|
||||
key: "duplicate_tenant_slugs",
|
||||
label: "중복 테넌트 slug",
|
||||
description:
|
||||
"삭제되지 않은 tenant의 slug를 대소문자 무시 기준으로 검사합니다.",
|
||||
status: "fail",
|
||||
severity: "error",
|
||||
count: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
await page.route(/.*\/api\/v1\/.*/, async (route) => {
|
||||
const url = route.request().url();
|
||||
if (url.includes("/api/v1/user/me")) {
|
||||
await route.fulfill({
|
||||
json: {
|
||||
id: "admin-user",
|
||||
name: "Admin",
|
||||
email: "admin@test.com",
|
||||
role: "super_admin",
|
||||
manageableTenants: [],
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (url.includes("/api/v1/admin/integrity")) {
|
||||
await route.fulfill({
|
||||
json: {
|
||||
status: "fail",
|
||||
checkedAt: "2026-05-14T00:00:00Z",
|
||||
summary: {
|
||||
totalChecks: 2,
|
||||
passed: 1,
|
||||
warnings: 0,
|
||||
failures: 1,
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
key: "tenant_integrity",
|
||||
label: "테넌트 정합성",
|
||||
status: "fail",
|
||||
checks: [
|
||||
{
|
||||
key: "duplicate_tenant_slugs",
|
||||
label: "중복 테넌트 slug",
|
||||
description:
|
||||
"삭제되지 않은 tenant의 slug를 대소문자 무시 기준으로 검사합니다.",
|
||||
status: "fail",
|
||||
severity: "error",
|
||||
count: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (route.request().method() === "GET") {
|
||||
await route.fulfill({ json: { items: [], total: 0 } });
|
||||
} else {
|
||||
await route.fulfill({ status: 200, json: {} });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test("shows the super-admin integrity report", async ({ page }) => {
|
||||
await page.goto("/system/data-integrity");
|
||||
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "데이터 정합성 검증" }),
|
||||
).toBeVisible();
|
||||
await expect(page.getByText("테넌트 정합성")).toBeVisible();
|
||||
await expect(page.getByText("중복 테넌트 slug")).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "다시 검사" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("shows the latest integrity summary on the overview page", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/");
|
||||
|
||||
await expect(page.getByText("정합성 최종 검증")).toBeVisible();
|
||||
await expect(page.getByText("실패 1건")).toBeVisible();
|
||||
await expect(page.getByText("테넌트 정합성")).toBeVisible();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user