Skip to content

Commit d8d8b54

Browse files
committed
🧪 test: adjust tests
1 parent 795578d commit d8d8b54

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

‎test/src/abilities.test.ts‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ describe("test rumble abilities", async () => {
115115
).toEqual(10);
116116
});
117117

118-
test("deny indirect read with helper implementation on one to one", async () => {
118+
test("error indirect read with helper implementation on one to one with error on non nullable relationship", async () => {
119119
rumble.abilityBuilder.comments.allow(["read"]);
120120

121121
const { executor, yogaInstance } = build();
@@ -140,6 +140,26 @@ describe("test rumble abilities", async () => {
140140
]);
141141
});
142142

143+
test("deny indirect read with helper implementation on one to one with error on nullable relationship", async () => {
144+
rumble.abilityBuilder.comments.allow(["read"]);
145+
146+
const { executor, yogaInstance } = build();
147+
const r = await executor({
148+
document: parse(/* GraphQL */ `
149+
query {
150+
findManyComments {
151+
id
152+
post {
153+
id
154+
}
155+
}
156+
}
157+
`),
158+
});
159+
160+
expect((r as any).data.findManyComments.length).toEqual(10);
161+
});
162+
143163
test("allow indirect read with helper implementation on one to one", async () => {
144164
rumble.abilityBuilder.comments.allow(["read"]);
145165
rumble.abilityBuilder.users.allow(["read"]);

‎test/src/db/schema.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ export const comments = table("comments", {
3737
postId: t.text("post_id").references(() => posts.id, {
3838
onDelete: "cascade",
3939
}),
40-
ownerId: t.text("owner_id").references(() => users.id, {
41-
onDelete: "cascade",
42-
}),
40+
ownerId: t
41+
.text("owner_id")
42+
.notNull()
43+
.references(() => users.id, {
44+
onDelete: "cascade",
45+
}),
4346
});
4447

4548
export const usersRelations = relations(users, ({ one, many }) => ({

0 commit comments

Comments
 (0)