github.com/zoomfoo/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/ui/tests/acceptance/application-errors-test.js (about) 1 import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance'; 2 import { test } from 'qunit'; 3 import ClientsList from 'nomad-ui/tests/pages/clients/list'; 4 import JobsList from 'nomad-ui/tests/pages/jobs/list'; 5 import Job from 'nomad-ui/tests/pages/jobs/detail'; 6 7 moduleForAcceptance('Acceptance | application errors ', { 8 beforeEach() { 9 server.create('agent'); 10 server.create('node'); 11 server.create('job'); 12 }, 13 }); 14 15 test('transitioning away from an error page resets the global error', function(assert) { 16 server.pretender.get('/v1/nodes', () => [500, {}, null]); 17 18 ClientsList.visit(); 19 20 andThen(() => { 21 assert.ok(ClientsList.error.isPresent, 'Application has errored'); 22 }); 23 24 JobsList.visit(); 25 26 andThen(() => { 27 assert.notOk(JobsList.error.isPresent, 'Application is no longer in an error state'); 28 }); 29 }); 30 31 test('the 403 error page links to the ACL tokens page', function(assert) { 32 const job = server.db.jobs[0]; 33 34 server.pretender.get(`/v1/job/${job.id}`, () => [403, {}, null]); 35 36 Job.visit({ id: job.id }); 37 38 andThen(() => { 39 assert.ok(Job.error.isPresent, 'Error message is shown'); 40 assert.equal(Job.error.title, 'Not Authorized', 'Error message is for 403'); 41 }); 42 43 andThen(() => { 44 Job.error.seekHelp(); 45 }); 46 47 andThen(() => { 48 assert.equal( 49 currentURL(), 50 '/settings/tokens', 51 'Error message contains a link to the tokens page' 52 ); 53 }); 54 }); 55 56 test('the no leader error state gets its own error message', function(assert) { 57 server.pretender.get('/v1/jobs', () => [500, {}, 'No cluster leader']); 58 59 JobsList.visit(); 60 61 andThen(() => { 62 assert.ok(JobsList.error.isPresent, 'An error is shown'); 63 assert.equal( 64 JobsList.error.title, 65 'No Cluster Leader', 66 'The error is specifically for the lack of a cluster leader' 67 ); 68 }); 69 });