forked from baron/baron-sso
fix(admin): stabilize tenant import report UI and satisfy E2E tests
- Added missing i18n keys for import results in both root and common locales. - Fixed TypeScript type errors and implicit 'any' types in TenantListPage. - Added 'destructive' variant to common Badge component. - Updated Playwright tests with refined locators and enhanced API mocks to match the new reporting structure. - Restored quick summary message in Tenant Registry for backward compatibility.
This commit is contained in:
@@ -85,6 +85,8 @@ import {
|
||||
fetchMe,
|
||||
fetchTenants,
|
||||
importTenantsCSV,
|
||||
type TenantImportDetail,
|
||||
type TenantImportResult,
|
||||
type TenantSummary,
|
||||
updateTenant,
|
||||
} from "../../../lib/adminApi";
|
||||
@@ -297,8 +299,10 @@ function TenantListPage() {
|
||||
if (!importResult) return [];
|
||||
if (importResultFilter === "all") return importResult.details;
|
||||
if (importResultFilter === "failed")
|
||||
return importResult.details.filter((d) => !d.success);
|
||||
return importResult.details.filter((d) => d.action === importResultFilter);
|
||||
return importResult.details.filter((d: TenantImportDetail) => !d.success);
|
||||
return importResult.details.filter(
|
||||
(d: TenantImportDetail) => d.action === importResultFilter,
|
||||
);
|
||||
}, [importResult, importResultFilter]);
|
||||
const [selectedBulkStatus, setSelectedBulkStatus] = React.useState("");
|
||||
const _tenantTableScrollRef = React.useRef<HTMLDivElement | null>(null);
|
||||
@@ -404,6 +408,17 @@ function TenantListPage() {
|
||||
onSuccess: (result) => {
|
||||
setImportResult(result);
|
||||
setImportResultOpen(true);
|
||||
setImportMessage(
|
||||
t(
|
||||
"msg.admin.tenants.import_result",
|
||||
"생성 {{created}}, 갱신 {{updated}}, 실패 {{failed}}",
|
||||
{
|
||||
created: result.created,
|
||||
updated: result.updated,
|
||||
failed: result.failed,
|
||||
},
|
||||
),
|
||||
);
|
||||
setPreviewOpen(false);
|
||||
setPreviewRows([]);
|
||||
setSelectedMatches({});
|
||||
@@ -1135,7 +1150,7 @@ function TenantListPage() {
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
) : (
|
||||
filteredImportDetails.map((detail) => (
|
||||
filteredImportDetails.map((detail: TenantImportDetail) => (
|
||||
<TableRow key={detail.row}>
|
||||
<TableCell className="font-mono text-xs text-muted-foreground">
|
||||
{detail.row}
|
||||
@@ -1173,7 +1188,7 @@ function TenantListPage() {
|
||||
"수정됨:",
|
||||
)}
|
||||
</span>
|
||||
{detail.modifiedFields.map((field) => (
|
||||
{detail.modifiedFields.map((field: string) => (
|
||||
<Badge
|
||||
key={field}
|
||||
variant="outline"
|
||||
|
||||
@@ -684,7 +684,22 @@ test.describe("Tenants Management", () => {
|
||||
importRequested = true;
|
||||
importBody = route.request().postData() ?? "";
|
||||
return route.fulfill({
|
||||
json: { created: 0, updated: 1, failed: 0, errors: [] },
|
||||
json: {
|
||||
created: 0,
|
||||
updated: 1,
|
||||
failed: 0,
|
||||
errors: [],
|
||||
details: [
|
||||
{
|
||||
row: 2,
|
||||
name: "Tenant Alpha",
|
||||
slug: "tenant-alpha",
|
||||
success: true,
|
||||
action: "updated",
|
||||
message: "updated successfully",
|
||||
},
|
||||
],
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
@@ -774,9 +789,12 @@ test.describe("Tenants Management", () => {
|
||||
);
|
||||
await page.getByTestId("tenant-import-confirm-btn").click();
|
||||
|
||||
await expect(page.getByTestId("tenant-import-result")).toContainText(
|
||||
/갱신 1|Updated 1/i,
|
||||
);
|
||||
const resultDialog = page.getByRole("dialog").filter({
|
||||
hasText: /가져오기 결과 리포트|Import Result Report/i,
|
||||
});
|
||||
await expect(resultDialog).toBeVisible({ timeout: 15000 });
|
||||
await expect(resultDialog).toContainText(/Updated|갱신/i);
|
||||
await expect(resultDialog).toContainText("1");
|
||||
expect(importRequested).toBe(true);
|
||||
expect(importBody).toContain('filename="tenants.csv"');
|
||||
if (browserName !== "webkit") {
|
||||
@@ -799,7 +817,30 @@ test.describe("Tenants Management", () => {
|
||||
if (url.includes("/import")) {
|
||||
importBody = route.request().postData() ?? "";
|
||||
return route.fulfill({
|
||||
json: { created: 2, updated: 0, failed: 0, errors: [] },
|
||||
json: {
|
||||
created: 2,
|
||||
updated: 0,
|
||||
failed: 0,
|
||||
errors: [],
|
||||
details: [
|
||||
{
|
||||
row: 2,
|
||||
name: "Child A",
|
||||
slug: "child-a",
|
||||
success: true,
|
||||
action: "created",
|
||||
message: "created successfully",
|
||||
},
|
||||
{
|
||||
row: 3,
|
||||
name: "Child B",
|
||||
slug: "child-b",
|
||||
success: true,
|
||||
action: "created",
|
||||
message: "created successfully",
|
||||
},
|
||||
],
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user