mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Added E2E tests for Public Site Settings in members API (#18223)
fixes https://github.com/TryGhost/Product/issues/3901
This commit is contained in:
parent
85484c20af
commit
95c8ba11d6
2 changed files with 107 additions and 0 deletions
|
@ -0,0 +1,59 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Site Public Settings Can retrieve site pubic config 1: [body] 1`] = `
|
||||
Object {
|
||||
"site": Object {
|
||||
"accent_color": "#FF1A75",
|
||||
"allow_self_signup": true,
|
||||
"cover_image": "https://static.ghost.org/v5.0.0/images/publication-cover.jpg",
|
||||
"description": "Thoughts, stories and ideas",
|
||||
"icon": null,
|
||||
"locale": "en",
|
||||
"logo": null,
|
||||
"title": "Ghost",
|
||||
"url": "http://127.0.0.1:2369/",
|
||||
"version": StringMatching /\\\\d\\+\\\\\\.\\\\d\\+/,
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Site Public Settings Can retrieve site pubic config 2: [headers] 1`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "*",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
"content-length": StringMatching /\\\\d\\+/,
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Accept-Encoding",
|
||||
"x-powered-by": "Express",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Site Public Settings Sets allow_self_signup to false when members are invite only 1: [body] 1`] = `
|
||||
Object {
|
||||
"site": Object {
|
||||
"accent_color": "#FF1A75",
|
||||
"allow_self_signup": false,
|
||||
"cover_image": "https://static.ghost.org/v5.0.0/images/publication-cover.jpg",
|
||||
"description": "Thoughts, stories and ideas",
|
||||
"icon": null,
|
||||
"locale": "en",
|
||||
"logo": null,
|
||||
"title": "Ghost",
|
||||
"url": "http://127.0.0.1:2369/",
|
||||
"version": StringMatching /\\\\d\\+\\\\\\.\\\\d\\+/,
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Site Public Settings Sets allow_self_signup to false when members are invite only 2: [headers] 1`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "*",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
"content-length": StringMatching /\\\\d\\+/,
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Accept-Encoding",
|
||||
"x-powered-by": "Express",
|
||||
}
|
||||
`;
|
48
ghost/core/test/e2e-api/members/site.test.js
Normal file
48
ghost/core/test/e2e-api/members/site.test.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
const {agentProvider, fixtureManager, matchers} = require('../../utils/e2e-framework');
|
||||
const {anyEtag, stringMatching, anyContentLength} = matchers;
|
||||
const assert = require('assert/strict');
|
||||
const models = require('../../../core/server/models');
|
||||
|
||||
describe('Site Public Settings', function () {
|
||||
let membersAgent;
|
||||
|
||||
before(async function () {
|
||||
membersAgent = await agentProvider.getMembersAPIAgent();
|
||||
await fixtureManager.init();
|
||||
});
|
||||
|
||||
it('Can retrieve site pubic config', async function () {
|
||||
const {body} = await membersAgent
|
||||
.get('/api/site')
|
||||
.matchBodySnapshot({
|
||||
site: {
|
||||
version: stringMatching(/\d+\.\d+/)
|
||||
}
|
||||
})
|
||||
.matchHeaderSnapshot({
|
||||
etag: anyEtag,
|
||||
'content-length': anyContentLength
|
||||
});
|
||||
assert.equal(body.site.allow_self_signup, true);
|
||||
});
|
||||
|
||||
it('Sets allow_self_signup to false when members are invite only', async function () {
|
||||
await await models.Settings.edit({
|
||||
key: 'members_signup_access',
|
||||
value: 'invite'
|
||||
}, {context: {internal: true}});
|
||||
|
||||
const {body} = await membersAgent
|
||||
.get('/api/site')
|
||||
.matchBodySnapshot({
|
||||
site: {
|
||||
version: stringMatching(/\d+\.\d+/)
|
||||
}
|
||||
})
|
||||
.matchHeaderSnapshot({
|
||||
etag: anyEtag,
|
||||
'content-length': anyContentLength
|
||||
});
|
||||
assert.equal(body.site.allow_self_signup, false);
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue