Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions ghost/core/test/e2e-api/admin/actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ describe('Actions API', function () {
assert.equal(res2.body.actions[0].actor_type, 'user');
assert.equal(res2.body.actions[0].event, 'added');
assert.equal(Object.keys(res2.body.actions[0].actor).length, 4);
res2.body.actions[0].actor.id.should.eql(testUtils.DataGenerator.Content.users[0].id);
res2.body.actions[0].actor.image.should.eql(testUtils.DataGenerator.Content.users[0].profile_image);
res2.body.actions[0].actor.name.should.eql(testUtils.DataGenerator.Content.users[0].name);
res2.body.actions[0].actor.slug.should.eql(testUtils.DataGenerator.Content.users[0].slug);
assert.equal(res2.body.actions[0].actor.id, testUtils.DataGenerator.Content.users[0].id);
assert.equal(res2.body.actions[0].actor.image, testUtils.DataGenerator.Content.users[0].profile_image);
assert.equal(res2.body.actions[0].actor.name, testUtils.DataGenerator.Content.users[0].name);
assert.equal(res2.body.actions[0].actor.slug, testUtils.DataGenerator.Content.users[0].slug);

clock.tick(1000);

Expand Down Expand Up @@ -94,10 +94,10 @@ describe('Actions API', function () {
assert.equal(res4.body.actions[0].actor_type, 'user');
assert.equal(res4.body.actions[0].event, 'edited');
assert.equal(Object.keys(res4.body.actions[0].actor).length, 4);
res4.body.actions[0].actor.id.should.eql(testUtils.DataGenerator.Content.users[0].id);
res4.body.actions[0].actor.image.should.eql(testUtils.DataGenerator.Content.users[0].profile_image);
res4.body.actions[0].actor.name.should.eql(testUtils.DataGenerator.Content.users[0].name);
res4.body.actions[0].actor.slug.should.eql(testUtils.DataGenerator.Content.users[0].slug);
assert.equal(res4.body.actions[0].actor.id, testUtils.DataGenerator.Content.users[0].id);
assert.equal(res4.body.actions[0].actor.image, testUtils.DataGenerator.Content.users[0].profile_image);
assert.equal(res4.body.actions[0].actor.name, testUtils.DataGenerator.Content.users[0].name);
assert.equal(res4.body.actions[0].actor.slug, testUtils.DataGenerator.Content.users[0].slug);

clock.tick(1000);

Expand Down Expand Up @@ -132,9 +132,9 @@ describe('Actions API', function () {
assert.equal(res5.body.actions[0].actor_type, 'integration');
assert.equal(res5.body.actions[0].event, 'edited');
assert.equal(Object.keys(res5.body.actions[0].actor).length, 4);
res5.body.actions[0].actor.id.should.eql(testUtils.DataGenerator.Content.integrations[0].id);
assert.equal(res5.body.actions[0].actor.id, testUtils.DataGenerator.Content.integrations[0].id);
assert.equal(res5.body.actions[0].actor.image, null);
res5.body.actions[0].actor.name.should.eql(testUtils.DataGenerator.Content.integrations[0].name);
res5.body.actions[0].actor.slug.should.eql(testUtils.DataGenerator.Content.integrations[0].slug);
assert.equal(res5.body.actions[0].actor.name, testUtils.DataGenerator.Content.integrations[0].name);
assert.equal(res5.body.actions[0].actor.slug, testUtils.DataGenerator.Content.integrations[0].slug);
});
});
4 changes: 2 additions & 2 deletions ghost/core/test/e2e-api/admin/integrations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ describe('Integrations API', function () {
await request.del(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
.set('Origin', config.get('url'))
.expect(204)
.expect((_res) => {
_res.body.should.be.empty();
.expect(({body}) => {
assert.deepEqual(body, {});
});

await request.get(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
Expand Down
14 changes: 7 additions & 7 deletions ghost/core/test/e2e-api/admin/invites.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ describe('Invites API', function () {

assert.equal(jsonResponse.invites[0].status, 'sent');
assert.equal(jsonResponse.invites[0].email, 'test1@ghost.org');
jsonResponse.invites[0].role_id.should.eql(testUtils.roles.ids.admin);
assert.equal(jsonResponse.invites[0].role_id, testUtils.roles.ids.admin);

assert.equal(jsonResponse.invites[1].status, 'sent');
assert.equal(jsonResponse.invites[1].email, 'test2@ghost.org');
jsonResponse.invites[1].role_id.should.eql(testUtils.roles.ids.author);
assert.equal(jsonResponse.invites[1].role_id, testUtils.roles.ids.author);

assert.equal(mailService.GhostMailer.prototype.send.called, false);
});
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('Invites API', function () {
assert.equal(jsonResponse.invites.length, 1);

localUtils.API.checkResponse(jsonResponse.invites[0], 'invite');
jsonResponse.invites[0].role_id.should.eql(testUtils.getExistingData().roles[1].id);
assert.equal(jsonResponse.invites[0].role_id, testUtils.getExistingData().roles[1].id);

assert.equal(mailService.GhostMailer.prototype.send.called, true);

Expand Down Expand Up @@ -153,7 +153,7 @@ describe('Invites API', function () {
assert.equal(jsonResponse.invites.length, 1);

localUtils.API.checkResponse(jsonResponse.invites[0], 'invite');
jsonResponse.invites[0].role_id.should.eql(roleId);
assert.equal(jsonResponse.invites[0].role_id, roleId);

assert.equal(mailService.GhostMailer.prototype.send.called, true);

Expand All @@ -180,7 +180,7 @@ describe('Invites API', function () {
assert.equal(jsonResponse.invites.length, 1);

localUtils.API.checkResponse(jsonResponse.invites[0], 'invite');
jsonResponse.invites[0].role_id.should.eql(roleId);
assert.equal(jsonResponse.invites[0].role_id, roleId);

assert.equal(mailService.GhostMailer.prototype.send.called, true);

Expand All @@ -207,7 +207,7 @@ describe('Invites API', function () {
assert.equal(jsonResponse.invites.length, 1);

localUtils.API.checkResponse(jsonResponse.invites[0], 'invite');
jsonResponse.invites[0].role_id.should.eql(roleId);
assert.equal(jsonResponse.invites[0].role_id, roleId);

assert.equal(mailService.GhostMailer.prototype.send.called, true);

Expand All @@ -234,7 +234,7 @@ describe('Invites API', function () {
assert.equal(jsonResponse.invites.length, 1);

localUtils.API.checkResponse(jsonResponse.invites[0], 'invite');
jsonResponse.invites[0].role_id.should.eql(roleId);
assert.equal(jsonResponse.invites[0].role_id, roleId);

assert.equal(mailService.GhostMailer.prototype.send.called, true);

Expand Down
6 changes: 3 additions & 3 deletions ghost/core/test/e2e-api/admin/oembed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ describe('Oembed API', function () {
assert.equal(pageMock.isDone(), true);

// Check that the substitute icon URL is returned in place of the original
res.body.metadata.icon.should.eql(`${urlUtils.urlFor('home', true)}content/images/icon/image-01.png`);
assert.equal(res.body.metadata.icon, `${urlUtils.urlFor('home', true)}content/images/icon/image-01.png`);
});

it('should fetch and store thumbnails', async function () {
Expand All @@ -305,7 +305,7 @@ describe('Oembed API', function () {
assert.equal(pageMock.isDone(), true);

// Check that the substitute thumbnail URL is returned in place of the original
res.body.metadata.thumbnail.should.eql(`${urlUtils.urlFor('home', true)}content/images/thumbnail/image-01.png`);
assert.equal(res.body.metadata.thumbnail, `${urlUtils.urlFor('home', true)}content/images/thumbnail/image-01.png`);
});

it('should prevent SSRF attacks via bookmark image fetching', async function () {
Expand Down Expand Up @@ -824,7 +824,7 @@ describe('Oembed API', function () {
assert.equal(pageMock.isDone(), true);
assert.equal(res.body.type, 'bookmark');
assert.equal(res.body.url, 'http://example.com');
res.body.metadata.title.should.eql(utfString);
assert.equal(res.body.metadata.title, utfString);
});

it('does not fail on unknown charset', async function () {
Expand Down
12 changes: 6 additions & 6 deletions ghost/core/test/e2e-api/admin/pages-legacy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ describe('Pages API', function () {

const modelJson = model.toJSON();

modelJson.title.should.eql(page.title);
modelJson.status.should.eql(page.status);
assert.equal(modelJson.title, page.title);
assert.equal(modelJson.status, page.status);
assert.equal(modelJson.type, 'page');

modelJson.posts_meta.feature_image_alt.should.eql(page.feature_image_alt);
modelJson.posts_meta.feature_image_caption.should.eql(page.feature_image_caption);
assert.equal(modelJson.posts_meta.feature_image_alt, page.feature_image_alt);
assert.equal(modelJson.posts_meta.feature_image_caption, page.feature_image_caption);
});

it('Can add a page with mobiledoc', async function () {
Expand Down Expand Up @@ -392,7 +392,7 @@ describe('Pages API', function () {

assertExists(res2.headers['x-cache-invalidate']);
localUtils.API.checkResponse(res2.body.pages[0], 'page', ['reading_time']);
res2.body.pages[0].tiers.length.should.eql(paidTiers.length);
assert.equal(res2.body.pages[0].tiers.length, paidTiers.length);

const model = await models.Post.findOne({
id: res2.body.pages[0].id
Expand Down Expand Up @@ -429,7 +429,7 @@ describe('Pages API', function () {
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(204);

res.body.should.be.empty();
assert.deepEqual(res.body, {});
assert.equal(res.headers['x-cache-invalidate'], '/*');
});
});
20 changes: 10 additions & 10 deletions ghost/core/test/e2e-api/admin/posts-legacy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ describe('Posts API', function () {
assert.equal(new URL(jsonResponse.posts[2].authors[0].url).pathname, '/author/ghost/');

// Check if the newsletter relation is loaded by default and newsletter_id is not returned
jsonResponse.posts[14].id.should.eql(testUtils.DataGenerator.Content.posts[0].id);
jsonResponse.posts[14].newsletter.id.should.eql(testUtils.DataGenerator.Content.newsletters[0].id);
assert.equal(jsonResponse.posts[14].id, testUtils.DataGenerator.Content.posts[0].id);
assert.equal(jsonResponse.posts[14].newsletter.id, testUtils.DataGenerator.Content.newsletters[0].id);
assert.equal(jsonResponse.posts[14].newsletter_id, undefined);

assert.equal(jsonResponse.posts[0].newsletter, null);
Expand Down Expand Up @@ -184,7 +184,7 @@ describe('Posts API', function () {
assert.equal(testUtils.API.isISO8601(jsonResponse.posts[0].created_at), true);

// Check if the newsletter relation is loaded by default and newsletter_id is not returned
jsonResponse.posts[0].newsletter.id.should.eql(testUtils.DataGenerator.Content.newsletters[0].id);
assert.equal(jsonResponse.posts[0].newsletter.id, testUtils.DataGenerator.Content.newsletters[0].id);
assert.equal(jsonResponse.posts[0].newsletter_id, undefined);
});

Expand Down Expand Up @@ -256,7 +256,7 @@ describe('Posts API', function () {
assert(_.isPlainObject(jsonResponse.posts[0].email));
localUtils.API.checkResponse(jsonResponse.posts[0].email, 'email');

jsonResponse.posts[0].newsletter.id.should.eql(testUtils.DataGenerator.Content.newsletters[0].id);
assert.equal(jsonResponse.posts[0].newsletter.id, testUtils.DataGenerator.Content.newsletters[0].id);
assert.equal(jsonResponse.posts[0].newsletter_id, undefined);
});

Expand Down Expand Up @@ -298,14 +298,14 @@ describe('Posts API', function () {

const modelJson = model.toJSON();

modelJson.title.should.eql(post.title);
modelJson.status.should.eql(post.status);
assert.equal(modelJson.title, post.title);
assert.equal(modelJson.status, post.status);
assert.equal(modelJson.published_at.toISOString(), '2016-05-30T07:00:00.000Z');
modelJson.created_at.toISOString().should.not.eql(post.created_at.toISOString());
modelJson.updated_at.toISOString().should.not.eql(post.updated_at.toISOString());

modelJson.posts_meta.feature_image_alt.should.eql(post.feature_image_alt);
modelJson.posts_meta.feature_image_caption.should.eql(post.feature_image_caption);
assert.equal(modelJson.posts_meta.feature_image_alt, post.feature_image_alt);
assert.equal(modelJson.posts_meta.feature_image_caption, post.feature_image_caption);
});

it('Can include free and paid tiers for public post', async function () {
Expand Down Expand Up @@ -407,7 +407,7 @@ describe('Posts API', function () {

const uuid = res2.body.posts[0].uuid;
const expectedPattern = `/p/${uuid}/, /p/${uuid}/?member_status=anonymous, /p/${uuid}/?member_status=free, /p/${uuid}/?member_status=paid`;
res2.headers['x-cache-invalidate'].should.eql(expectedPattern);
assert.equal(res2.headers['x-cache-invalidate'], expectedPattern);

// Newsletter should be returned as null
assert.equal(res2.body.posts[0].newsletter, null);
Expand Down Expand Up @@ -446,7 +446,7 @@ describe('Posts API', function () {

const uuid = res2.body.posts[0].uuid;
const expectedPattern = `/p/${uuid}/, /p/${uuid}/?member_status=anonymous, /p/${uuid}/?member_status=free, /p/${uuid}/?member_status=paid`;
res2.headers['x-cache-invalidate'].should.eql(expectedPattern);
assert.equal(res2.headers['x-cache-invalidate'], expectedPattern);

assert.equal(unsplashMock.isDone(), true);

Expand Down
2 changes: 1 addition & 1 deletion ghost/core/test/e2e-api/admin/redirects.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('Redirects API', function () {
.expect('Content-Type', /application\/json/)
.expect(200)
.expect((res) => {
res.body.should.be.empty();
assert.deepEqual(res.body, {});
});
});
});
6 changes: 3 additions & 3 deletions ghost/core/test/e2e-api/admin/themes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ describe('Themes API', function () {
.del(localUtils.API.getApiQuery('themes/valid'))
.set('Origin', config.get('url'))
.expect(204)
.expect((_res) => {
_res.body.should.be.empty();
.expect((res) => {
assert.deepEqual(res.body, {});
});

// ensure tmp theme folder contains one theme again now
Expand Down Expand Up @@ -291,7 +291,7 @@ describe('Themes API', function () {
.set('Origin', config.get('url'))
.expect(200);

res2.body.should.eql(activeThemeResult.body);
assert.deepEqual(res2.body, activeThemeResult.body);
});

it('Can download and install a theme from GitHub', async function () {
Expand Down
16 changes: 8 additions & 8 deletions ghost/core/test/e2e-api/members/middleware.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('Comments API', function () {
})
.matchBodySnapshot(buildMemberMatcher(1))
.expect(({body}) => {
body.email.should.eql(member.get('email'));
assert.equal(body.email, member.get('email'));
assert.equal(body.enable_comment_notifications, false);
});
member = await models.Member.findOne({id: member.id}, {require: true});
Expand All @@ -104,7 +104,7 @@ describe('Comments API', function () {
})
.matchBodySnapshot(memberMatcher(2))
.expect(({body}) => {
body.email.should.eql(member.get('email'));
assert.equal(body.email, member.get('email'));
});
});

Expand All @@ -120,7 +120,7 @@ describe('Comments API', function () {
})
.matchBodySnapshot(memberMatcher(2))
.expect(({body}) => {
body.email.should.eql(member.get('email'));
assert.equal(body.email, member.get('email'));
assert.equal(body.expertise, 'Head of Testing');
});
member = await models.Member.findOne({id: member.id}, {require: true});
Expand All @@ -139,7 +139,7 @@ describe('Comments API', function () {
})
.matchBodySnapshot(memberMatcher(2))
.expect(({body}) => {
body.email.should.eql(member.get('email'));
assert.equal(body.email, member.get('email'));
assert.equal(body.expertise, 'test');
});
member = await models.Member.findOne({id: member.id}, {require: true});
Expand All @@ -158,7 +158,7 @@ describe('Comments API', function () {
})
.matchBodySnapshot(memberMatcher(2))
.expect(({body}) => {
body.email.should.eql(member.get('email'));
assert.equal(body.email, member.get('email'));
assert.equal(body.name, 'Test User');
assert.equal(body.firstname, 'Test');
});
Expand All @@ -181,7 +181,7 @@ describe('Comments API', function () {
})
.matchBodySnapshot(memberMatcher(2))
.expect(({body}) => {
body.email.should.eql(member.get('email'));
assert.equal(body.email, member.get('email'));
assert.equal(body.enable_comment_notifications, false);
});
member = await models.Member.findOne({id: member.id}, {require: true});
Expand All @@ -202,7 +202,7 @@ describe('Comments API', function () {
})
.matchBodySnapshot(buildMemberMatcher(2))
.expect(({body}) => {
body.email.should.eql(member.get('email'));
assert.equal(body.email, member.get('email'));
assert.equal(body.enable_comment_notifications, true);
});
member = await models.Member.findOne({id: member.id}, {require: true});
Expand Down Expand Up @@ -257,7 +257,7 @@ describe('Comments API', function () {
})
.matchBodySnapshot(memberMatcher(2))
.expect(({body}) => {
body.email.should.eql(member.get('email'));
assert.equal(body.email, member.get('email'));
});
});

Expand Down
2 changes: 1 addition & 1 deletion ghost/core/test/e2e-frontend/helpers/get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function buildMember(status, products = []) {

function testPosts(posts, map) {
assert(Array.isArray(posts));
posts.length.should.eql(DEFAULT_POST_FIXTURE_COUNT + Object.keys(map).length);
assert.equal(posts.length, DEFAULT_POST_FIXTURE_COUNT + Object.keys(map).length);

// Free post
for (const postID in map) {
Expand Down
2 changes: 1 addition & 1 deletion ghost/core/test/integration/exporter/exporter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('Exporter', function () {

// NOTE: using `Object.keys` here instead of `should.have.only.keys` assertion
// because when `have.only.keys` fails there's no useful diff
Object.keys(exportData.data).sort().should.eql(tables.sort());
assert.deepEqual(Object.keys(exportData.data).sort(), tables.sort());
Object.keys(exportData.data).sort().should.containDeep(Object.keys(exportedBodyLatest().db[0].data));
assert.equal(exportData.meta.version, ghostVersion.full);

Expand Down
4 changes: 2 additions & 2 deletions ghost/core/test/integration/importer/v1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('Importer 1.0', function () {
const posts = result[0].data.map(model => model.toJSON());

assert.equal(posts.length, 2);
posts[0].comment_id.should.eql(exportData.data.posts[1].id);
assert.equal(posts[0].comment_id, exportData.data.posts[1].id);
assert.equal(posts[1].comment_id, '2');
});
});
Expand Down Expand Up @@ -180,7 +180,7 @@ describe('Importer 1.0', function () {
assert.equal(posts[0].html, '<!--kg-card-begin: markdown--><h1 id="thisismypostcontent">This is my post content</h1>\n<!--kg-card-end: markdown-->');
const expectedMobiledoc = JSON.parse(exportData.data.posts[0].mobiledoc);
expectedMobiledoc.ghostVersion = '3.0';
posts[0].mobiledoc.should.eql(JSON.stringify(expectedMobiledoc));
assert.equal(posts[0].mobiledoc, JSON.stringify(expectedMobiledoc));
});
});

Expand Down
Loading
Loading