From b3bf19e9e3b707eeac684972a9311b6594398fc5 Mon Sep 17 00:00:00 2001 From: Naz Date: Tue, 1 Mar 2022 18:17:13 +0700 Subject: [PATCH] Renamed e2e framework date matchers refs https://github.com/TryGhost/Ghost/commit/f48892028d451a8b3f82d0bd345ec3fa0dd269b8 refs https://github.com/TryGhost/Ghost/commit/33da5841614df2182f0a44488bae9a2ce5a55ca7 - There was another mather added recently: anyDateWithTimezoneOffset. The naming of date-related matchers was getting long and confusing. Renamed existing date matcher to better reflect what they do and they types of matches they are responsible for, following renames have been done: - anyShortDate -> anyISODate - anyDate -> anyISODateTime - anyDateWithTimezoneOffset -> anyISODateTimeWithTZ --- test/e2e-api/admin/members.test.js | 64 +++++++++---------- test/e2e-api/admin/tiers.test.js | 4 +- test/e2e-api/content/pages.test.js | 8 +-- test/e2e-api/content/posts.test.js | 8 +-- .../api/admin/authentication.test.js | 12 ++-- test/utils/e2e-framework.js | 6 +- 6 files changed, 51 insertions(+), 51 deletions(-) diff --git a/test/e2e-api/admin/members.test.js b/test/e2e-api/admin/members.test.js index 03130e563f..6b9f6072e1 100644 --- a/test/e2e-api/admin/members.test.js +++ b/test/e2e-api/admin/members.test.js @@ -1,5 +1,5 @@ const {agentProvider, mockManager, fixtureManager, matchers} = require('../../utils/e2e-framework'); -const {anyEtag, anyObjectId, anyUuid, anyDate, anyShortDate, anyString, anyArray, anyLocationFor, anyErrorId} = matchers; +const {anyEtag, anyObjectId, anyUuid, anyISODateTime, anyISODate, anyString, anyArray, anyLocationFor, anyErrorId} = matchers; const assert = require('assert'); const nock = require('nock'); @@ -24,15 +24,15 @@ async function assertEvents({eventType, eventName, quantity, asserts}) { const memberMatcherNoIncludes = { id: anyObjectId, uuid: anyUuid, - created_at: anyDate, - updated_at: anyDate + created_at: anyISODateTime, + updated_at: anyISODateTime }; const memberMatcherShallowIncludes = { id: anyObjectId, uuid: anyUuid, - created_at: anyDate, - updated_at: anyDate, + created_at: anyISODateTime, + updated_at: anyISODateTime, subscriptions: anyArray, labels: anyArray }; @@ -110,8 +110,8 @@ describe('Members API', function () { members: new Array(8).fill({ id: anyObjectId, uuid: anyUuid, - created_at: anyDate, - updated_at: anyDate, + created_at: anyISODateTime, + updated_at: anyISODateTime, labels: anyArray, subscriptions: anyArray }) @@ -129,8 +129,8 @@ describe('Members API', function () { members: new Array(1).fill({ id: anyObjectId, uuid: anyUuid, - created_at: anyDate, - updated_at: anyDate, + created_at: anyISODateTime, + updated_at: anyISODateTime, labels: anyArray, subscriptions: anyArray }) @@ -148,8 +148,8 @@ describe('Members API', function () { members: new Array(1).fill({ id: anyObjectId, uuid: anyUuid, - created_at: anyDate, - updated_at: anyDate, + created_at: anyISODateTime, + updated_at: anyISODateTime, labels: anyArray, subscriptions: anyArray }) @@ -167,8 +167,8 @@ describe('Members API', function () { members: new Array(5).fill({ id: anyObjectId, uuid: anyUuid, - created_at: anyDate, - updated_at: anyDate, + created_at: anyISODateTime, + updated_at: anyISODateTime, labels: anyArray, subscriptions: anyArray }) @@ -268,8 +268,8 @@ describe('Members API', function () { members: new Array(1).fill({ id: anyObjectId, uuid: anyUuid, - created_at: anyDate, - updated_at: anyDate, + created_at: anyISODateTime, + updated_at: anyISODateTime, labels: anyArray, subscriptions: anyArray }) @@ -287,8 +287,8 @@ describe('Members API', function () { members: new Array(1).fill({ id: anyObjectId, uuid: anyUuid, - created_at: anyDate, - updated_at: anyDate, + created_at: anyISODateTime, + updated_at: anyISODateTime, labels: anyArray, subscriptions: anyArray }) @@ -317,8 +317,8 @@ describe('Members API', function () { members: new Array(1).fill({ id: anyObjectId, uuid: anyUuid, - created_at: anyDate, - updated_at: anyDate, + created_at: anyISODateTime, + updated_at: anyISODateTime, labels: anyArray, subscriptions: anyArray }) @@ -483,8 +483,8 @@ describe('Members API', function () { members: new Array(1).fill({ id: anyObjectId, uuid: anyUuid, - created_at: anyDate, - updated_at: anyDate, + created_at: anyISODateTime, + updated_at: anyISODateTime, labels: anyArray, subscriptions: anyArray }) @@ -504,8 +504,8 @@ describe('Members API', function () { members: new Array(1).fill({ id: anyObjectId, uuid: anyUuid, - created_at: anyDate, - updated_at: anyDate, + created_at: anyISODateTime, + updated_at: anyISODateTime, labels: anyArray, subscriptions: anyArray }) @@ -558,8 +558,8 @@ describe('Members API', function () { members: new Array(1).fill({ id: anyObjectId, uuid: anyUuid, - created_at: anyDate, - updated_at: anyDate, + created_at: anyISODateTime, + updated_at: anyISODateTime, labels: anyArray, subscriptions: anyArray }) @@ -598,8 +598,8 @@ describe('Members API', function () { members: new Array(1).fill({ id: anyObjectId, uuid: anyUuid, - created_at: anyDate, - updated_at: anyDate, + created_at: anyISODateTime, + updated_at: anyISODateTime, labels: anyArray, subscriptions: anyArray }) @@ -678,8 +678,8 @@ describe('Members API', function () { members: new Array(1).fill({ id: anyObjectId, uuid: anyUuid, - created_at: anyDate, - updated_at: anyDate, + created_at: anyISODateTime, + updated_at: anyISODateTime, labels: anyArray, subscriptions: [{ start_date: anyString, @@ -714,8 +714,8 @@ describe('Members API', function () { members: new Array(1).fill({ id: anyObjectId, uuid: anyUuid, - created_at: anyDate, - updated_at: anyDate, + created_at: anyISODateTime, + updated_at: anyISODateTime, labels: anyArray, subscriptions: anyArray }) @@ -832,7 +832,7 @@ describe('Members API', function () { .expectStatus(200) .matchBodySnapshot({ data: [{ - date: anyShortDate + date: anyISODate }] }) .matchHeaderSnapshot({ diff --git a/test/e2e-api/admin/tiers.test.js b/test/e2e-api/admin/tiers.test.js index 59057c8c58..d619f9239c 100644 --- a/test/e2e-api/admin/tiers.test.js +++ b/test/e2e-api/admin/tiers.test.js @@ -29,8 +29,8 @@ describe('Tiers API', function () { .matchBodySnapshot({ tiers: Array(2).fill({ id: matchers.anyObjectId, - created_at: matchers.anyDate, - updated_at: matchers.anyDate + created_at: matchers.anyISODateTime, + updated_at: matchers.anyISODateTime }) }); }); diff --git a/test/e2e-api/content/pages.test.js b/test/e2e-api/content/pages.test.js index 6acc5263c0..d5650eb529 100644 --- a/test/e2e-api/content/pages.test.js +++ b/test/e2e-api/content/pages.test.js @@ -1,12 +1,12 @@ const assert = require('assert'); const {agentProvider, fixtureManager, matchers} = require('../../utils/e2e-framework'); -const {anyEtag, anyUuid, anyDateWithTimezoneOffset} = matchers; +const {anyEtag, anyUuid, anyISODateTimeWithTZ} = matchers; const pageMatcher = { - published_at: anyDateWithTimezoneOffset, - created_at: anyDateWithTimezoneOffset, - updated_at: anyDateWithTimezoneOffset, + published_at: anyISODateTimeWithTZ, + created_at: anyISODateTimeWithTZ, + updated_at: anyISODateTimeWithTZ, uuid: anyUuid }; diff --git a/test/e2e-api/content/posts.test.js b/test/e2e-api/content/posts.test.js index cf1f7d105d..05a17b401f 100644 --- a/test/e2e-api/content/posts.test.js +++ b/test/e2e-api/content/posts.test.js @@ -3,12 +3,12 @@ const cheerio = require('cheerio'); const moment = require('moment'); const {agentProvider, fixtureManager, matchers} = require('../../utils/e2e-framework'); -const {anyArray, anyEtag, anyUuid, anyDateWithTimezoneOffset} = matchers; +const {anyArray, anyEtag, anyUuid, anyISODateTimeWithTZ} = matchers; const postMatcher = { - published_at: anyDateWithTimezoneOffset, - created_at: anyDateWithTimezoneOffset, - updated_at: anyDateWithTimezoneOffset, + published_at: anyISODateTimeWithTZ, + created_at: anyISODateTimeWithTZ, + updated_at: anyISODateTimeWithTZ, uuid: anyUuid }; diff --git a/test/regression/api/admin/authentication.test.js b/test/regression/api/admin/authentication.test.js index a4d1c0942b..da0c046c50 100644 --- a/test/regression/api/admin/authentication.test.js +++ b/test/regression/api/admin/authentication.test.js @@ -1,7 +1,7 @@ const nock = require('nock'); const assert = require('assert'); const {agentProvider, mockManager, fixtureManager, matchers} = require('../../../utils/e2e-framework'); -const {anyEtag, anyDate, anyErrorId} = matchers; +const {anyEtag, anyISODateTime, anyErrorId} = matchers; const {tokens} = require('@tryghost/security'); const models = require('../../../../core/server/models'); @@ -56,8 +56,8 @@ describe('Authentication API', function () { .expectStatus(201) .matchBodySnapshot({ users: [{ - created_at: anyDate, - updated_at: anyDate + created_at: anyISODateTime, + updated_at: anyISODateTime }] }) .matchHeaderSnapshot({ @@ -127,9 +127,9 @@ describe('Authentication API', function () { .expectStatus(200) .matchBodySnapshot({ users: [{ - created_at: anyDate, - last_seen: anyDate, - updated_at: anyDate + created_at: anyISODateTime, + last_seen: anyISODateTime, + updated_at: anyISODateTime }] }) .matchHeaderSnapshot({ diff --git a/test/utils/e2e-framework.js b/test/utils/e2e-framework.js index 1aac991758..b88f68b632 100644 --- a/test/utils/e2e-framework.js +++ b/test/utils/e2e-framework.js @@ -276,9 +276,9 @@ module.exports = { matchers: { anyString: any(String), anyArray: any(Array), - anyDate: stringMatching(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.000Z/), - anyShortDate: stringMatching(/\d{4}-\d{2}-\d{2}/), - anyDateWithTimezoneOffset: stringMatching(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.000\+\d{2}:\d{2}/), + anyISODateTime: stringMatching(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.000Z/), + anyISODate: stringMatching(/\d{4}-\d{2}-\d{2}/), + anyISODateTimeWithTZ: stringMatching(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.000\+\d{2}:\d{2}/), anyEtag: stringMatching(/(?:W\/)?"(?:[ !#-\x7E\x80-\xFF]*|\r\n[\t ]|\\.)*"/), anyObjectId: stringMatching(/[a-f0-9]{24}/), anyErrorId: stringMatching(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/),