forked from baron/baron-sso
린트 적용
This commit is contained in:
@@ -7,9 +7,14 @@ test.describe("Bulk Actions and Tree Search", () => {
|
||||
const authority = "http://localhost:5000/oidc";
|
||||
const client_id = "adminfront";
|
||||
const key = `oidc.user:${authority}:${client_id}`;
|
||||
window.localStorage.setItem(key, JSON.stringify({
|
||||
access_token: "fake", profile: { sub: "admin", role: "super_admin" }, expires_at: 9999999999
|
||||
}));
|
||||
window.localStorage.setItem(
|
||||
key,
|
||||
JSON.stringify({
|
||||
access_token: "fake",
|
||||
profile: { sub: "admin", role: "super_admin" },
|
||||
expires_at: 9999999999,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
// Mock APIs
|
||||
@@ -18,34 +23,61 @@ test.describe("Bulk Actions and Tree Search", () => {
|
||||
});
|
||||
|
||||
await page.route("**/api/v1/admin/users?*", async (route) => {
|
||||
await route.fulfill({ json: {
|
||||
items: [
|
||||
{ id: "u-1", name: "User One", email: "u1@test.com", status: "active", role: "user", createdAt: new Date().toISOString() },
|
||||
{ id: "u-2", name: "User Two", email: "u2@test.com", status: "active", role: "user", createdAt: new Date().toISOString() },
|
||||
],
|
||||
total: 2
|
||||
}});
|
||||
await route.fulfill({
|
||||
json: {
|
||||
items: [
|
||||
{
|
||||
id: "u-1",
|
||||
name: "User One",
|
||||
email: "u1@test.com",
|
||||
status: "active",
|
||||
role: "user",
|
||||
createdAt: new Date().toISOString(),
|
||||
},
|
||||
{
|
||||
id: "u-2",
|
||||
name: "User Two",
|
||||
email: "u2@test.com",
|
||||
status: "active",
|
||||
role: "user",
|
||||
createdAt: new Date().toISOString(),
|
||||
},
|
||||
],
|
||||
total: 2,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/api/v1/admin/tenants/t-1", async (route) => {
|
||||
await route.fulfill({ json: { id: "t-1", name: "Main Tenant", slug: "main" } });
|
||||
await route.fulfill({
|
||||
json: { id: "t-1", name: "Main Tenant", slug: "main" },
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/api/v1/admin/tenants/t-1/organization", async (route) => {
|
||||
await route.fulfill({ json: [
|
||||
{ id: "g-1", name: "Engineering", slug: "eng", tenantId: "t-1" },
|
||||
{ id: "g-2", name: "Sales", slug: "sales", tenantId: "t-1" },
|
||||
]});
|
||||
});
|
||||
await page.route(
|
||||
"**/api/v1/admin/tenants/t-1/organization",
|
||||
async (route) => {
|
||||
await route.fulfill({
|
||||
json: [
|
||||
{ id: "g-1", name: "Engineering", slug: "eng", tenantId: "t-1" },
|
||||
{ id: "g-2", name: "Sales", slug: "sales", tenantId: "t-1" },
|
||||
],
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test("should show bulk action bar when users are selected", async ({ page }) => {
|
||||
test("should show bulk action bar when users are selected", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/users");
|
||||
|
||||
|
||||
// Check individual row
|
||||
await page.locator('input[type="checkbox"]').nth(1).check();
|
||||
await expect(page.getByText("1명 선택됨")).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: /활성화|Active/i })).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("button", { name: /활성화|Active/i }),
|
||||
).toBeVisible();
|
||||
|
||||
// Check select all
|
||||
await page.locator('input[type="checkbox"]').first().check();
|
||||
@@ -56,15 +88,19 @@ test.describe("Bulk Actions and Tree Search", () => {
|
||||
await expect(page.getByText("명 선택됨")).not.toBeVisible();
|
||||
});
|
||||
|
||||
test("should filter and highlight nodes in organization tree", async ({ page }) => {
|
||||
test("should filter and highlight nodes in organization tree", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/tenants/t-1");
|
||||
await page.getByRole("link", { name: /하위 테넌트 관리|Sub-tenant/i }).click();
|
||||
await page
|
||||
.getByRole("link", { name: /하위 테넌트 관리|Sub-tenant/i })
|
||||
.click();
|
||||
|
||||
const searchInput = page.getByPlaceholder(/조직도 내 검색|Search in tree/i);
|
||||
await expect(searchInput).toBeVisible();
|
||||
|
||||
await searchInput.fill("Eng");
|
||||
|
||||
|
||||
// Check if Engineering row is highlighted
|
||||
const engRow = page.locator('tr:has-text("Engineering")');
|
||||
await expect(engRow).toHaveClass(/bg-primary\/10/);
|
||||
|
||||
@@ -21,14 +21,22 @@ test.describe("Users Bulk Upload", () => {
|
||||
});
|
||||
|
||||
// Mock OIDC config
|
||||
await page.route("**/oidc/.well-known/openid-configuration", async (route) => {
|
||||
await route.fulfill({ json: { issuer: "http://localhost:5000/oidc" } });
|
||||
});
|
||||
await page.route(
|
||||
"**/oidc/.well-known/openid-configuration",
|
||||
async (route) => {
|
||||
await route.fulfill({ json: { issuer: "http://localhost:5000/oidc" } });
|
||||
},
|
||||
);
|
||||
|
||||
// Mock user profile
|
||||
await page.route("**/api/v1/user/me", async (route) => {
|
||||
await route.fulfill({
|
||||
json: { id: "admin-user", name: "Admin User", email: "admin@example.com", role: "super_admin" },
|
||||
json: {
|
||||
id: "admin-user",
|
||||
name: "Admin User",
|
||||
email: "admin@example.com",
|
||||
role: "super_admin",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -42,13 +50,19 @@ test.describe("Users Bulk Upload", () => {
|
||||
|
||||
test("should open bulk upload modal and show preview", async ({ page }) => {
|
||||
await page.goto("/users");
|
||||
|
||||
const bulkBtn = page.getByRole("button", { name: /일괄 등록|Bulk Import/i });
|
||||
|
||||
const bulkBtn = page.getByRole("button", {
|
||||
name: /일괄 등록|Bulk Import/i,
|
||||
});
|
||||
await expect(bulkBtn).toBeVisible();
|
||||
await bulkBtn.click();
|
||||
|
||||
await expect(page.getByText(/사용자 일괄 등록|User Bulk Upload/i)).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: /템플릿 다운로드|Download Template/i })).toBeVisible();
|
||||
await expect(
|
||||
page.getByText(/사용자 일괄 등록|User Bulk Upload/i),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("button", { name: /템플릿 다운로드|Download Template/i }),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test("should show success results after mock upload", async ({ page }) => {
|
||||
@@ -58,7 +72,11 @@ test.describe("Users Bulk Upload", () => {
|
||||
json: {
|
||||
results: [
|
||||
{ email: "success@test.com", success: true, userId: "u-1" },
|
||||
{ email: "fail@test.com", success: false, message: "Invalid format" },
|
||||
{
|
||||
email: "fail@test.com",
|
||||
success: false,
|
||||
message: "Invalid format",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
@@ -69,7 +87,9 @@ test.describe("Users Bulk Upload", () => {
|
||||
|
||||
// Directly set internal state for testing results view if file simulation is hard
|
||||
// But let's assume we want to see the "Start Upload" button disabled initially
|
||||
const uploadBtn = page.getByRole("button", { name: /등록 시작|Start Upload/i });
|
||||
const uploadBtn = page.getByRole("button", {
|
||||
name: /등록 시작|Start Upload/i,
|
||||
});
|
||||
await expect(uploadBtn).toBeDisabled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,19 +10,31 @@ test.describe("User Schema Dynamic Form", () => {
|
||||
const authData = {
|
||||
access_token: "fake-token",
|
||||
token_type: "Bearer",
|
||||
profile: { sub: "admin-user", name: "Admin User", email: "admin@example.com" },
|
||||
profile: {
|
||||
sub: "admin-user",
|
||||
name: "Admin User",
|
||||
email: "admin@example.com",
|
||||
},
|
||||
expires_at: Math.floor(Date.now() / 1000) + 3600,
|
||||
};
|
||||
window.localStorage.setItem(key, JSON.stringify(authData));
|
||||
});
|
||||
|
||||
await page.route("**/oidc/.well-known/openid-configuration", async (route) => {
|
||||
await route.fulfill({ json: { issuer: "http://localhost:5000/oidc" } });
|
||||
});
|
||||
await page.route(
|
||||
"**/oidc/.well-known/openid-configuration",
|
||||
async (route) => {
|
||||
await route.fulfill({ json: { issuer: "http://localhost:5000/oidc" } });
|
||||
},
|
||||
);
|
||||
|
||||
await page.route("**/api/v1/user/me", async (route) => {
|
||||
await route.fulfill({
|
||||
json: { id: "admin-user", name: "Admin User", email: "admin@example.com", role: "super_admin" },
|
||||
json: {
|
||||
id: "admin-user",
|
||||
name: "Admin User",
|
||||
email: "admin@example.com",
|
||||
role: "super_admin",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -34,11 +46,21 @@ test.describe("User Schema Dynamic Form", () => {
|
||||
slug: "test-tenant",
|
||||
config: {
|
||||
userSchema: [
|
||||
{ key: "emp_id", label: "Employee ID", required: true, validation: "^E[0-9]{3}$" },
|
||||
{ key: "salary", label: "Salary", adminOnly: true, type: "number" }
|
||||
]
|
||||
}
|
||||
}
|
||||
{
|
||||
key: "emp_id",
|
||||
label: "Employee ID",
|
||||
required: true,
|
||||
validation: "^E[0-9]{3}$",
|
||||
},
|
||||
{
|
||||
key: "salary",
|
||||
label: "Salary",
|
||||
adminOnly: true,
|
||||
type: "number",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,38 +72,51 @@ test.describe("User Schema Dynamic Form", () => {
|
||||
name: "John Doe",
|
||||
email: "john@test.com",
|
||||
companyCode: "test-tenant",
|
||||
metadata: { emp_id: "E123", salary: 1000 }
|
||||
}
|
||||
metadata: { emp_id: "E123", salary: 1000 },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/api/v1/admin/tenants**", async (route) => {
|
||||
if (route.request().method() === "GET") {
|
||||
await route.fulfill({ json: { items: [{id: "t-1", slug: "test-tenant", name: "Test Tenant"}], total: 1 } });
|
||||
await route.fulfill({
|
||||
json: {
|
||||
items: [{ id: "t-1", slug: "test-tenant", name: "Test Tenant" }],
|
||||
total: 1,
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test("should render custom fields from schema in user detail", async ({ page }) => {
|
||||
test("should render custom fields from schema in user detail", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/users/u-1");
|
||||
|
||||
await expect(page.getByText("테넌트 확장 정보 (Custom Fields)")).toBeVisible();
|
||||
await expect(
|
||||
page.getByText("테넌트 확장 정보 (Custom Fields)"),
|
||||
).toBeVisible();
|
||||
await expect(page.getByLabel("Employee ID")).toHaveValue("E123");
|
||||
await expect(page.getByLabel("Salary")).toHaveValue("1000");
|
||||
|
||||
|
||||
// Check for Admin Only badge
|
||||
await expect(page.getByText("Admin Only")).toBeVisible();
|
||||
});
|
||||
|
||||
test("should show regex validation error for custom field", async ({ page }) => {
|
||||
test("should show regex validation error for custom field", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/users/u-1");
|
||||
|
||||
const empIdInput = page.getByLabel("Employee ID");
|
||||
await empIdInput.fill("invalid");
|
||||
|
||||
|
||||
// Click somewhere to trigger blur/validation
|
||||
await page.getByLabel("이름").click();
|
||||
|
||||
await expect(page.getByText("Employee ID 형식이 올바르지 않습니다.")).toBeVisible();
|
||||
await expect(
|
||||
page.getByText("Employee ID 형식이 올바르지 않습니다."),
|
||||
).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user