0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Removed copy-pasta code form TestAgent

refs https://github.com/TryGhost/Toolbox/issues/158

- To make the development quicker the copy-paste code was left in the codebase but gave immediate smell. Removed it to stop bothering me every time I look at the related code :)
This commit is contained in:
Naz 2021-12-13 13:13:17 +04:00
parent 42cd78e05e
commit 868ae96100
2 changed files with 13 additions and 14 deletions

View file

@ -27,6 +27,7 @@ const mockUtils = require('./e2e-framework-mock-utils');
const boot = require('../../core/boot');
const TestAgent = require('./test-agent');
const db = require('./db-utils');
const DataGenerator = require('./fixtures/data-generator');
const startGhost = async () => {
/**
@ -116,11 +117,16 @@ const resetDb = async () => {
const getAgent = async (apiURL) => {
const app = await startGhost();
const originURL = configUtils.config.get('url');
const ownerUser = {
email: DataGenerator.Content.users[0].email,
password: DataGenerator.Content.users[0].password
};
return new TestAgent({
apiURL,
app,
originURL
originURL,
ownerUser
});
};

View file

@ -8,11 +8,15 @@ class TestAgent {
* @param {String} options.apiURL
* @param {String} options.originURL
* @param {Object} options.app Ghost express app instance
* @param {Object} options.ownerUser owner used for login
* @param {String} options.ownerUser.email
* @param {String} options.ownerUser.password
*/
constructor({apiURL, app, originURL}) {
constructor({apiURL, app, originURL, ownerUser}) {
this.API_URL = apiURL;
this.app = app;
this.originURL = originURL;
this.ownerUser = ownerUser;
this.request = supertest.agent(app);
}
@ -72,18 +76,7 @@ class TestAgent {
}
async loginAsOwner() {
// temporary copy-pasta
let user = {
// owner (owner is still id 1 because of permissions)
id: '1',
name: 'Joe Bloggs',
slug: 'joe-bloggs',
email: 'jbloggs@example.com',
password: 'Sl1m3rson99',
profile_image: 'https://example.com/super_photo.jpg'
};
await this.loginAs(user.email, user.password);
await this.loginAs(this.ownerUser.email, this.ownerUser.password);
}
}