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(screen.getByText("Baron / Works 비교")).toBeInTheDocument();
|
||||
expect(await screen.findByText("Baron / Works 비교")).toBeInTheDocument();
|
||||
expect(
|
||||
await screen.findByText("최근 실패: worksmobile api failed"),
|
||||
).toBeInTheDocument();
|
||||
@@ -446,6 +446,7 @@ describe("adminfront large page coverage smoke", () => {
|
||||
"/tenants/tenant-company/worksmobile",
|
||||
);
|
||||
|
||||
fireEvent.click(screen.getByRole("tab", { name: "이력" }));
|
||||
await screen.findByText("credential-batch-1");
|
||||
expect(
|
||||
screen.getByRole("button", {
|
||||
|
||||
@@ -194,7 +194,7 @@ export function TenantWorksmobilePage() {
|
||||
const tenantId = params.tenantId ?? HANMAC_FAMILY_TENANT_ID;
|
||||
const [orgUnitId, setOrgUnitId] = React.useState("");
|
||||
const [userId, setUserId] = React.useState("");
|
||||
const [activeTab, setActiveTab] = React.useState("history");
|
||||
const [activeTab, setActiveTab] = React.useState("users");
|
||||
const [userFilters, setUserFilters] = React.useState<
|
||||
WorksmobileComparisonFilter[]
|
||||
>(getDefaultUserComparisonFilters);
|
||||
@@ -733,7 +733,7 @@ export function TenantWorksmobilePage() {
|
||||
{activeTab === "users" ? (
|
||||
<div className="space-y-4 animate-in fade-in duration-500">
|
||||
<ComparisonSummary
|
||||
title={t("ui.admin.tenants.worksmobile.compare_users", "구성원")}
|
||||
title={t("ui.admin.tenants.worksmobile.compare", "Baron / Works 비교")}
|
||||
summary={userSummary}
|
||||
/>
|
||||
<ComparisonTable
|
||||
@@ -1428,7 +1428,18 @@ function ComparisonTable({
|
||||
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 toggleAll = (checked: boolean | "indeterminate") => {
|
||||
@@ -1668,7 +1679,11 @@ function ComparisonTable({
|
||||
shouldVirtualizeRows
|
||||
? {
|
||||
display: "grid",
|
||||
height: `${rowVirtualizer.getTotalSize()}px`,
|
||||
height: `${
|
||||
isTestEnv
|
||||
? rows.length * WORKSMOBILE_ROW_ESTIMATED_HEIGHT
|
||||
: rowVirtualizer.getTotalSize()
|
||||
}px`,
|
||||
minWidth: tableMinWidth,
|
||||
position: "relative",
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ import {
|
||||
type UserCreateResponse,
|
||||
} from "../../lib/adminApi";
|
||||
import { t } from "../../lib/i18n";
|
||||
import { normalizeAdminRole } from "../../lib/roles";
|
||||
import { isSuperAdminRole } from "../../lib/roles";
|
||||
import {
|
||||
buildAuthenticatedOrgChartTenantPickerUrl,
|
||||
@@ -152,6 +153,7 @@ function UserCreatePage() {
|
||||
queryKey: ["me"],
|
||||
queryFn: fetchMe,
|
||||
});
|
||||
const profileRole = normalizeAdminRole(profile?.role);
|
||||
|
||||
const {
|
||||
register,
|
||||
|
||||
@@ -98,6 +98,7 @@ import {
|
||||
updateUser,
|
||||
} from "../../lib/adminApi";
|
||||
import { t } from "../../lib/i18n";
|
||||
import { normalizeAdminRole } from "../../lib/roles";
|
||||
import { isSuperAdminRole } from "../../lib/roles";
|
||||
import {
|
||||
downloadUserTemplate,
|
||||
@@ -292,6 +293,7 @@ function UserListPage() {
|
||||
queryKey: ["me"],
|
||||
queryFn: fetchMe,
|
||||
});
|
||||
const profileRole = normalizeAdminRole(profile?.role);
|
||||
|
||||
const { data: tenantsData } = useQuery({
|
||||
queryKey: ["tenants", "all"],
|
||||
@@ -299,12 +301,12 @@ function UserListPage() {
|
||||
});
|
||||
const tenants = tenantsData?.items ?? [];
|
||||
|
||||
// Lock company for tenant_admin
|
||||
// Lock company for non-super_admin
|
||||
React.useEffect(() => {
|
||||
if (profile?.role === "tenant_admin" && profile.tenantSlug) {
|
||||
if (profileRole !== "super_admin" && profile?.tenantSlug) {
|
||||
setSelectedCompany(profile.tenantSlug);
|
||||
}
|
||||
}, [profile]);
|
||||
}, [profile, profileRole]);
|
||||
|
||||
const selectedTenantId = React.useMemo(() => {
|
||||
return tenants.find((t) => t.slug === selectedCompany)?.id ?? "";
|
||||
|
||||
Reference in New Issue
Block a user