Browse Source

Fixed the tests for the comments service.

pull/329/head
Sebastian Stehle 7 years ago
parent
commit
b146588301
  1. 5
      src/Squidex/Areas/Api/Controllers/Comments/CommentsController.cs
  2. 1
      src/Squidex/app/shared/internal.ts
  3. 10
      src/Squidex/app/shared/services/comments.service.spec.ts
  4. 2
      src/Squidex/app/shared/services/comments.service.ts

5
src/Squidex/Areas/Api/Controllers/Comments/CommentsController.cs

@ -12,6 +12,7 @@ using Orleans;
using Squidex.Areas.Api.Controllers.Comments.Models; using Squidex.Areas.Api.Controllers.Comments.Models;
using Squidex.Domain.Apps.Entities.Comments; using Squidex.Domain.Apps.Entities.Comments;
using Squidex.Domain.Apps.Entities.Comments.Commands; using Squidex.Domain.Apps.Entities.Comments.Commands;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Pipeline; using Squidex.Pipeline;
@ -45,9 +46,9 @@ namespace Squidex.Areas.Api.Controllers.Comments
[ApiCosts(0)] [ApiCosts(0)]
public async Task<IActionResult> GetComments(Guid commentsId) public async Task<IActionResult> 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<ICommentGrain>(commentsId).GetCommentsAsync(version); var result = await grainFactory.GetGrain<ICommentGrain>(commentsId).GetCommentsAsync(version);

1
src/Squidex/app/shared/internal.ts

@ -27,6 +27,7 @@ export * from './services/apps.service';
export * from './services/assets.service'; export * from './services/assets.service';
export * from './services/auth.service'; export * from './services/auth.service';
export * from './services/backups.service'; export * from './services/backups.service';
export * from './services/comments.service';
export * from './services/contents.service'; export * from './services/contents.service';
export * from './services/graphql.service'; export * from './services/graphql.service';
export * from './services/help.service'; export * from './services/help.service';

10
src/Squidex/app/shared/services/comments.service.spec.ts

@ -71,7 +71,7 @@ describe('CommentsService', () => {
expect(comments!).toEqual( expect(comments!).toEqual(
new CommentsDto( 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) 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(); expect(req.request.headers.get('If-Match')).toBeNull();
req.flush({ req.flush({
id: '456', id: '123',
text: 'text2', text: 'text1',
time: '2017-11-12T12:12', time: '2016-10-12T10:10',
user: user 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', it('should make put request to replace comment content',

2
src/Squidex/app/shared/services/comments.service.ts

@ -58,7 +58,7 @@ export class CommentsService {
public getComments(commentsId: string, version: Version): Observable<CommentsDto> { public getComments(commentsId: string, version: Version): Observable<CommentsDto> {
const url = this.apiUrl.buildUrl(`api/comments/${commentsId}`); 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 => { map(response => {
const body: any = response; const body: any = response;

Loading…
Cancel
Save