Skip to content

Commit efcb89a

Browse files
authored
fix(webapp): add hasAdminDisplayAccess to the env param test mock (#4430)
`test/envParamRoute.ownership.test.ts` fails on main: 3 of its 4 tests throw ``` Error: [vitest] No "hasAdminDisplayAccess" export is defined on the "~/services/session.server" mock. Did you forget to return it from "vi.mock"? ``` #4421 added a `hasAdminDisplayAccess(user)` call to the `env.$envParam` loader, and the test's `vi.mock` of `session.server` only returns `requireUser`, so the call blows up. Both changes were green in their own PR and only conflict once merged together, which is why nobody caught it. The mock now mirrors the real implementation rather than returning a constant, so it stays correct if the test's user fixture is ever varied. No assertions were changed: the tests were right, the mock was stale. Worth flagging separately: no workflow runs on push to main, so this has been red since #4421 landed without showing up anywhere. Every PR opened since has inherited the failure.
1 parent debfa2b commit efcb89a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

apps/webapp/test/envParamRoute.ownership.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ vi.mock("~/db.server", () => ({
1717

1818
vi.mock("~/services/session.server", () => ({
1919
requireUser: async () => mocks.user,
20+
hasAdminDisplayAccess: (user: {
21+
admin: boolean;
22+
isImpersonating: boolean;
23+
isViewingAsUser?: boolean;
24+
}) => (user.admin || user.isImpersonating) && !user.isViewingAsUser,
2025
}));
2126

2227
vi.mock("~/services/dashboardPreferences.server", () => ({

0 commit comments

Comments
 (0)