mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05:00
Note E2E tests: Check that create & update dates are updated correctly
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
88c0794724
commit
c4b61ae580
1 changed files with 48 additions and 27 deletions
|
@ -120,34 +120,55 @@ describe('Notes', () => {
|
||||||
.expect(404);
|
.expect(404);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`GET /notes/{note}/metadata`, async () => {
|
describe('GET /notes/{note}/metadata', () => {
|
||||||
await notesService.createNote('This is a test note.', 'test6');
|
it(`returns complete metadata object`, async () => {
|
||||||
const metadata = await request(app.getHttpServer())
|
await notesService.createNote('This is a test note.', 'test6');
|
||||||
.get('/notes/test6/metadata')
|
const metadata = await request(app.getHttpServer())
|
||||||
.expect(200);
|
.get('/notes/test6/metadata')
|
||||||
expect(typeof metadata.body.id).toEqual('string');
|
.expect(200);
|
||||||
expect(metadata.body.alias).toEqual('test6');
|
expect(typeof metadata.body.id).toEqual('string');
|
||||||
expect(metadata.body.title).toBeNull();
|
expect(metadata.body.alias).toEqual('test6');
|
||||||
expect(metadata.body.description).toBeNull();
|
expect(metadata.body.title).toBeNull();
|
||||||
expect(typeof metadata.body.createTime).toEqual('string');
|
expect(metadata.body.description).toBeNull();
|
||||||
expect(metadata.body.editedBy).toEqual([]);
|
expect(typeof metadata.body.createTime).toEqual('string');
|
||||||
expect(metadata.body.permissions.owner).toBeNull();
|
expect(metadata.body.editedBy).toEqual([]);
|
||||||
expect(metadata.body.permissions.sharedToUsers).toEqual([]);
|
expect(metadata.body.permissions.owner).toBeNull();
|
||||||
expect(metadata.body.permissions.sharedToUsers).toEqual([]);
|
expect(metadata.body.permissions.sharedToUsers).toEqual([]);
|
||||||
expect(metadata.body.tags).toEqual([]);
|
expect(metadata.body.permissions.sharedToUsers).toEqual([]);
|
||||||
expect(typeof metadata.body.updateTime).toEqual('string');
|
expect(metadata.body.tags).toEqual([]);
|
||||||
expect(typeof metadata.body.updateUser.displayName).toEqual('string');
|
expect(typeof metadata.body.updateTime).toEqual('string');
|
||||||
expect(typeof metadata.body.updateUser.userName).toEqual('string');
|
expect(typeof metadata.body.updateUser.displayName).toEqual('string');
|
||||||
expect(typeof metadata.body.updateUser.email).toEqual('string');
|
expect(typeof metadata.body.updateUser.userName).toEqual('string');
|
||||||
expect(typeof metadata.body.updateUser.photo).toEqual('string');
|
expect(typeof metadata.body.updateUser.email).toEqual('string');
|
||||||
expect(typeof metadata.body.viewCount).toEqual('number');
|
expect(typeof metadata.body.updateUser.photo).toEqual('string');
|
||||||
expect(metadata.body.editedBy).toEqual([]);
|
expect(typeof metadata.body.viewCount).toEqual('number');
|
||||||
|
expect(metadata.body.editedBy).toEqual([]);
|
||||||
|
|
||||||
// check if a missing note correctly returns 404
|
// check if a missing note correctly returns 404
|
||||||
await request(app.getHttpServer())
|
await request(app.getHttpServer())
|
||||||
.get('/notes/i_dont_exist/metadata')
|
.get('/notes/i_dont_exist/metadata')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(404);
|
.expect(404);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has the correct update/create dates', async () => {
|
||||||
|
// create a note
|
||||||
|
const note = await notesService.createNote(
|
||||||
|
'This is a test note.',
|
||||||
|
'test6a',
|
||||||
|
);
|
||||||
|
// save the creation time
|
||||||
|
const createDate = (await note.revisions)[0].createdAt;
|
||||||
|
// wait one second
|
||||||
|
await new Promise((r) => setTimeout(r, 1000));
|
||||||
|
// update the note
|
||||||
|
await notesService.updateNoteByIdOrAlias('test6a', 'More test content');
|
||||||
|
const metadata = await request(app.getHttpServer())
|
||||||
|
.get('/notes/test6a/metadata')
|
||||||
|
.expect(200);
|
||||||
|
expect(metadata.body.createTime).toEqual(createDate.toISOString());
|
||||||
|
expect(metadata.body.updateTime).not.toEqual(createDate.toISOString());
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`GET /notes/{note}/revisions`, async () => {
|
it(`GET /notes/{note}/revisions`, async () => {
|
||||||
|
|
Loading…
Reference in a new issue