Skip to content

Commit 154f474

Browse files
committed
update test
1 parent 50b01fe commit 154f474

File tree

2 files changed

+43
-53
lines changed

2 files changed

+43
-53
lines changed

tests/regression/tests/issue-2104.test.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { loadSchema } from '@zenstackhq/testtools';
2+
3+
describe('issue 2117', () => {
4+
it('regression', async () => {
5+
const { prisma, enhanceRaw, prismaModule } = await loadSchema(
6+
`
7+
model User {
8+
uuid String @id
9+
email String @unique @deny('read', auth().uuid != this.uuid)
10+
username String @unique
11+
@@allow('all', true)
12+
}
13+
`
14+
);
15+
16+
const extPrisma = prisma.$extends(
17+
prismaModule.defineExtension({
18+
name: 'urls-extension',
19+
result: {
20+
user: {
21+
pageUrl: {
22+
needs: { username: true },
23+
compute: () => `foo`,
24+
},
25+
},
26+
},
27+
})
28+
);
29+
30+
const db = enhanceRaw(extPrisma, { user: { uuid: '1' } }, { logPrismaQuery: true });
31+
await db.user.create({ data: { uuid: '1', email: 'a@b.com', username: 'a' } });
32+
await expect(db.user.findFirst()).resolves.toMatchObject({
33+
uuid: '1',
34+
email: 'a@b.com',
35+
username: 'a',
36+
pageUrl: 'foo',
37+
});
38+
const r = await db.user.findFirst({ select: { email: true } });
39+
expect(r.email).toBeTruthy();
40+
expect(r.uuid).toBeUndefined();
41+
expect(r.pageUrl).toBeUndefined();
42+
});
43+
});

0 commit comments

Comments
 (0)