mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-12-23 18:42:30 +00:00
PublicNotesE2E: Add extra test for note deletion
This test checks if permission are correctly set and no error is thrown if the note is deleted. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
cbf0ce98dd
commit
5c138e4115
1 changed files with 26 additions and 0 deletions
|
@ -26,6 +26,7 @@ import { User } from '../../src/users/user.entity';
|
|||
import { UsersModule } from '../../src/users/users.module';
|
||||
import { promises as fs } from 'fs';
|
||||
import { MediaService } from '../../src/media/media.service';
|
||||
import { NotePermissionsUpdateDto } from '../../src/notes/note-permissions.dto';
|
||||
import { join } from 'path';
|
||||
|
||||
describe('Notes', () => {
|
||||
|
@ -155,6 +156,31 @@ describe('Notes', () => {
|
|||
new NotInDBError("Note with id/alias 'test3' not found."),
|
||||
);
|
||||
});
|
||||
it('works with an existing alias with permissions', async () => {
|
||||
const note = await notesService.createNote(content, 'test3', user);
|
||||
const updateNotePermission = new NotePermissionsUpdateDto();
|
||||
updateNotePermission.sharedToUsers = [
|
||||
{
|
||||
username: user.userName,
|
||||
canEdit: true,
|
||||
},
|
||||
];
|
||||
updateNotePermission.sharedToGroups = [];
|
||||
await notesService.updateNotePermissions(note, updateNotePermission);
|
||||
const updatedNote = await notesService.getNoteByIdOrAlias(note.alias);
|
||||
expect(updatedNote.userPermissions).toHaveLength(1);
|
||||
expect(updatedNote.userPermissions[0].canEdit).toEqual(
|
||||
updateNotePermission.sharedToUsers[0].canEdit,
|
||||
);
|
||||
expect(updatedNote.userPermissions[0].user.userName).toEqual(
|
||||
user.userName,
|
||||
);
|
||||
expect(updatedNote.groupPermissions).toHaveLength(0);
|
||||
await request(app.getHttpServer()).delete('/notes/test3').expect(204);
|
||||
await expect(notesService.getNoteByIdOrAlias('test3')).rejects.toEqual(
|
||||
new NotInDBError("Note with id/alias 'test3' not found."),
|
||||
);
|
||||
});
|
||||
it('fails with a forbidden alias', async () => {
|
||||
await request(app.getHttpServer())
|
||||
.delete(`/notes/${forbiddenNoteId}`)
|
||||
|
|
Loading…
Reference in a new issue