mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Exposed Content API agent in e2e test utils
refs https://github.com/TryGhost/Toolbox/issues/461 - When testing OPTIONS requests there is a need to get all possible agents available in the system. The "getAgentsWithFrontend" serves exactly this purpose - create all possible agents while starting Ghost instance only once - This is groundwork for OPTIONS request caching tests and improvements
This commit is contained in:
parent
ab678c3a90
commit
5fe80c82c5
1 changed files with 10 additions and 3 deletions
|
@ -292,13 +292,15 @@ const getAgentsForMembers = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: for now this agent returns a supertest agent instead of a proper test agent.
|
* @NOTE: for now method returns a supertest agent for Frontend instead of test agent with snapshot support.
|
||||||
* We need to add support for this.
|
* frontendAgent should be returning an instance of TestAgent.
|
||||||
|
* @returns {Promise<{adminAgent: InstanceType<AdminAPITestAgent>, membersAgent: InstanceType<MembersAPITestAgent>, frontendAgent: InstanceType<supertest.SuperAgentTest>, contentAPIAgent: InstanceType<ContentAPITestAgent>}>} agents
|
||||||
*/
|
*/
|
||||||
const getAgentsWithFrontend = async () => {
|
const getAgentsWithFrontend = async () => {
|
||||||
let membersAgent;
|
let membersAgent;
|
||||||
let adminAgent;
|
let adminAgent;
|
||||||
let frontendAgent;
|
let frontendAgent;
|
||||||
|
let contentAPIAgent;
|
||||||
|
|
||||||
const bootOptions = {
|
const bootOptions = {
|
||||||
frontend: true,
|
frontend: true,
|
||||||
|
@ -316,6 +318,10 @@ const getAgentsWithFrontend = async () => {
|
||||||
apiURL: '/ghost/api/admin/',
|
apiURL: '/ghost/api/admin/',
|
||||||
originURL
|
originURL
|
||||||
});
|
});
|
||||||
|
contentAPIAgent = new ContentAPITestAgent(app, {
|
||||||
|
apiURL: '/ghost/api/content/',
|
||||||
|
originURL
|
||||||
|
});
|
||||||
frontendAgent = supertest.agent(originURL);
|
frontendAgent = supertest.agent(originURL);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.message = `Unable to create test agent. ${error.message}`;
|
error.message = `Unable to create test agent. ${error.message}`;
|
||||||
|
@ -325,7 +331,8 @@ const getAgentsWithFrontend = async () => {
|
||||||
return {
|
return {
|
||||||
adminAgent,
|
adminAgent,
|
||||||
membersAgent,
|
membersAgent,
|
||||||
frontendAgent
|
frontendAgent,
|
||||||
|
contentAPIAgent
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue