2017-10-12 19:35:00 +00:00
|
|
|
import { find, visit } from 'ember-native-dom-helpers';
|
|
|
|
import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance';
|
|
|
|
import { test } from 'qunit';
|
|
|
|
|
|
|
|
moduleForAcceptance('Acceptance | application errors ', {
|
|
|
|
beforeEach() {
|
|
|
|
server.create('agent');
|
|
|
|
server.create('node');
|
|
|
|
server.create('job');
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
test('transitioning away from an error page resets the global error', function(assert) {
|
2017-10-12 23:56:20 +00:00
|
|
|
server.pretender.get('/v1/nodes', () => [500, {}, null]);
|
2017-10-12 19:35:00 +00:00
|
|
|
|
2017-10-28 01:23:41 +00:00
|
|
|
visit('/clients');
|
2017-10-12 19:35:00 +00:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-01-05 20:59:36 +00:00
|
|
|
assert.ok(find('[data-test-error]'), 'Application has errored');
|
2017-10-12 19:35:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
visit('/jobs');
|
|
|
|
|
|
|
|
andThen(() => {
|
2018-01-05 20:59:36 +00:00
|
|
|
assert.notOk(find('[data-test-error]'), 'Application is no longer in an error state');
|
2017-10-12 19:35:00 +00:00
|
|
|
});
|
|
|
|
});
|
2017-10-12 23:56:20 +00:00
|
|
|
|
|
|
|
test('the 403 error page links to the ACL tokens page', function(assert) {
|
|
|
|
const job = server.db.jobs[0];
|
|
|
|
|
|
|
|
server.pretender.get(`/v1/job/${job.id}`, () => [403, {}, null]);
|
|
|
|
|
|
|
|
visit(`/jobs/${job.id}`);
|
|
|
|
|
|
|
|
andThen(() => {
|
2018-01-05 20:59:36 +00:00
|
|
|
assert.ok(find('[data-test-error]'), 'Error message is shown');
|
2017-10-12 23:56:20 +00:00
|
|
|
assert.equal(
|
2018-01-05 20:59:36 +00:00
|
|
|
find('[data-test-error] .title').textContent,
|
2017-10-12 23:56:20 +00:00
|
|
|
'Not Authorized',
|
|
|
|
'Error message is for 403'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
andThen(() => {
|
2018-01-05 20:59:36 +00:00
|
|
|
click('[data-test-error-acl-link]');
|
2017-10-12 23:56:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(
|
|
|
|
currentURL(),
|
|
|
|
'/settings/tokens',
|
|
|
|
'Error message contains a link to the tokens page'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|