0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Updated the authentication test

no issue

- Mocked the github url with nock to avoid network usage during regression testing
- Added logging when the theme install fails during setup
This commit is contained in:
Thibaut Patel 2022-02-14 18:22:53 +01:00
parent 8dcf92d047
commit e59ee38d21
2 changed files with 13 additions and 3 deletions

View file

@ -12,7 +12,8 @@ const messages = {
setupUnableToRun: 'Database missing fixture data. Please reset database and try again.',
sampleBlogDescription: 'Thoughts, stories and ideas.',
yourNewGhostBlog: 'Your New Ghost Site',
unableToSendWelcomeEmail: 'Unable to send welcome email, your site will continue to function.'
unableToSendWelcomeEmail: 'Unable to send welcome email, your site will continue to function.',
failedThemeInstall: 'Theme {themeName} didn\'t install because of the error: {error}'
};
/**
@ -169,8 +170,9 @@ async function installTheme(data, api) {
name: theme.name,
context: {internal: true}
});
} catch (e) {
} catch (error) {
//Fallback to Casper by doing nothing as the theme setting update is the last step
logging.warn(tpl(messages.failedThemeInstall, {themeName, error: error.message}));
await api.notifications.add({
notifications: [{

View file

@ -1,3 +1,4 @@
const nock = require('nock');
const assert = require('assert');
const {agentProvider, mockManager, fixtureManager, matchers} = require('../../../utils/e2e-framework');
const {anyEtag, anyDate, anyErrorId} = matchers;
@ -20,6 +21,7 @@ describe('Authentication API', function () {
afterEach(function () {
mockManager.restore();
nock.cleanAll();
});
it('is setup? no', async function () {
@ -33,6 +35,11 @@ describe('Authentication API', function () {
});
it('complete setup', async function () {
const requestMock = nock('https://api.github.com')
.get('/repos/tryghost/dawn/zipball')
.query(true)
.replyWithFile(200, __dirname + '/../../../utils/fixtures/themes/valid.zip');
await agent
.post('authentication/setup')
.body({
@ -60,9 +67,10 @@ describe('Authentication API', function () {
subject: 'Your New Ghost Site',
to: 'test@example.com'
});
assert.equal(requestMock.isDone(), true, 'The dawn github URL should have been used');
const activeTheme = await settingsCache.get('active_theme');
assert.equal(activeTheme, 'dawn', 'The theme dawn should have been isntalled');
assert.equal(activeTheme, 'dawn', 'The theme dawn should have been installed');
});
it('is setup? yes', async function () {