From b146588301769cd0dcf664afd00b33cb61491d06 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Sat, 20 Oct 2018 19:32:09 +0200 Subject: [PATCH] Fixed the tests for the comments service. --- .../Api/Controllers/Comments/CommentsController.cs | 5 +++-- src/Squidex/app/shared/internal.ts | 1 + .../app/shared/services/comments.service.spec.ts | 10 +++++----- src/Squidex/app/shared/services/comments.service.ts | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Squidex/Areas/Api/Controllers/Comments/CommentsController.cs b/src/Squidex/Areas/Api/Controllers/Comments/CommentsController.cs index 455a96f48..dafcf2f8f 100644 --- a/src/Squidex/Areas/Api/Controllers/Comments/CommentsController.cs +++ b/src/Squidex/Areas/Api/Controllers/Comments/CommentsController.cs @@ -12,6 +12,7 @@ using Orleans; using Squidex.Areas.Api.Controllers.Comments.Models; using Squidex.Domain.Apps.Entities.Comments; using Squidex.Domain.Apps.Entities.Comments.Commands; +using Squidex.Infrastructure; using Squidex.Infrastructure.Commands; using Squidex.Pipeline; @@ -45,9 +46,9 @@ namespace Squidex.Areas.Api.Controllers.Comments [ApiCosts(0)] public async Task GetComments(Guid commentsId) { - if (!int.TryParse(Request.Headers["X-Since"], out var version)) + if (!long.TryParse(Request.Headers["X-Since"], out var version)) { - version = -1; + version = EtagVersion.Any; } var result = await grainFactory.GetGrain(commentsId).GetCommentsAsync(version); diff --git a/src/Squidex/app/shared/internal.ts b/src/Squidex/app/shared/internal.ts index 562a4393d..db93f8ce4 100644 --- a/src/Squidex/app/shared/internal.ts +++ b/src/Squidex/app/shared/internal.ts @@ -27,6 +27,7 @@ export * from './services/apps.service'; export * from './services/assets.service'; export * from './services/auth.service'; export * from './services/backups.service'; +export * from './services/comments.service'; export * from './services/contents.service'; export * from './services/graphql.service'; export * from './services/help.service'; diff --git a/src/Squidex/app/shared/services/comments.service.spec.ts b/src/Squidex/app/shared/services/comments.service.spec.ts index ec73049b7..f913643a8 100644 --- a/src/Squidex/app/shared/services/comments.service.spec.ts +++ b/src/Squidex/app/shared/services/comments.service.spec.ts @@ -71,7 +71,7 @@ describe('CommentsService', () => { expect(comments!).toEqual( new CommentsDto( [ - new CommentDto('123', DateTime.parseISO_UTC('2016-12-12T10:10'), 'text1', user) + new CommentDto('123', DateTime.parseISO_UTC('2016-10-12T10:10'), 'text1', user) ], [ new CommentDto('456', DateTime.parseISO_UTC('2017-11-12T12:12'), 'text2', user) ], [ @@ -96,13 +96,13 @@ describe('CommentsService', () => { expect(req.request.headers.get('If-Match')).toBeNull(); req.flush({ - id: '456', - text: 'text2', - time: '2017-11-12T12:12', + id: '123', + text: 'text1', + time: '2016-10-12T10:10', user: user }); - expect(comment!).toEqual(new CommentDto('123', DateTime.parseISO_UTC('2016-12-12T10:10'), 'text1', user)); + expect(comment!).toEqual(new CommentDto('123', DateTime.parseISO_UTC('2016-10-12T10:10'), 'text1', user)); })); it('should make put request to replace comment content', diff --git a/src/Squidex/app/shared/services/comments.service.ts b/src/Squidex/app/shared/services/comments.service.ts index e7cd3915a..2b625ad98 100644 --- a/src/Squidex/app/shared/services/comments.service.ts +++ b/src/Squidex/app/shared/services/comments.service.ts @@ -58,7 +58,7 @@ export class CommentsService { public getComments(commentsId: string, version: Version): Observable { const url = this.apiUrl.buildUrl(`api/comments/${commentsId}`); - return this.http.get(url, { headers: { 'Since': version.value } }).pipe( + return this.http.get(url, { headers: { 'X-Since': version.value } }).pipe( map(response => { const body: any = response;