From 0abcba052c5dac76ba7b5440e2941c4c24789006 Mon Sep 17 00:00:00 2001 From: "Fabien \"egg\" O'Carroll" Date: Fri, 12 May 2023 08:13:51 -0400 Subject: [PATCH] Used static created_at_ts to avoid flaky tests closes https://github.com/TryGhost/Team/issues/3184 --- ghost/post-revisions/test/PostRevisions.test.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ghost/post-revisions/test/PostRevisions.test.ts b/ghost/post-revisions/test/PostRevisions.test.ts index b02d754dfc..9cebe3d96f 100644 --- a/ghost/post-revisions/test/PostRevisions.test.ts +++ b/ghost/post-revisions/test/PostRevisions.test.ts @@ -25,7 +25,7 @@ function makePostLike(data: any = {}) { function makeRevision(data: any = {}) { return Object.assign({ post_id: 'fakeid', - created_at_ts: Date.now(), + created_at_ts: data.created_at_ts || Date.now(), lexical: 'blah', html: 'blah', author_id: 'fakeauthorid', @@ -181,13 +181,16 @@ describe('PostRevisions', function () { describe('getRevisions', function () { it('returns the original revisions if there is no previous', async function () { const postRevisions = new PostRevisions({config, model: {}}); + const now = Date.now(); const expected = [{ - lexical: 'blah' + lexical: 'blah', + created_at_ts: now }].map(makeRevision); const actual = await postRevisions.getRevisions(makePostLike({}), [{ - lexical: 'blah' + lexical: 'blah', + created_at_ts: now }].map(makeRevision)); assert.deepEqual(actual, expected); @@ -195,16 +198,19 @@ describe('PostRevisions', function () { it('returns the original revisions if the current and previous', async function () { const postRevisions = new PostRevisions({config, model: {}}); + const now = Date.now(); const expected = [{ - lexical: 'revision' + lexical: 'revision', + created_at_ts: now }].map(makeRevision); const actual = await postRevisions.getRevisions(makePostLike({ lexical: 'blah', html: 'blah' }), [{ - lexical: 'revision' + lexical: 'revision', + created_at_ts: now }].map(makeRevision)); assert.deepEqual(actual, expected);