mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-01 02:41:39 -05:00
Improved agentProvider api in e2e-framework
refs: https://github.com/TryGhost/Toolbox/issues/158 - Working up to having these be the defacto "reference" tests - Changing this allows for the fact that there will be a getContentAPIAgent, and probably more in future - Abstracting away the path to a single location will make updating API paths easier later too
This commit is contained in:
parent
069c344495
commit
d7c2759b3f
4 changed files with 14 additions and 12 deletions
|
@ -15,7 +15,7 @@ describe('Authentication API', function () {
|
|||
|
||||
describe('Blog setup', function () {
|
||||
before(async function () {
|
||||
agent = await agentProvider.getAgent('/ghost/api/canary/admin/');
|
||||
agent = await agentProvider.getAdminAPIAgent();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
@ -134,7 +134,7 @@ describe('Authentication API', function () {
|
|||
|
||||
describe('Invitation', function () {
|
||||
before(async function () {
|
||||
agent = await agentProvider.getAgent('/ghost/api/canary/admin/');
|
||||
agent = await agentProvider.getAdminAPIAgent();
|
||||
// NOTE: this order of fixture initialization boggles me. Ideally should not depend on agent/login sequence
|
||||
await fixtureManager.init('invites');
|
||||
await agent.loginAsOwner();
|
||||
|
@ -231,7 +231,7 @@ describe('Authentication API', function () {
|
|||
const user = testUtils.DataGenerator.forModel.users[0];
|
||||
|
||||
before(async function () {
|
||||
agent = await agentProvider.getAgent('/ghost/api/canary/admin/');
|
||||
agent = await agentProvider.getAdminAPIAgent();
|
||||
// NOTE: this order of fixture initialization boggles me. Ideally should not depend on agent/login sequence
|
||||
await fixtureManager.init('invites');
|
||||
await agent.loginAsOwner();
|
||||
|
@ -373,7 +373,7 @@ describe('Authentication API', function () {
|
|||
|
||||
describe('Reset all passwords', function () {
|
||||
before(async function () {
|
||||
agent = await agentProvider.getAgent('/ghost/api/canary/admin/');
|
||||
agent = await agentProvider.getAdminAPIAgent();
|
||||
// NOTE: this order of fixture initialization boggles me. Ideally should not depend on agent/login sequence
|
||||
await fixtureManager.init('invites');
|
||||
await agent.loginAsOwner();
|
||||
|
|
|
@ -15,7 +15,7 @@ describe('Members API', function () {
|
|||
});
|
||||
|
||||
before(async function () {
|
||||
agent = await agentProvider.getAgent('/ghost/api/canary/admin/');
|
||||
agent = await agentProvider.getAdminAPIAgent();
|
||||
await fixtureManager.init('members');
|
||||
await agent.loginAsOwner();
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ describe('Site API', function () {
|
|||
let agent;
|
||||
|
||||
before(async function () {
|
||||
agent = await agentProvider.getAgent('/ghost/api/canary/admin/');
|
||||
agent = await agentProvider.getAdminAPIAgent('/ghost/api/canary/admin/');
|
||||
});
|
||||
|
||||
it('can retrieve config and all expected properties', async function () {
|
||||
|
|
|
@ -113,17 +113,19 @@ const resetDb = async () => {
|
|||
};
|
||||
|
||||
/**
|
||||
* Creates a TestAgent which is a drop-in substitution for supertest hooked into Ghost.
|
||||
* @param {String} apiURL
|
||||
* @returns {TestAgent}
|
||||
* Creates a TestAgent which is a drop-in substitution for supertest
|
||||
* It is automatically hooked up to the Admin API so you can make requests to e.g.
|
||||
* agent.get('/posts/') without having to worry about URL paths
|
||||
*
|
||||
* @returns {TestAgent} agent
|
||||
*/
|
||||
const getAgent = async (apiURL) => {
|
||||
const getAdminAPIAgent = async () => {
|
||||
try {
|
||||
const app = await startGhost();
|
||||
const originURL = configUtils.config.get('url');
|
||||
|
||||
return new TestAgent(app, {
|
||||
apiURL,
|
||||
apiURL: '/ghost/api/canary/admin/',
|
||||
originURL
|
||||
});
|
||||
} catch (error) {
|
||||
|
@ -134,7 +136,7 @@ const getAgent = async (apiURL) => {
|
|||
module.exports = {
|
||||
// request agent
|
||||
agentProvider: {
|
||||
getAgent
|
||||
getAdminAPIAgent
|
||||
},
|
||||
|
||||
// Mocks and Stubs
|
||||
|
|
Loading…
Add table
Reference in a new issue