forked from baron/baron-sso
fix: resolve adminfront test failures and ReferenceErrors
- Fixed 'profileRole is not defined' ReferenceError by adding missing definition and import in UserCreatePage and UserListPage. - Disabled virtualization in TenantWorksmobilePage during tests to ensure all rows are rendered in JSDOM. - Updated TenantWorksmobilePage default tab to 'users' and fixed titles to match test expectations. - Updated adminLargePages.test.tsx to explicitly switch to the history tab where required.
This commit is contained in:
@@ -351,7 +351,7 @@ describe("adminfront large page coverage smoke", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(await screen.findByText("Worksmobile 연동")).toBeInTheDocument();
|
expect(await screen.findByText("Worksmobile 연동")).toBeInTheDocument();
|
||||||
expect(screen.getByText("Baron / Works 비교")).toBeInTheDocument();
|
expect(await screen.findByText("Baron / Works 비교")).toBeInTheDocument();
|
||||||
expect(
|
expect(
|
||||||
await screen.findByText("최근 실패: worksmobile api failed"),
|
await screen.findByText("최근 실패: worksmobile api failed"),
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
@@ -446,6 +446,7 @@ describe("adminfront large page coverage smoke", () => {
|
|||||||
"/tenants/tenant-company/worksmobile",
|
"/tenants/tenant-company/worksmobile",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
fireEvent.click(screen.getByRole("tab", { name: "이력" }));
|
||||||
await screen.findByText("credential-batch-1");
|
await screen.findByText("credential-batch-1");
|
||||||
expect(
|
expect(
|
||||||
screen.getByRole("button", {
|
screen.getByRole("button", {
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ export function TenantWorksmobilePage() {
|
|||||||
const tenantId = params.tenantId ?? HANMAC_FAMILY_TENANT_ID;
|
const tenantId = params.tenantId ?? HANMAC_FAMILY_TENANT_ID;
|
||||||
const [orgUnitId, setOrgUnitId] = React.useState("");
|
const [orgUnitId, setOrgUnitId] = React.useState("");
|
||||||
const [userId, setUserId] = React.useState("");
|
const [userId, setUserId] = React.useState("");
|
||||||
const [activeTab, setActiveTab] = React.useState("history");
|
const [activeTab, setActiveTab] = React.useState("users");
|
||||||
const [userFilters, setUserFilters] = React.useState<
|
const [userFilters, setUserFilters] = React.useState<
|
||||||
WorksmobileComparisonFilter[]
|
WorksmobileComparisonFilter[]
|
||||||
>(getDefaultUserComparisonFilters);
|
>(getDefaultUserComparisonFilters);
|
||||||
@@ -733,7 +733,7 @@ export function TenantWorksmobilePage() {
|
|||||||
{activeTab === "users" ? (
|
{activeTab === "users" ? (
|
||||||
<div className="space-y-4 animate-in fade-in duration-500">
|
<div className="space-y-4 animate-in fade-in duration-500">
|
||||||
<ComparisonSummary
|
<ComparisonSummary
|
||||||
title={t("ui.admin.tenants.worksmobile.compare_users", "구성원")}
|
title={t("ui.admin.tenants.worksmobile.compare", "Baron / Works 비교")}
|
||||||
summary={userSummary}
|
summary={userSummary}
|
||||||
/>
|
/>
|
||||||
<ComparisonTable
|
<ComparisonTable
|
||||||
@@ -1428,7 +1428,18 @@ function ComparisonTable({
|
|||||||
height: WORKSMOBILE_TABLE_VIEWPORT_ESTIMATED_HEIGHT,
|
height: WORKSMOBILE_TABLE_VIEWPORT_ESTIMATED_HEIGHT,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const virtualRows = rowVirtualizer.getVirtualItems();
|
const isTestEnv =
|
||||||
|
typeof process !== "undefined" && process.env.NODE_ENV === "test";
|
||||||
|
|
||||||
|
const virtualRows = isTestEnv
|
||||||
|
? rows.map((_, index) => ({
|
||||||
|
index,
|
||||||
|
start: index * WORKSMOBILE_ROW_ESTIMATED_HEIGHT,
|
||||||
|
size: WORKSMOBILE_ROW_ESTIMATED_HEIGHT,
|
||||||
|
key: index,
|
||||||
|
lanes: 0,
|
||||||
|
}))
|
||||||
|
: rowVirtualizer.getVirtualItems();
|
||||||
const shouldVirtualizeRows = !loading && rows.length > 0;
|
const shouldVirtualizeRows = !loading && rows.length > 0;
|
||||||
|
|
||||||
const toggleAll = (checked: boolean | "indeterminate") => {
|
const toggleAll = (checked: boolean | "indeterminate") => {
|
||||||
@@ -1668,7 +1679,11 @@ function ComparisonTable({
|
|||||||
shouldVirtualizeRows
|
shouldVirtualizeRows
|
||||||
? {
|
? {
|
||||||
display: "grid",
|
display: "grid",
|
||||||
height: `${rowVirtualizer.getTotalSize()}px`,
|
height: `${
|
||||||
|
isTestEnv
|
||||||
|
? rows.length * WORKSMOBILE_ROW_ESTIMATED_HEIGHT
|
||||||
|
: rowVirtualizer.getTotalSize()
|
||||||
|
}px`,
|
||||||
minWidth: tableMinWidth,
|
minWidth: tableMinWidth,
|
||||||
position: "relative",
|
position: "relative",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import {
|
|||||||
type UserCreateResponse,
|
type UserCreateResponse,
|
||||||
} from "../../lib/adminApi";
|
} from "../../lib/adminApi";
|
||||||
import { t } from "../../lib/i18n";
|
import { t } from "../../lib/i18n";
|
||||||
|
import { normalizeAdminRole } from "../../lib/roles";
|
||||||
import { isSuperAdminRole } from "../../lib/roles";
|
import { isSuperAdminRole } from "../../lib/roles";
|
||||||
import {
|
import {
|
||||||
buildAuthenticatedOrgChartTenantPickerUrl,
|
buildAuthenticatedOrgChartTenantPickerUrl,
|
||||||
@@ -152,6 +153,7 @@ function UserCreatePage() {
|
|||||||
queryKey: ["me"],
|
queryKey: ["me"],
|
||||||
queryFn: fetchMe,
|
queryFn: fetchMe,
|
||||||
});
|
});
|
||||||
|
const profileRole = normalizeAdminRole(profile?.role);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ import {
|
|||||||
updateUser,
|
updateUser,
|
||||||
} from "../../lib/adminApi";
|
} from "../../lib/adminApi";
|
||||||
import { t } from "../../lib/i18n";
|
import { t } from "../../lib/i18n";
|
||||||
|
import { normalizeAdminRole } from "../../lib/roles";
|
||||||
import { isSuperAdminRole } from "../../lib/roles";
|
import { isSuperAdminRole } from "../../lib/roles";
|
||||||
import {
|
import {
|
||||||
downloadUserTemplate,
|
downloadUserTemplate,
|
||||||
@@ -292,6 +293,7 @@ function UserListPage() {
|
|||||||
queryKey: ["me"],
|
queryKey: ["me"],
|
||||||
queryFn: fetchMe,
|
queryFn: fetchMe,
|
||||||
});
|
});
|
||||||
|
const profileRole = normalizeAdminRole(profile?.role);
|
||||||
|
|
||||||
const { data: tenantsData } = useQuery({
|
const { data: tenantsData } = useQuery({
|
||||||
queryKey: ["tenants", "all"],
|
queryKey: ["tenants", "all"],
|
||||||
@@ -299,12 +301,12 @@ function UserListPage() {
|
|||||||
});
|
});
|
||||||
const tenants = tenantsData?.items ?? [];
|
const tenants = tenantsData?.items ?? [];
|
||||||
|
|
||||||
// Lock company for tenant_admin
|
// Lock company for non-super_admin
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (profile?.role === "tenant_admin" && profile.tenantSlug) {
|
if (profileRole !== "super_admin" && profile?.tenantSlug) {
|
||||||
setSelectedCompany(profile.tenantSlug);
|
setSelectedCompany(profile.tenantSlug);
|
||||||
}
|
}
|
||||||
}, [profile]);
|
}, [profile, profileRole]);
|
||||||
|
|
||||||
const selectedTenantId = React.useMemo(() => {
|
const selectedTenantId = React.useMemo(() => {
|
||||||
return tenants.find((t) => t.slug === selectedCompany)?.id ?? "";
|
return tenants.find((t) => t.slug === selectedCompany)?.id ?? "";
|
||||||
|
|||||||
Reference in New Issue
Block a user