Ghost/ghost/admin/tests/acceptance/members-activity-test.js
Kevin Ansfield eb2109499a Added initial setup of members activity feed
refs https://github.com/TryGhost/Team/issues/1277

- added `/members-activity` route with associated controller, template, and components behind labs flag
  - table component currently renders some dummy rows
- added navigation item to main menu
  - will use the currently set `?filter` query param unless clicked whilst already on the `/members-activity` screen in which case it will reset the query
- added link to dashboard members activity panel
- added link to member details activity panel
  - sets the filter param to `?filter=member:{member.id}` in preparation for the feed to be filtered to the member's activity
- updated the labs-flag test helper file to export both `enableLabsFlag()` and the new `disableLabsFlag()` so it's easier to test for flag-disabled functionality
2022-01-17 18:06:12 +00:00

55 lines
1.8 KiB
JavaScript

import {authenticateSession, invalidateSession} from 'ember-simple-auth/test-support';
import {currentURL} from '@ember/test-helpers';
import {describe, it} from 'mocha';
import {disableLabsFlag, enableLabsFlag} from '../helpers/labs-flag';
import {expect} from 'chai';
import {setupApplicationTest} from 'ember-mocha';
import {setupMirage} from 'ember-cli-mirage/test-support';
import {visit} from '../helpers/visit';
describe('Acceptance: Members activity', function () {
const hooks = setupApplicationTest();
setupMirage(hooks);
beforeEach(function () {
enableLabsFlag(this.server, 'membersActivityFeed');
});
it('redirects when not authenticated', async function () {
await invalidateSession();
await visit('/members-activity');
expect(currentURL()).to.equal('/signin');
});
it('redirects non-admins', async function () {
await invalidateSession();
const role = this.server.create('role', {name: 'Editor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/members-activity');
expect(currentURL()).to.equal('/site');
});
describe('as admin', function () {
beforeEach(async function () {
const role = this.server.create('role', {name: 'Administrator'});
this.server.create('user', {roles: [role]});
await authenticateSession();
});
it('renders', async function () {
await visit('/members-activity');
expect(currentURL()).to.equal('/members-activity');
});
it('requires feature flag', async function () {
disableLabsFlag(this.server, 'membersActivityFeed');
await visit('/members-activity');
expect(currentURL()).to.equal('/dashboard');
});
});
});