Note E2E tests: Check that create & update dates are updated correctly

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-01-10 20:12:21 +01:00
parent 88c0794724
commit c4b61ae580
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

View file

@ -120,7 +120,8 @@ describe('Notes', () => {
.expect(404);
});
it(`GET /notes/{note}/metadata`, async () => {
describe('GET /notes/{note}/metadata', () => {
it(`returns complete metadata object`, async () => {
await notesService.createNote('This is a test note.', 'test6');
const metadata = await request(app.getHttpServer())
.get('/notes/test6/metadata')
@ -150,6 +151,26 @@ describe('Notes', () => {
.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 () => {
await notesService.createNote('This is a test note.', 'test7');
const response = await request(app.getHttpServer())