From f1feb3bf946af5ecd7c85b99aab1f332cd22f193 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Sun, 16 Jan 2022 21:59:54 +0100 Subject: [PATCH] refactor(note-metadata): rename date attributes This is part of an effort to name all date attributes consistently. Signed-off-by: David Mehren --- src/notes/note-metadata.dto.ts | 4 ++-- src/notes/notes.service.spec.ts | 8 ++++---- src/notes/notes.service.ts | 4 ++-- test/public-api/notes.e2e-spec.ts | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/notes/note-metadata.dto.ts b/src/notes/note-metadata.dto.ts index 137e92ce2..e41433720 100644 --- a/src/notes/note-metadata.dto.ts +++ b/src/notes/note-metadata.dto.ts @@ -72,7 +72,7 @@ export class NoteMetadataDto { */ @IsDate() @ApiProperty() - updateTime: Date; + updatedAt: Date; /** * User that last edited the note @@ -96,7 +96,7 @@ export class NoteMetadataDto { */ @IsDate() @ApiProperty() - createTime: Date; + createdAt: Date; /** * List of usernames that edited the note diff --git a/src/notes/notes.service.spec.ts b/src/notes/notes.service.spec.ts index 76ec8e1bc..8ebd3f04d 100644 --- a/src/notes/notes.service.spec.ts +++ b/src/notes/notes.service.spec.ts @@ -773,7 +773,7 @@ describe('NotesService', () => { expect(metadataDto.aliases).toHaveLength(1); expect(metadataDto.aliases[0]).toEqual((await note.aliases)[0].name); expect(metadataDto.title).toEqual(note.title); - expect(metadataDto.createTime).toEqual(revisions[0].createdAt); + expect(metadataDto.createdAt).toEqual(revisions[0].createdAt); expect(metadataDto.description).toEqual(note.description); expect(metadataDto.editedBy).toHaveLength(1); expect(metadataDto.editedBy[0]).toEqual(user.username); @@ -790,7 +790,7 @@ describe('NotesService', () => { expect(metadataDto.permissions.sharedToGroups[0].canEdit).toEqual(true); expect(metadataDto.tags).toHaveLength(1); expect(metadataDto.tags[0]).toEqual((await note.tags)[0].name); - expect(metadataDto.updateTime).toEqual(revisions[0].createdAt); + expect(metadataDto.updatedAt).toEqual(revisions[0].createdAt); expect(metadataDto.updateUser.username).toEqual(user.username); expect(metadataDto.viewCount).toEqual(note.viewCount); }); @@ -875,7 +875,7 @@ describe('NotesService', () => { expect(noteDto.metadata.aliases).toHaveLength(1); expect(noteDto.metadata.aliases[0]).toEqual((await note.aliases)[0].name); expect(noteDto.metadata.title).toEqual(note.title); - expect(noteDto.metadata.createTime).toEqual(revisions[0].createdAt); + expect(noteDto.metadata.createdAt).toEqual(revisions[0].createdAt); expect(noteDto.metadata.description).toEqual(note.description); expect(noteDto.metadata.editedBy).toHaveLength(1); expect(noteDto.metadata.editedBy[0]).toEqual(user.username); @@ -898,7 +898,7 @@ describe('NotesService', () => { ); expect(noteDto.metadata.tags).toHaveLength(1); expect(noteDto.metadata.tags[0]).toEqual((await note.tags)[0].name); - expect(noteDto.metadata.updateTime).toEqual(revisions[0].createdAt); + expect(noteDto.metadata.updatedAt).toEqual(revisions[0].createdAt); expect(noteDto.metadata.updateUser.username).toEqual(user.username); expect(noteDto.metadata.viewCount).toEqual(note.viewCount); expect(noteDto.content).toEqual(content); diff --git a/src/notes/notes.service.ts b/src/notes/notes.service.ts index 0eee31428..c66d6102e 100644 --- a/src/notes/notes.service.ts +++ b/src/notes/notes.service.ts @@ -400,12 +400,12 @@ export class NotesService { ), primaryAlias: (await getPrimaryAlias(note)) ?? null, title: note.title ?? '', - createTime: (await this.getFirstRevision(note)).createdAt, + createdAt: (await this.getFirstRevision(note)).createdAt, description: note.description ?? '', editedBy: (await this.getAuthorUsers(note)).map((user) => user.username), permissions: await this.toNotePermissionsDto(note), tags: await this.toTagList(note), - updateTime: (await this.getLatestRevision(note)).createdAt, + updatedAt: (await this.getLatestRevision(note)).createdAt, updateUser: updateUser ? this.usersService.toUserDto(updateUser) : null, viewCount: note.viewCount, }; diff --git a/test/public-api/notes.e2e-spec.ts b/test/public-api/notes.e2e-spec.ts index d5dd441bc..a120ee8c3 100644 --- a/test/public-api/notes.e2e-spec.ts +++ b/test/public-api/notes.e2e-spec.ts @@ -274,13 +274,13 @@ describe('Notes', () => { expect(metadata.body.primaryAlias).toEqual('test5'); expect(metadata.body.title).toEqual(''); expect(metadata.body.description).toEqual(''); - expect(typeof metadata.body.createTime).toEqual('string'); + expect(typeof metadata.body.createdAt).toEqual('string'); expect(metadata.body.editedBy).toEqual([]); expect(metadata.body.permissions.owner.username).toEqual('hardcoded'); expect(metadata.body.permissions.sharedToUsers).toEqual([]); expect(metadata.body.permissions.sharedToUsers).toEqual([]); expect(metadata.body.tags).toEqual([]); - expect(typeof metadata.body.updateTime).toEqual('string'); + expect(typeof metadata.body.updatedAt).toEqual('string'); expect(typeof metadata.body.updateUser.displayName).toEqual('string'); expect(typeof metadata.body.updateUser.username).toEqual('string'); expect(typeof metadata.body.updateUser.email).toEqual('string'); @@ -320,7 +320,7 @@ describe('Notes', () => { const metadata = await request(testSetup.app.getHttpServer()) .get('/api/v2/notes/test5a/metadata') .expect(200); - expect(metadata.body.createTime).toEqual(createDate.toISOString()); + expect(metadata.body.createdAt).toEqual(createDate.toISOString()); expect(metadata.body.updateTime).not.toEqual(createDate.toISOString()); }); });