Skip to content

Commit 1d4431c

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

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const mockServerCode = async () => {
1212

1313
return {
1414
testDb,
15-
getLoginData: vi.fn(),
15+
getLoginData: vi.fn(() => ({ user: { isSuperAdmin: false } })),
1616
findCommunityBySlug: vi.fn(),
1717
};
1818
});

0 commit comments

Comments
 (0)