Ghost/ghost/admin/tests/acceptance/version-mismatch-test.js
Kevin Ansfield c16d633d4b New content screen prototype (#503)
refs https://github.com/TryGhost/Ghost/issues/7860

- remove preview pane from content screen
- add basic post status filters
- replace custom infinite scroll with ember-infinity and increase trigger threshold for improved scroll behaviour

Commits:
* basic content list + filter using existing infinite scroll and pagination
* swap our custom pagination + infinite loader for `ember-infinity`
* minor cleanups
* reset scroll position when changing filter
* fix tests
* remove client-side sorting step as we no longer have a live collection
* remove unused `mobile-index-route`
* add acceptance tests for content screen filters
2017-01-25 21:05:28 +01:00

122 lines
4.1 KiB
JavaScript

/* jshint expr:true */
import {
describe,
it,
beforeEach,
afterEach
} from 'mocha';
import {expect} from 'chai';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';
import {authenticateSession} from 'ghost-admin/tests/helpers/ember-simple-auth';
import {versionMismatchResponse} from 'ghost-admin/mirage/utils';
describe('Acceptance: Version Mismatch', function() {
let application;
beforeEach(function() {
application = startApp();
});
afterEach(function() {
destroyApp(application);
});
describe('logged in', function () {
beforeEach(function () {
let role = server.create('role', {name: 'Administrator'});
server.create('user', {roles: [role]});
return authenticateSession(application);
});
it('displays an alert and disables navigation when saving', function () {
server.createList('post', 3);
// mock the post save endpoint to return version mismatch
server.put('/posts/:id', versionMismatchResponse);
visit('/');
click('.posts-list li:nth-of-type(2) a'); // select second post
click('.js-publish-button'); // "Save post"
andThen(() => {
// has the refresh to update alert
expect(find('.gh-alert').length).to.equal(1);
expect(find('.gh-alert').text()).to.match(/refresh/);
});
// try navigating back to the content list
click('.gh-nav-main-content');
andThen(() => {
expect(currentPath()).to.equal('editor.edit');
});
});
it('displays alert and aborts the transition when navigating', function () {
// mock the tags endpoint to return version mismatch
server.get('/tags/', versionMismatchResponse);
visit('/');
click('.gh-nav-settings-tags');
andThen(() => {
// navigation is blocked on loading screen
expect(currentPath()).to.equal('settings.tags_loading');
// has the refresh to update alert
expect(find('.gh-alert').length).to.equal(1);
expect(find('.gh-alert').text()).to.match(/refresh/);
});
});
it('displays alert and aborts the transition when an ember-ajax error is thrown whilst navigating', function () {
server.get('/configuration/timezones/', versionMismatchResponse);
visit('/settings/tags');
click('.gh-nav-settings-general');
andThen(() => {
// navigation is blocked
expect(currentPath()).to.equal('settings.general_loading');
// has the refresh to update alert
expect(find('.gh-alert').length).to.equal(1);
expect(find('.gh-alert').text()).to.match(/refresh/);
});
});
it('can be triggered when passed in to a component', function () {
server.post('/subscribers/csv/', versionMismatchResponse);
visit('/subscribers');
click('.btn:contains("Import CSV")');
fileUpload('.fullscreen-modal input[type="file"]', ['test'], {name: 'test.csv'});
andThen(() => {
// alert is shown
expect(find('.gh-alert').length).to.equal(1);
expect(find('.gh-alert').text()).to.match(/refresh/);
});
});
});
describe('logged out', function () {
it('displays alert', function () {
server.post('/authentication/token', versionMismatchResponse);
visit('/signin');
fillIn('[name="identification"]', 'test@example.com');
fillIn('[name="password"]', 'password');
click('.btn-blue');
andThen(() => {
// has the refresh to update alert
expect(find('.gh-alert').length).to.equal(1);
expect(find('.gh-alert').text()).to.match(/refresh/);
});
});
});
});