refactor(note): lazy-load relations

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-11-30 16:46:07 +01:00
parent d761ff7f4f
commit 235e4f647c
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
23 changed files with 343 additions and 284 deletions

View file

@ -200,16 +200,16 @@ describe('Notes', () => {
updateNotePermission,
);
const updatedNote = await testSetup.notesService.getNoteByIdOrAlias(
note.aliases.filter((alias) => alias.primary)[0].name,
(await note.aliases).filter((alias) => alias.primary)[0].name,
);
expect(updatedNote.userPermissions).toHaveLength(1);
expect(updatedNote.userPermissions[0].canEdit).toEqual(
expect(await updatedNote.userPermissions).toHaveLength(1);
expect((await updatedNote.userPermissions)[0].canEdit).toEqual(
updateNotePermission.sharedToUsers[0].canEdit,
);
expect(updatedNote.userPermissions[0].user.username).toEqual(
expect((await updatedNote.userPermissions)[0].user.username).toEqual(
user.username,
);
expect(updatedNote.groupPermissions).toHaveLength(0);
expect(await updatedNote.groupPermissions).toHaveLength(0);
await request(testSetup.app.getHttpServer())
.delete('/api/v2/notes/test3')
.expect(204);