forked from baron/baron-sso
test: raise frontend coverage baselines
This commit is contained in:
@@ -258,7 +258,7 @@ test.describe("Tenants Management", () => {
|
||||
page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 900, height: 700 });
|
||||
let requestCount = 0;
|
||||
let _requestCount = 0;
|
||||
|
||||
await page.route("**/api/v1/admin/tenants**", async (route) => {
|
||||
if (route.request().method() !== "GET") {
|
||||
@@ -266,7 +266,7 @@ test.describe("Tenants Management", () => {
|
||||
}
|
||||
const url = new URL(route.request().url());
|
||||
const cursor = url.searchParams.get("cursor");
|
||||
requestCount += 1;
|
||||
_requestCount += 1;
|
||||
|
||||
if (!cursor) {
|
||||
return route.fulfill({
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
type BulkUsersRequest = {
|
||||
users: Array<{
|
||||
metadata: {
|
||||
sub_email?: string[];
|
||||
};
|
||||
}>;
|
||||
};
|
||||
|
||||
test.describe("Users Bulk Upload Secondary Emails", () => {
|
||||
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;
|
||||
(
|
||||
window as Window & typeof globalThis & { _IS_TEST_MODE?: boolean }
|
||||
)._IS_TEST_MODE = true;
|
||||
|
||||
const authData = {
|
||||
access_token: "fake-token",
|
||||
@@ -13,12 +23,20 @@ test.describe("Users Bulk Upload Secondary Emails", () => {
|
||||
profile: { sub: "admin-user", name: "Admin", role: "super_admin" },
|
||||
expires_at: Math.floor(Date.now() / 1000) + 36000,
|
||||
};
|
||||
window.localStorage.setItem("oidc.user:http://localhost:5000/oidc:adminfront", JSON.stringify(authData));
|
||||
window.localStorage.setItem(
|
||||
"oidc.user:http://localhost:5000/oidc:adminfront",
|
||||
JSON.stringify(authData),
|
||||
);
|
||||
});
|
||||
|
||||
await page.route("**/api/v1/user/me", async (route) => {
|
||||
return route.fulfill({
|
||||
json: { id: "admin-user", name: "Admin", role: "super_admin", manageableTenants: [] },
|
||||
json: {
|
||||
id: "admin-user",
|
||||
name: "Admin",
|
||||
role: "super_admin",
|
||||
manageableTenants: [],
|
||||
},
|
||||
headers: { "Access-Control-Allow-Origin": "*" },
|
||||
});
|
||||
});
|
||||
@@ -31,7 +49,7 @@ test.describe("Users Bulk Upload Secondary Emails", () => {
|
||||
});
|
||||
|
||||
await page.route("**/api/v1/admin/users*", async (route) => {
|
||||
if(route.request().url().includes("/bulk")) {
|
||||
if (route.request().url().includes("/bulk")) {
|
||||
return route.continue();
|
||||
}
|
||||
return route.fulfill({
|
||||
@@ -45,14 +63,20 @@ test.describe("Users Bulk Upload Secondary Emails", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("should parse secondary_emails and send to backend", async ({ page }) => {
|
||||
let bulkPayload: any = null;
|
||||
test("should parse secondary_emails and send to backend", async ({
|
||||
page,
|
||||
}) => {
|
||||
let bulkPayload: BulkUsersRequest | null = null;
|
||||
|
||||
await page.route("**/api/v1/admin/users/bulk", async (route) => {
|
||||
if (route.request().method() === "POST") {
|
||||
bulkPayload = route.request().postDataJSON();
|
||||
bulkPayload = route.request().postDataJSON() as BulkUsersRequest;
|
||||
return route.fulfill({
|
||||
json: { results: [{ email: "test@example.com", success: true, userId: "u-1" }] },
|
||||
json: {
|
||||
results: [
|
||||
{ email: "test@example.com", success: true, userId: "u-1" },
|
||||
],
|
||||
},
|
||||
headers: { "Access-Control-Allow-Origin": "*" },
|
||||
});
|
||||
}
|
||||
@@ -60,21 +84,26 @@ test.describe("Users Bulk Upload Secondary Emails", () => {
|
||||
});
|
||||
|
||||
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 },
|
||||
);
|
||||
|
||||
await page.getByTestId("user-data-mgmt-btn").click();
|
||||
await page.getByRole("menuitem", { name: /일괄 임포트|일괄 등록|Bulk Import/i }).click();
|
||||
await page
|
||||
.getByRole("menuitem", { name: /일괄 임포트|일괄 등록|Bulk Import/i })
|
||||
.click();
|
||||
|
||||
// Create a mock CSV with secondary_emails
|
||||
const csvContent = `email,sub_email,name,phone,role,tenant_slug\ntest@example.com,sub1@test.com;sub2@test.com,홍길동,010-1234-5678,user,tenant-slug`;
|
||||
|
||||
const fileChooserPromise = page.waitForEvent('filechooser');
|
||||
const fileChooserPromise = page.waitForEvent("filechooser");
|
||||
await page.getByText(/파일 선택|Change file|Select file/i).click();
|
||||
const fileChooser = await fileChooserPromise;
|
||||
|
||||
await fileChooser.setFiles({
|
||||
name: 'users_with_secondary.csv',
|
||||
mimeType: 'text/csv',
|
||||
name: "users_with_secondary.csv",
|
||||
mimeType: "text/csv",
|
||||
buffer: Buffer.from(csvContent),
|
||||
});
|
||||
|
||||
@@ -87,9 +116,9 @@ test.describe("Users Bulk Upload Secondary Emails", () => {
|
||||
|
||||
expect(bulkPayload).not.toBeNull();
|
||||
expect(bulkPayload.users).toHaveLength(1);
|
||||
|
||||
|
||||
// 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("sub2@test.com");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user