mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Merge pull request #5944 from kevinansfield/fix-ember-test-failures
Fix random ember test failures
This commit is contained in:
commit
da78de8f38
4 changed files with 68 additions and 94 deletions
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"framework": "qunit",
|
"framework": "mocha",
|
||||||
"test_page": "tests/index.html?hidepassed",
|
"test_page": "tests/index.html?hidepassed",
|
||||||
"disable_watching": true,
|
"disable_watching": true,
|
||||||
"launch_in_ci": [
|
"launch_in_ci": [
|
||||||
|
|
|
@ -141,8 +141,8 @@ describe('Acceptance: Settings - Navigation', function () {
|
||||||
|
|
||||||
it('redirects to team page when authenticated as author', function () {
|
it('redirects to team page when authenticated as author', function () {
|
||||||
run(() => {
|
run(() => {
|
||||||
let role = store.createRecord('role', {name: 'Author'});
|
let role = store.push('role', {id: 1, name: 'Author'});
|
||||||
store.createRecord('user', {id: 'me', roles: [role]});
|
store.push('user', {id: 'me', roles: [role]});
|
||||||
});
|
});
|
||||||
|
|
||||||
authenticateSession();
|
authenticateSession();
|
||||||
|
@ -156,8 +156,8 @@ describe('Acceptance: Settings - Navigation', function () {
|
||||||
describe('when logged in', function () {
|
describe('when logged in', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
run(() => {
|
run(() => {
|
||||||
let role = store.createRecord('role', {name: 'Administrator'});
|
let role = store.push('role', {id: 1, name: 'Administrator'});
|
||||||
store.createRecord('user', {id: 'me', roles: [role]});
|
store.push('user', {id: 'me', roles: [role]});
|
||||||
});
|
});
|
||||||
|
|
||||||
authenticateSession();
|
authenticateSession();
|
||||||
|
@ -185,16 +185,20 @@ describe('Acceptance: Settings - Navigation', function () {
|
||||||
// TODO: Test for successful save here once we have a visual
|
// TODO: Test for successful save here once we have a visual
|
||||||
// indication. For now we know the save happened because
|
// indication. For now we know the save happened because
|
||||||
// Pretender doesn't complain about an unknown URL
|
// Pretender doesn't complain about an unknown URL
|
||||||
expect($('.error').length).to.equal(0);
|
|
||||||
expect($('.gh-alert').length).to.equal(0);
|
// don't test against .error directly as it will pick up failed
|
||||||
|
// tests "pre.error" elements
|
||||||
|
expect($('span.error').length, 'error fields count').to.equal(0);
|
||||||
|
expect($('.gh-alert').length, 'alerts count').to.equal(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('clears unsaved settings when navigating away', function () {
|
it('clears unsaved settings when navigating away', function () {
|
||||||
visit('/settings/navigation');
|
visit('/settings/navigation');
|
||||||
|
fillIn('.gh-blognav-label:first input', 'Test');
|
||||||
|
triggerEvent('.gh-blognav-label:first input', 'blur');
|
||||||
|
|
||||||
andThen(function () {
|
andThen(function () {
|
||||||
$('.gh-blognav-label input').val('Test');
|
|
||||||
expect($('.gh-blognav-label:first input').val()).to.equal('Test');
|
expect($('.gh-blognav-label:first input').val()).to.equal('Test');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,3 +2,10 @@ import resolver from './helpers/resolver';
|
||||||
import { setResolver } from 'ember-mocha';
|
import { setResolver } from 'ember-mocha';
|
||||||
|
|
||||||
setResolver(resolver);
|
setResolver(resolver);
|
||||||
|
|
||||||
|
/* jshint ignore:start */
|
||||||
|
mocha.setup({
|
||||||
|
timeout: 5000,
|
||||||
|
slow: 500
|
||||||
|
});
|
||||||
|
/* jshint ignore:end */
|
||||||
|
|
|
@ -4,6 +4,8 @@ import {
|
||||||
it
|
it
|
||||||
} from 'ember-mocha';
|
} from 'ember-mocha';
|
||||||
|
|
||||||
|
const { run } = Ember;
|
||||||
|
|
||||||
describeModel(
|
describeModel(
|
||||||
'user',
|
'user',
|
||||||
'Unit: Model: user',
|
'Unit: Model: user',
|
||||||
|
@ -26,25 +28,16 @@ describeModel(
|
||||||
expect(model.get('active')).to.be.ok;
|
expect(model.get('active')).to.be.ok;
|
||||||
|
|
||||||
['warn-1', 'warn-2', 'warn-3', 'warn-4', 'locked'].forEach(function (status) {
|
['warn-1', 'warn-2', 'warn-3', 'warn-4', 'locked'].forEach(function (status) {
|
||||||
Ember.run(function () {
|
run(() => { model.set('status', status); });
|
||||||
model.set('status', status);
|
|
||||||
|
|
||||||
expect(model.get('status')).to.be.ok;
|
expect(model.get('status')).to.be.ok;
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
Ember.run(function () {
|
|
||||||
model.set('status', 'inactive');
|
|
||||||
|
|
||||||
|
run(() => { model.set('status', 'inactive'); });
|
||||||
expect(model.get('active')).to.not.be.ok;
|
expect(model.get('active')).to.not.be.ok;
|
||||||
});
|
|
||||||
|
|
||||||
Ember.run(function () {
|
|
||||||
model.set('status', 'invited');
|
|
||||||
|
|
||||||
|
run(() => { model.set('status', 'invited'); });
|
||||||
expect(model.get('active')).to.not.be.ok;
|
expect(model.get('active')).to.not.be.ok;
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('invited property is correct', function () {
|
it('invited property is correct', function () {
|
||||||
var model = this.subject({
|
var model = this.subject({
|
||||||
|
@ -53,24 +46,15 @@ describeModel(
|
||||||
|
|
||||||
expect(model.get('invited')).to.be.ok;
|
expect(model.get('invited')).to.be.ok;
|
||||||
|
|
||||||
Ember.run(function () {
|
run(() => { model.set('status', 'invited-pending'); });
|
||||||
model.set('status', 'invited-pending');
|
|
||||||
|
|
||||||
expect(model.get('invited')).to.be.ok;
|
expect(model.get('invited')).to.be.ok;
|
||||||
});
|
|
||||||
|
|
||||||
Ember.run(function () {
|
|
||||||
model.set('status', 'active');
|
|
||||||
|
|
||||||
|
run(() => { model.set('status', 'active'); });
|
||||||
expect(model.get('invited')).to.not.be.ok;
|
expect(model.get('invited')).to.not.be.ok;
|
||||||
});
|
|
||||||
|
|
||||||
Ember.run(function () {
|
|
||||||
model.set('status', 'inactive');
|
|
||||||
|
|
||||||
|
run(() => { model.set('status', 'inactive'); });
|
||||||
expect(model.get('invited')).to.not.be.ok;
|
expect(model.get('invited')).to.not.be.ok;
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('pending property is correct', function () {
|
it('pending property is correct', function () {
|
||||||
var model = this.subject({
|
var model = this.subject({
|
||||||
|
@ -79,100 +63,79 @@ describeModel(
|
||||||
|
|
||||||
expect(model.get('pending')).to.be.ok;
|
expect(model.get('pending')).to.be.ok;
|
||||||
|
|
||||||
Ember.run(function () {
|
run(() => { model.set('status', 'invited'); });
|
||||||
model.set('status', 'invited');
|
|
||||||
|
|
||||||
expect(model.get('pending')).to.not.be.ok;
|
expect(model.get('pending')).to.not.be.ok;
|
||||||
});
|
|
||||||
|
|
||||||
Ember.run(function () {
|
|
||||||
model.set('status', 'inactive');
|
|
||||||
|
|
||||||
|
run(() => { model.set('status', 'inactive'); });
|
||||||
expect(model.get('pending')).to.not.be.ok;
|
expect(model.get('pending')).to.not.be.ok;
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('role property is correct', function () {
|
it('role property is correct', function () {
|
||||||
var model,
|
var model = this.subject();
|
||||||
role;
|
|
||||||
|
|
||||||
model = this.subject();
|
|
||||||
|
|
||||||
Ember.run(this, function () {
|
|
||||||
role = this.store().createRecord('role', {name: 'Author'});
|
|
||||||
|
|
||||||
|
run(() => {
|
||||||
|
let role = this.store().push('role', {id: 1, name: 'Author'});
|
||||||
model.get('roles').pushObject(role);
|
model.get('roles').pushObject(role);
|
||||||
|
});
|
||||||
expect(model.get('role.name')).to.equal('Author');
|
expect(model.get('role.name')).to.equal('Author');
|
||||||
});
|
|
||||||
|
|
||||||
Ember.run(this, function () {
|
|
||||||
role = this.store().createRecord('role', {name: 'Editor'});
|
|
||||||
|
|
||||||
|
run(() => {
|
||||||
|
let role = this.store().push('role', {id: 1, name: 'Editor'});
|
||||||
model.set('role', role);
|
model.set('role', role);
|
||||||
|
|
||||||
expect(model.get('role.name')).to.equal('Editor');
|
|
||||||
});
|
});
|
||||||
|
expect(model.get('role.name')).to.equal('Editor');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('isAuthor property is correct', function () {
|
it('isAuthor property is correct', function () {
|
||||||
var model = this.subject();
|
var model = this.subject();
|
||||||
|
|
||||||
Ember.run(this, function () {
|
run(() => {
|
||||||
var role = this.store().createRecord('role', {name: 'Author'});
|
let role = this.store().push('role', {id: 1, name: 'Author'});
|
||||||
|
|
||||||
model.set('role', role);
|
model.set('role', role);
|
||||||
|
});
|
||||||
expect(model.get('isAuthor')).to.be.ok;
|
expect(model.get('isAuthor')).to.be.ok;
|
||||||
expect(model.get('isEditor')).to.not.be.ok;
|
expect(model.get('isEditor')).to.not.be.ok;
|
||||||
expect(model.get('isAdmin')).to.not.be.ok;
|
expect(model.get('isAdmin')).to.not.be.ok;
|
||||||
expect(model.get('isOwner')).to.not.be.ok;
|
expect(model.get('isOwner')).to.not.be.ok;
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('isEditor property is correct', function () {
|
it('isEditor property is correct', function () {
|
||||||
var model = this.subject();
|
var model = this.subject();
|
||||||
|
|
||||||
Ember.run(this, function () {
|
run(() => {
|
||||||
var role = this.store().createRecord('role', {name: 'Editor'});
|
let role = this.store().push('role', {id: 1, name: 'Editor'});
|
||||||
|
|
||||||
model.set('role', role);
|
model.set('role', role);
|
||||||
|
});
|
||||||
expect(model.get('isEditor')).to.be.ok;
|
expect(model.get('isEditor')).to.be.ok;
|
||||||
expect(model.get('isAuthor')).to.not.be.ok;
|
expect(model.get('isAuthor')).to.not.be.ok;
|
||||||
expect(model.get('isAdmin')).to.not.be.ok;
|
expect(model.get('isAdmin')).to.not.be.ok;
|
||||||
expect(model.get('isOwner')).to.not.be.ok;
|
expect(model.get('isOwner')).to.not.be.ok;
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('isAdmin property is correct', function () {
|
it('isAdmin property is correct', function () {
|
||||||
var model = this.subject();
|
var model = this.subject();
|
||||||
|
|
||||||
Ember.run(this, function () {
|
run(() => {
|
||||||
var role = this.store().createRecord('role', {name: 'Administrator'});
|
let role = this.store().push('role', {id: 1, name: 'Administrator'});
|
||||||
|
|
||||||
model.set('role', role);
|
model.set('role', role);
|
||||||
|
});
|
||||||
expect(model.get('isAdmin')).to.be.ok;
|
expect(model.get('isAdmin')).to.be.ok;
|
||||||
expect(model.get('isAuthor')).to.not.be.ok;
|
expect(model.get('isAuthor')).to.not.be.ok;
|
||||||
expect(model.get('isEditor')).to.not.be.ok;
|
expect(model.get('isEditor')).to.not.be.ok;
|
||||||
expect(model.get('isOwner')).to.not.be.ok;
|
expect(model.get('isOwner')).to.not.be.ok;
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('isOwner property is correct', function () {
|
it('isOwner property is correct', function () {
|
||||||
var model = this.subject();
|
var model = this.subject();
|
||||||
|
|
||||||
Ember.run(this, function () {
|
run(() => {
|
||||||
var role = this.store().createRecord('role', {name: 'Owner'});
|
let role = this.store().push('role', {id: 1, name: 'Owner'});
|
||||||
|
|
||||||
model.set('role', role);
|
model.set('role', role);
|
||||||
|
});
|
||||||
expect(model.get('isOwner')).to.be.ok;
|
expect(model.get('isOwner')).to.be.ok;
|
||||||
expect(model.get('isAuthor')).to.not.be.ok;
|
expect(model.get('isAuthor')).to.not.be.ok;
|
||||||
expect(model.get('isAdmin')).to.not.be.ok;
|
expect(model.get('isAdmin')).to.not.be.ok;
|
||||||
expect(model.get('isEditor')).to.not.be.ok;
|
expect(model.get('isEditor')).to.not.be.ok;
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue