Skip to content

Commit 9e4205f

Browse files
committed
Fix mock so usercan doesn't error in db tests
1 parent c53c390 commit 9e4205f

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

core/app/components/pubs/PubEditor/actions.db.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe("createPubRecursive", () => {
7373
},
7474
});
7575
getLoginData.mockImplementation(() => {
76-
return { user: loginUser ? { id: users.john.id } : undefined };
76+
return { user: loginUser ? { id: users.john.id, isSuperAdmin: false } : null };
7777
});
7878

7979
const { createPubRecursive } = await import("./actions");
@@ -162,7 +162,7 @@ describe("updatePub", () => {
162162
},
163163
});
164164
getLoginData.mockImplementation(() => {
165-
return { user: loginUser ? { id: users.john.id } : undefined };
165+
return { user: loginUser ? { id: users.john.id, isSuperAdmin: false } : null };
166166
});
167167
findCommunityBySlug.mockImplementation(() => {
168168
return community;

core/lib/__tests__/live.db.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ describe("live", () => {
122122
const { community, users, pubs } = await seed(trx);
123123

124124
getLoginData.mockImplementation(() => {
125-
return undefined;
125+
return { user: null };
126126
});
127127

128128
const createForm = await import("~/app/c/[communitySlug]/forms/actions").then(
@@ -143,7 +143,7 @@ describe("live", () => {
143143
test("getForm and createForm", async () => {
144144
const trx = getTrx();
145145
getLoginData.mockImplementation(() => {
146-
return { id: "123", isSuperAdmin: true };
146+
return { user: { id: "123", isSuperAdmin: true } };
147147
});
148148

149149
const { community, users, pubs } = await seed(trx);

core/lib/__tests__/utils.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export const mockServerCode = async () => {
1212

1313
return {
1414
testDb,
15-
getLoginData: vi.fn(),
15+
getLoginData: vi.fn((): { user: { isSuperAdmin: boolean } | null } => ({
16+
user: { isSuperAdmin: false },
17+
})),
1618
findCommunityBySlug: vi.fn(),
1719
};
1820
});

0 commit comments

Comments
 (0)