Fixed tests for flag bumps and new setting

no issue
This commit is contained in:
Simon Backx 2022-10-27 18:11:33 +02:00
parent f2ba88e6e0
commit 13fd64ebf7
5 changed files with 464 additions and 419 deletions

View File

@ -4,6 +4,10 @@ exports[`Settings API Browse Can request all settings 1: [body] 1`] = `
Object {
"meta": Object {},
"settings": Array [
Object {
"key": "members_track_sources",
"value": true,
},
Object {
"key": "title",
"value": "Ghost",
@ -347,6 +351,10 @@ exports[`Settings API Edit Can edit a setting 1: [body] 1`] = `
Object {
"meta": Object {},
"settings": Array [
Object {
"key": "members_track_sources",
"value": true,
},
Object {
"key": "title",
"value": "[]",
@ -627,7 +635,7 @@ exports[`Settings API Edit Can edit a setting 2: [headers] 1`] = `
Object {
"access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "3478",
"content-length": "3603",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Accept-Version, Origin, Accept-Encoding",
@ -640,6 +648,10 @@ exports[`Settings API Edit cannot edit uneditable settings 1: [body] 1`] = `
Object {
"meta": Object {},
"settings": Array [
Object {
"key": "members_track_sources",
"value": true,
},
Object {
"key": "title",
"value": "[]",
@ -932,6 +944,10 @@ exports[`Settings API Edit does not trigger email verification flow if members_s
Object {
"meta": Object {},
"settings": Array [
Object {
"key": "members_track_sources",
"value": true,
},
Object {
"key": "title",
"value": "[]",
@ -1229,6 +1245,10 @@ Object {
],
},
"settings": Array [
Object {
"key": "members_track_sources",
"value": true,
},
Object {
"key": "title",
"value": "[]",
@ -1521,6 +1541,10 @@ exports[`Settings API Edit removes image size prefixes when setting the icon 1:
Object {
"meta": Object {},
"settings": Array [
Object {
"key": "members_track_sources",
"value": true,
},
Object {
"key": "title",
"value": "[]",
@ -1876,6 +1900,10 @@ exports[`Settings API verify key update can update members_support_address via t
Object {
"meta": Object {},
"settings": Array [
Object {
"key": "members_track_sources",
"value": true,
},
Object {
"key": "title",
"value": "[]",

View File

@ -1,5 +1,5 @@
const {agentProvider, mockManager, fixtureManager, matchers} = require('../../utils/e2e-framework');
const {anyEtag, anyErrorId, anyObjectId, anyUuid, anyISODate, anyString, anyObject, anyNumber} = matchers;
const {anyEtag, anyErrorId, anyObjectId, anyContentLength, anyUuid, anyISODate, anyString, anyObject, anyNumber} = matchers;
const models = require('../../../core/server/models');
const assert = require('assert');
@ -16,7 +16,8 @@ async function testPagination(skippedTypes, postId, totalExpected) {
.get(`/members/events?filter=${encodeURIComponent(`type:-[${skippedTypes.join(',')}]${postFilter}`)}&limit=${limit}`)
.expectStatus(200)
.matchHeaderSnapshot({
etag: anyEtag
etag: anyEtag,
'content-length': anyContentLength // Depending on random conditions (ID generation) the order of events can change
})
.matchBodySnapshot({
events: new Array(limit).fill({
@ -50,7 +51,8 @@ async function testPagination(skippedTypes, postId, totalExpected) {
.get(`/members/events?filter=${encodeURIComponent(`type:-[${skippedTypes.join(',')}]${postFilter}+(data.created_at:<'${lastCreatedAt}',(data.created_at:'${lastCreatedAt}'+id:<${lastId}))`)}&limit=${limit}`)
.expectStatus(200)
.matchHeaderSnapshot({
etag: anyEtag
etag: anyEtag,
'content-length': anyContentLength // Depending on random conditions (ID generation) the order of events can change
})
.matchBodySnapshot({
events: new Array(Math.min(remaining, limit)).fill({
@ -424,7 +426,8 @@ describe('Activity Feed API', function () {
.get(`/members/events?filter=data.post_id:${postId}&limit=2`)
.expectStatus(200)
.matchHeaderSnapshot({
etag: anyEtag
etag: anyEtag,
'content-length': anyContentLength // Depending on random conditions (ID generation) the order of events can change
})
.matchBodySnapshot({
events: new Array(2).fill({

View File

@ -7,7 +7,7 @@ const {stringMatching, anyEtag, anyUuid, anyContentLength} = matchers;
const models = require('../../../core/server/models');
const {anyErrorId} = matchers;
const CURRENT_SETTINGS_COUNT = 68;
const CURRENT_SETTINGS_COUNT = 69;
const settingsMatcher = {};
@ -22,14 +22,16 @@ const labsSettingMatcher = {
const matchSettingsArray = (length) => {
const settingsArray = new Array(length).fill(settingsMatcher);
if (length > 25) {
// Item at index 25 is the public hash, which is always different
settingsArray[25] = publicHashSettingMatcher;
if (length > 26) {
// Added a setting that is alphabetically before 'public_hash'? then you need to increment this counter.
// Item at index x is the public hash, which is always different
settingsArray[26] = publicHashSettingMatcher;
}
if (length > 57) {
// Item at index 56 is the lab settings, which changes as we add and remove features
settingsArray[57] = labsSettingMatcher;
if (length > 58) {
// Added a setting that is alphabetically before 'labs'? then you need to increment this counter.
// Item at index x is the lab settings, which changes as we add and remove features
settingsArray[58] = labsSettingMatcher;
}
return settingsArray;

View File

@ -7,6 +7,7 @@ const urlService = require('../../../../../core/server/services/url');
const labs = require('../../../../../core/shared/labs');
const {parseReplacements, renderEmailForSegment, serialize, _getTemplateSettings, createUnsubscribeUrl, createPostSignupUrl, _PostEmailSerializer} = require('../../../../../core/server/services/mega/post-email-serializer');
const {HtmlValidate} = require('html-validate');
const audienceFeedback = require('../../../../../core/server/services/audience-feedback');
function assertKeys(object, keys) {
assert.deepStrictEqual(Object.keys(object).sort(), keys.sort());
@ -91,6 +92,17 @@ describe('Post Email Serializer', function () {
sinon.restore();
});
beforeEach(function () {
// Stub not working because service is undefined
audienceFeedback.service = {
buildLink: (uuid, postId, score) => {
const url = new URL('https://feedback.com');
url.hash = `#/feedback/${postId}/${score}/?uuid=${encodeURIComponent(uuid)}`;
return url;
}
};
});
it('should output valid HTML and escape HTML characters in mobiledoc', async function () {
sinon.stub(_PostEmailSerializer, 'serializePostModel').callsFake(async () => {
return {