0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

use windowProxy to avoid mangling URL during team acceptance tests

This commit is contained in:
Kevin Ansfield 2017-11-10 14:19:20 +00:00
parent 71afd505fa
commit 719c2c3c6e
3 changed files with 21 additions and 2 deletions

View file

@ -2,6 +2,7 @@ import Controller from '@ember/controller';
import Ember from 'ember';
import boundOneWay from 'ghost-admin/utils/bound-one-way';
import isNumber from 'ghost-admin/utils/isNumber';
import windowProxy from 'ghost-admin/utils/window-proxy';
import {alias, and, not, or, readOnly} from '@ember/object/computed';
import {computed} from '@ember/object';
import {htmlSafe} from '@ember/string';
@ -182,7 +183,7 @@ export default Controller.extend({
newPath[newPath.length - 1] = model.get('slug');
newPath = newPath.join('/');
window.history.replaceState({path: newPath}, '', newPath);
windowProxy.replaceState({path: newPath}, '', newPath);
}
this.set('dirtyAttributes', false);

View file

@ -5,5 +5,9 @@ export default {
replaceLocation(url) {
window.location.replace(url);
},
replaceState(params, title, url) {
window.history.replaceState(params, title, url);
}
};

View file

@ -3,6 +3,7 @@ import ctrlOrCmd from 'ghost-admin/utils/ctrl-or-cmd';
import destroyApp from '../helpers/destroy-app';
import moment from 'moment';
import startApp from '../helpers/start-app';
import windowProxy from 'ghost-admin/utils/window-proxy';
import {Response} from 'ember-cli-mirage';
import {afterEach, beforeEach, describe, it} from 'mocha';
import {authenticateSession, invalidateSession} from '../helpers/ember-simple-auth';
@ -449,7 +450,7 @@ describe('Acceptance: Team', function () {
});
describe('existing user', function () {
let user;
let user, newLocation, originalReplaceState;
beforeEach(function () {
user = server.create('user', {
@ -458,6 +459,16 @@ describe('Acceptance: Team', function () {
facebook: 'test',
twitter: '@test'
});
originalReplaceState = windowProxy.replaceState;
windowProxy.replaceState = function (params, title, url) {
newLocation = url;
};
newLocation = undefined;
});
afterEach(function () {
windowProxy.replaceState = originalReplaceState;
});
it('input fields reset and validate correctly', async function () {
@ -511,6 +522,9 @@ describe('Acceptance: Team', function () {
expect(params.users[0].name).to.equal('Test User');
// check that the history state has been updated
expect(newLocation).to.equal('Test User');
await fillIn('[data-test-slug-input]', 'white space');
await triggerEvent('[data-test-slug-input]', 'blur');