0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-08 02:52:39 -05:00

Fixed Admin tests

no issue

- fixed eslint config so tests are correctly linted
- removed `.only` on stats tests preventing other tests from running
- removed unneccessary `return` from async setup functions
This commit is contained in:
Kevin Ansfield 2024-09-02 19:44:54 +01:00
parent f96313e9c2
commit cc72d368de
20 changed files with 70 additions and 57 deletions

View file

@ -51,5 +51,19 @@ module.exports = {
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error'
}
},
overrides: [{
files: 'tests/**/*.js',
env: {
embertest: true,
mocha: true
},
extends: [
'plugin:ghost/test'
],
rules: {
'ghost/ember/no-invalid-debug-function-arguments': 'off',
'ghost/mocha/no-setup-in-describe': 'off'
}
}]
};

View file

@ -1,10 +0,0 @@
/* eslint-env node */
module.exports = {
env: {
embertest: true,
mocha: true
},
rules: {
'ghost/ember/no-invalid-debug-function-arguments': 'off'
}
};

View file

@ -45,7 +45,7 @@ describe('Acceptance: Posts / Pages', function () {
let contributorRole = this.server.create('role', {name: 'Contributor'});
this.server.create('user', {roles: [contributorRole]});
return await authenticateSession();
await authenticateSession();
});
// NOTE: This test seems to fail if run AFTER the 'can change access' test in the 'as admin' section; router seems to fail, did not look into it further
@ -86,7 +86,7 @@ describe('Acceptance: Posts / Pages', function () {
authorPost = this.server.create('post', {authors: [author], status: 'published', title: 'Author Post'});
this.server.create('post', {authors: [admin], status: 'scheduled', title: 'Admin Post'});
return await authenticateSession();
await authenticateSession();
});
it('only fetches the author\'s posts', async function () {
@ -121,7 +121,7 @@ describe('Acceptance: Posts / Pages', function () {
// pages shouldn't appear in the list
this.server.create('page', {authors: [admin], status: 'published', title: 'Published Page'});
return await authenticateSession();
await authenticateSession();
});
describe('displays and filter posts', function () {
@ -694,7 +694,7 @@ describe('Acceptance: Posts / Pages', function () {
this.server.create('page', {authors: [admin], status: 'draft', title: 'Draft Page'});
this.server.create('page', {authors: [admin], status: 'scheduled', title: 'Scheduled Page'});
return await authenticateSession();
await authenticateSession();
});
it('can view pages', async function () {

View file

@ -19,7 +19,7 @@ describe('Acceptance: Custom Post Templates', function () {
let role = this.server.create('role', {name: 'Administrator'});
this.server.create('user', {roles: [role]});
return await authenticateSession();
await authenticateSession();
});
describe('with custom templates', function () {

View file

@ -16,7 +16,7 @@ describe('Acceptance: Dashboard', function () {
let role = this.server.create('role', {name: 'Administrator'});
this.server.create('user', {roles: [role]});
return await authenticateSession();
await authenticateSession();
});
it('can visit /dashboard', async function () {

View file

@ -118,7 +118,7 @@ describe('Acceptance: Editor', function () {
author = this.server.create('user', {roles: [role]});
this.server.loadFixtures('settings');
return await authenticateSession();
await authenticateSession();
});
describe('post settings menu', function () {

View file

@ -25,7 +25,7 @@ describe('Acceptance: Error Handling', function () {
let role = this.server.create('role', {name: 'Administrator'});
this.server.create('user', {roles: [role]});
return await authenticateSession();
await authenticateSession();
});
// TODO: can't replicate this with the Lexical editor... skip for now
@ -90,7 +90,7 @@ describe('Acceptance: Error Handling', function () {
let roles = this.server.schema.roles.where({name: 'Administrator'});
this.server.create('user', {roles});
return await authenticateSession();
await authenticateSession();
});
it('handles Ember Data HTML response', async function () {

View file

@ -37,7 +37,7 @@ describe('Acceptance: Members', function () {
let role = this.server.create('role', {name: 'Owner'});
this.server.create('user', {roles: [role]});
return await authenticateSession();
await authenticateSession();
});
it('it renders, can be navigated, can edit member', async function () {

View file

@ -42,7 +42,7 @@ describe('Acceptance: Member details', function () {
let role = this.server.create('role', {name: 'Owner'});
this.server.create('user', {roles: [role]});
return await authenticateSession();
await authenticateSession();
});
afterEach(function () {

View file

@ -29,7 +29,7 @@ describe('Acceptance: Members filtering', function () {
let role = this.server.create('role', {name: 'Owner'});
this.server.create('user', {roles: [role]});
return await authenticateSession();
await authenticateSession();
});
afterEach(function () {

View file

@ -17,7 +17,7 @@ describe('Acceptance: Members import', function () {
let role = this.server.create('role', {name: 'Owner'});
this.server.create('user', {roles: [role]});
return await authenticateSession();
await authenticateSession();
});
it('can open and close import modal', async function () {

View file

@ -20,11 +20,11 @@ describe('Acceptance: Mentions', function () {
beforeEach(async function () {
this.server.loadFixtures('configs');
this.server.loadFixtures('settings');
let role = this.server.create('role', {name: 'Administrator'});
this.server.create('user', {roles: [role]});
enableLabsFlag(this.server, 'webmentions');
return await authenticateSession();
await authenticateSession();
});
it('can render mentions page', async function () {
await visit('/mentions');

View file

@ -41,7 +41,7 @@
// enablePaidMembers(this.server);
// return await authenticateSession();
// await authenticateSession();
// });
// it('it renders, can be navigated, can edit offer', async function () {

View file

@ -22,7 +22,7 @@ describe('Acceptance: Onboarding', function () {
beforeEach(async function () {
let role = this.server.create('role', {name: 'Owner'});
this.server.create('user', {roles: [role], slug: 'owner'});
return await authenticateSession();
await authenticateSession();
});
it('dashboard does not show checklist by default', async function () {
@ -67,7 +67,7 @@ describe('Acceptance: Onboarding', function () {
beforeEach(async function () {
let role = this.server.create('role', {name: 'Administrator'});
this.server.create('user', {roles: [role], slug: 'admin'});
return await authenticateSession();
await authenticateSession();
});
it('dashboard doesn\'t show the checklist', async function () {

View file

@ -57,7 +57,7 @@ suites.forEach((suite) => {
suite.beforeEach.bind(this)();
return await authenticateSession();
await authenticateSession();
});
it('is using correct provider', async function () {

View file

@ -90,7 +90,7 @@
// // add a suspended user
// suspendedUser = this.server.create('user', {email: 'suspended@example.com', roles: [adminRole], status: 'inactive'});
// return await authenticateSession();
// await authenticateSession();
// });
// it('it renders and navigates correctly', async function () {
@ -913,7 +913,7 @@
// // add an expired invite
// this.server.create('invite', {expires: moment.utc().subtract(1, 'day').valueOf(), role: adminRole});
// return await authenticateSession();
// await authenticateSession();
// });
// describe('existing user', function () {
@ -972,7 +972,7 @@
// });
// });
// return await authenticateSession();
// await authenticateSession();
// });
// it('is redirected to user profile page', async function () {

View file

@ -6,7 +6,7 @@ import {invalidateSession} from 'ember-simple-auth/test-support';
import {setupApplicationTest} from 'ember-mocha';
import {setupMirage} from 'ember-cli-mirage/test-support';
describe.only('Acceptance: Stats', function () {
describe('Acceptance: Stats', function () {
const hooks = setupApplicationTest();
setupMirage(hooks);

View file

@ -43,7 +43,7 @@ describe('Acceptance: Tags', function () {
let role = this.server.create('role', {name: 'Administrator'});
this.server.create('user', {roles: [role]});
return await authenticateSession();
await authenticateSession();
});
it('lists public and internal tags separately', async function () {

View file

@ -71,31 +71,40 @@ describe('Integration: Component: gh-members-import-table', function () {
});
it('cannot navigate through data when only one data item is present', async function () {
it('renders members data with all the properties', async function () {
this.set('importData', [{
name: 'Egg',
email: 'egg@example.com'
}]);
this.set('importData', [{
name: 'Egg',
email: 'egg@example.com'
}]);
this.set('setMapping', () => {});
await render(hbs`
<GhMembersImportTable @importData={{this.importData}} />
`);
await render(hbs`
<GhMembersImportTable @data={{this.importData}} @setMapping={{this.setMapping}} />
`);
await click('[data-test-import-prev]');
expect(findAll('table tbody tr').length).to.equal(2);
expect(findAll('table tbody tr td')[0].textContent).to.equal('name');
expect(findAll('table tbody tr td')[1].textContent).to.equal('Egg');
expect(findAll('table tbody tr td')[2].textContent).to.match(/Not imported/);
expect(findAll('table tbody tr td')[3].textContent).to.equal('email');
expect(findAll('table tbody tr td')[4].textContent).to.equal('egg@example.com');
expect(findAll('table tbody tr td')[5].textContent).to.match(/Not imported/);
expect(findAll('table tbody tr').length).to.equal(2);
expect(findAll('table tbody tr td')[0].textContent).to.equal('name');
expect(findAll('table tbody tr td')[1].textContent).to.equal('Egg');
expect(findAll('table tbody tr td')[2].textContent).to.equal('email');
expect(findAll('table tbody tr td')[3].textContent).to.equal('egg@example.com');
await click('[data-test-import-next]');
await click('[data-test-import-next]');
expect(findAll('table tbody tr td')[0].textContent).to.equal('name');
expect(findAll('table tbody tr td')[1].textContent).to.equal('Egg');
expect(findAll('table tbody tr td')[2].textContent).to.match(/Not imported/);
expect(findAll('table tbody tr td')[3].textContent).to.equal('email');
expect(findAll('table tbody tr td')[4].textContent).to.equal('egg@example.com');
expect(findAll('table tbody tr td')[5].textContent).to.match(/Not imported/);
expect(findAll('table tbody tr').length).to.equal(2);
expect(findAll('table tbody tr td')[0].textContent).to.equal('name');
expect(findAll('table tbody tr td')[1].textContent).to.equal('Egg');
expect(findAll('table tbody tr td')[2].textContent).to.equal('email');
expect(findAll('table tbody tr td')[3].textContent).to.equal('egg@example.com');
});
await click('[data-test-import-prev]');
expect(findAll('table tbody tr td')[0].textContent).to.equal('name');
expect(findAll('table tbody tr td')[1].textContent).to.equal('Egg');
expect(findAll('table tbody tr td')[2].textContent).to.match(/Not imported/);
expect(findAll('table tbody tr td')[3].textContent).to.equal('email');
expect(findAll('table tbody tr td')[4].textContent).to.equal('egg@example.com');
expect(findAll('table tbody tr td')[5].textContent).to.match(/Not imported/);
});
});

View file

@ -128,7 +128,7 @@ describe('Integration: Service: member-import-validator', function () {
expect(result.stripe_customer_id).to.equal(undefined);
});
it('correctly detects only email mapping', async function () {
it('correctly detects email mapping', async function () {
this.owner.register('service:membersUtils', Service.extend({
isStripeEnabled: false
}));