forked from baron/baron-sso
Playwright 테스트 오류 수정
This commit is contained in:
@@ -5,8 +5,10 @@ test.describe("Users Bulk Upload", () => {
|
||||
await page.addInitScript(() => {
|
||||
window.localStorage.setItem("locale", "ko");
|
||||
window.localStorage.setItem("admin_session", "fake-token");
|
||||
(window as any)._IS_TEST_MODE = true;
|
||||
|
||||
(
|
||||
window as Window & typeof globalThis & { _IS_TEST_MODE?: boolean }
|
||||
)._IS_TEST_MODE = true;
|
||||
|
||||
const authority = "http://localhost:5000/oidc";
|
||||
const client_id = "adminfront";
|
||||
const key = `oidc.user:${authority}:${client_id}`;
|
||||
@@ -21,21 +23,32 @@ test.describe("Users Bulk Upload", () => {
|
||||
|
||||
await page.route("**/api/v1/**", async (route) => {
|
||||
const url = route.request().url();
|
||||
const headers = { 'Access-Control-Allow-Origin': '*' };
|
||||
const headers = { "Access-Control-Allow-Origin": "*" };
|
||||
|
||||
if (url.includes("/user/me")) {
|
||||
return route.fulfill({
|
||||
json: { id: "admin-user", name: "Admin", role: "super_admin", manageableTenants: [] },
|
||||
headers
|
||||
json: {
|
||||
id: "admin-user",
|
||||
name: "Admin",
|
||||
role: "super_admin",
|
||||
manageableTenants: [],
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
if (url.includes("/admin/users")) {
|
||||
if (!url.includes("/bulk")) {
|
||||
return route.fulfill({ json: { items: [], total: 0, limit: 50, offset: 0 }, headers });
|
||||
return route.fulfill({
|
||||
json: { items: [], total: 0, limit: 50, offset: 0 },
|
||||
headers,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (url.includes("/admin/tenants")) {
|
||||
return route.fulfill({ json: { items: [], total: 0, limit: 100, offset: 0 }, headers });
|
||||
return route.fulfill({
|
||||
json: { items: [], total: 0, limit: 100, offset: 0 },
|
||||
headers,
|
||||
});
|
||||
}
|
||||
return route.fulfill({ json: { items: [], total: 0 }, headers });
|
||||
});
|
||||
@@ -48,13 +61,21 @@ test.describe("Users Bulk Upload", () => {
|
||||
test("should open bulk upload modal and show preview", async ({ page }) => {
|
||||
await page.goto("/users");
|
||||
// 헤더 타이틀이 뜰 때까지 대기
|
||||
await expect(page.getByTestId("page-title")).toContainText(/사용자|Users/i, { timeout: 20000 });
|
||||
await expect(page.getByTestId("page-title")).toContainText(
|
||||
/사용자|Users/i,
|
||||
{ timeout: 20000 },
|
||||
);
|
||||
|
||||
const bulkBtn = page.getByTestId("bulk-import-btn");
|
||||
await bulkBtn.click();
|
||||
|
||||
await expect(page.getByTestId("bulk-upload-title")).toBeVisible({ timeout: 10000 });
|
||||
const downloadBtn = page.locator('button').filter({ hasText: /템플릿 다운로드|템플릿 받기|Download Template/ }).first();
|
||||
await expect(page.getByTestId("bulk-upload-title")).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
const downloadBtn = page
|
||||
.locator("button")
|
||||
.filter({ hasText: /템플릿 다운로드|템플릿 받기|Download Template/ })
|
||||
.first();
|
||||
await expect(downloadBtn).toBeVisible();
|
||||
});
|
||||
|
||||
@@ -65,10 +86,14 @@ 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",
|
||||
},
|
||||
],
|
||||
},
|
||||
headers: { 'Access-Control-Allow-Origin': '*' }
|
||||
headers: { "Access-Control-Allow-Origin": "*" },
|
||||
});
|
||||
} else {
|
||||
await route.continue();
|
||||
@@ -76,11 +101,14 @@ test.describe("Users Bulk Upload", () => {
|
||||
});
|
||||
|
||||
await page.goto("/users");
|
||||
await expect(page.getByTestId("page-title")).toContainText(/사용자|Users/i, { timeout: 20000 });
|
||||
await expect(page.getByTestId("page-title")).toContainText(
|
||||
/사용자|Users/i,
|
||||
{ timeout: 20000 },
|
||||
);
|
||||
|
||||
const bulkBtn = page.getByTestId("bulk-import-btn");
|
||||
await bulkBtn.click();
|
||||
|
||||
|
||||
const uploadBtn = page.getByTestId("bulk-start-btn");
|
||||
await expect(uploadBtn).toBeDisabled();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user