Sped up comments and feedback tests by reusing Ghost app instance

refs https://ghost.slack.com/archives/C02G9E68C/p1668777066462859

Added a duplicate method to the mmebers agent, so we can reuse the same app instance and options, whenever we need multiple agents (each with their own cookies).
This commit is contained in:
Simon Backx 2022-11-18 14:58:35 +01:00
parent bb91bfd1ee
commit 2220686113
3 changed files with 9 additions and 2 deletions

View File

@ -184,7 +184,7 @@ describe('Comments API', function () {
before(async function () {
membersAgent = await agentProvider.getMembersAPIAgent();
membersAgent2 = await agentProvider.getMembersAPIAgent();
membersAgent2 = membersAgent.duplicate();
await fixtureManager.init('posts', 'members', 'comments');

View File

@ -10,7 +10,7 @@ describe('Members Feedback', function () {
before(async function () {
membersAgent = await agentProvider.getMembersAPIAgent();
membersAgent2 = await agentProvider.getMembersAPIAgent();
membersAgent2 = membersAgent.duplicate();
await fixtureManager.init('posts', 'members');
memberUuid = fixtureManager.get('members', 0).uuid;

View File

@ -12,8 +12,15 @@ const errors = require('@tryghost/errors');
* @param {String} options.originURL
*/
class MembersAPITestAgent extends TestAgent {
#bootOptions = null;
constructor(app, options) {
super(app, options);
this.#bootOptions = options;
}
duplicate() {
return new MembersAPITestAgent(this.app, this.#bootOptions);
}
async loginAs(email) {