mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Refactored scheduling tests logic using async/await
refs https://github.com/TryGhost/Team/issues/694 - The previous `.then` chaining was outdated, while in this part of code did a tiny cleanup which should improve future maintenance slightly
This commit is contained in:
parent
ba50241fde
commit
48d5d4c93d
3 changed files with 54 additions and 60 deletions
|
@ -94,35 +94,33 @@ describe('Canary Schedules API', function () {
|
||||||
token = localUtils.getValidAdminToken('/canary/admin/', schedulerKey);
|
token = localUtils.getValidAdminToken('/canary/admin/', schedulerKey);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('publishes posts', function () {
|
it('publishes posts', async function () {
|
||||||
return request
|
const res = await request
|
||||||
.put(localUtils.API.getApiQuery(`schedules/posts/${resources[0].id}/?token=${token}`))
|
.put(localUtils.API.getApiQuery(`schedules/posts/${resources[0].id}/?token=${token}`))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200);
|
||||||
.then((res) => {
|
|
||||||
should.exist(res.headers['x-cache-invalidate']);
|
should.exist(res.headers['x-cache-invalidate']);
|
||||||
const jsonResponse = res.body;
|
const jsonResponse = res.body;
|
||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
jsonResponse.posts[0].id.should.eql(resources[0].id);
|
jsonResponse.posts[0].id.should.eql(resources[0].id);
|
||||||
jsonResponse.posts[0].status.should.eql('published');
|
jsonResponse.posts[0].status.should.eql('published');
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('publishes page', function () {
|
it('publishes page', async function () {
|
||||||
return request
|
const res = await request
|
||||||
.put(localUtils.API.getApiQuery(`schedules/pages/${resources[4].id}/?token=${token}`))
|
.put(localUtils.API.getApiQuery(`schedules/pages/${resources[4].id}/?token=${token}`))
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200);
|
||||||
.then((res) => {
|
|
||||||
should.exist(res.headers['x-cache-invalidate']);
|
should.exist(res.headers['x-cache-invalidate']);
|
||||||
const jsonResponse = res.body;
|
const jsonResponse = res.body;
|
||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
jsonResponse.pages[0].id.should.eql(resources[4].id);
|
jsonResponse.pages[0].id.should.eql(resources[4].id);
|
||||||
jsonResponse.pages[0].status.should.eql('published');
|
jsonResponse.pages[0].status.should.eql('published');
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('no access', function () {
|
it('no access', function () {
|
||||||
|
|
|
@ -94,35 +94,33 @@ describe('v2 Schedules API', function () {
|
||||||
token = localUtils.getValidAdminToken('/v2/admin/', schedulerKey);
|
token = localUtils.getValidAdminToken('/v2/admin/', schedulerKey);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('publishes posts', function () {
|
it('publishes posts', async function () {
|
||||||
return request
|
const res = await request
|
||||||
.put(localUtils.API.getApiQuery(`schedules/posts/${resources[0].id}/?token=${token}`))
|
.put(localUtils.API.getApiQuery(`schedules/posts/${resources[0].id}/?token=${token}`))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200);
|
||||||
.then((res) => {
|
|
||||||
should.exist(res.headers['x-cache-invalidate']);
|
should.exist(res.headers['x-cache-invalidate']);
|
||||||
const jsonResponse = res.body;
|
const jsonResponse = res.body;
|
||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
jsonResponse.posts[0].id.should.eql(resources[0].id);
|
jsonResponse.posts[0].id.should.eql(resources[0].id);
|
||||||
jsonResponse.posts[0].status.should.eql('published');
|
jsonResponse.posts[0].status.should.eql('published');
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('publishes page', function () {
|
it('publishes page', async function () {
|
||||||
return request
|
const res = await request
|
||||||
.put(localUtils.API.getApiQuery(`schedules/pages/${resources[4].id}/?token=${token}`))
|
.put(localUtils.API.getApiQuery(`schedules/pages/${resources[4].id}/?token=${token}`))
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200);
|
||||||
.then((res) => {
|
|
||||||
should.exist(res.headers['x-cache-invalidate']);
|
should.exist(res.headers['x-cache-invalidate']);
|
||||||
const jsonResponse = res.body;
|
const jsonResponse = res.body;
|
||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
jsonResponse.pages[0].id.should.eql(resources[4].id);
|
jsonResponse.pages[0].id.should.eql(resources[4].id);
|
||||||
jsonResponse.pages[0].status.should.eql('published');
|
jsonResponse.pages[0].status.should.eql('published');
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('no access', function () {
|
it('no access', function () {
|
||||||
|
|
|
@ -94,35 +94,33 @@ describe('v3 Schedules API', function () {
|
||||||
token = localUtils.getValidAdminToken('/v3/admin/', schedulerKey);
|
token = localUtils.getValidAdminToken('/v3/admin/', schedulerKey);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('publishes posts', function () {
|
it('publishes posts', async function () {
|
||||||
return request
|
const res = await request
|
||||||
.put(localUtils.API.getApiQuery(`schedules/posts/${resources[0].id}/?token=${token}`))
|
.put(localUtils.API.getApiQuery(`schedules/posts/${resources[0].id}/?token=${token}`))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200);
|
||||||
.then((res) => {
|
|
||||||
should.exist(res.headers['x-cache-invalidate']);
|
should.exist(res.headers['x-cache-invalidate']);
|
||||||
const jsonResponse = res.body;
|
const jsonResponse = res.body;
|
||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
jsonResponse.posts[0].id.should.eql(resources[0].id);
|
jsonResponse.posts[0].id.should.eql(resources[0].id);
|
||||||
jsonResponse.posts[0].status.should.eql('published');
|
jsonResponse.posts[0].status.should.eql('published');
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('publishes page', function () {
|
it('publishes page', async function () {
|
||||||
return request
|
const res = await request
|
||||||
.put(localUtils.API.getApiQuery(`schedules/pages/${resources[4].id}/?token=${token}`))
|
.put(localUtils.API.getApiQuery(`schedules/pages/${resources[4].id}/?token=${token}`))
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200);
|
||||||
.then((res) => {
|
|
||||||
should.exist(res.headers['x-cache-invalidate']);
|
should.exist(res.headers['x-cache-invalidate']);
|
||||||
const jsonResponse = res.body;
|
const jsonResponse = res.body;
|
||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
jsonResponse.pages[0].id.should.eql(resources[4].id);
|
jsonResponse.pages[0].id.should.eql(resources[4].id);
|
||||||
jsonResponse.pages[0].status.should.eql('published');
|
jsonResponse.pages[0].status.should.eql('published');
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('no access', function () {
|
it('no access', function () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue