From 6bbf3ac9927d08a1170d464478c2b61a4e9fa34a Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 12 Oct 2017 12:35:00 -0700 Subject: [PATCH] Allow users to escape error pages with the back button --- ui/app/routes/application.js | 1 + .../acceptance/application-errors-test.js | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 ui/tests/acceptance/application-errors-test.js diff --git a/ui/app/routes/application.js b/ui/app/routes/application.js index 1b6fe6335..f84961641 100644 --- a/ui/app/routes/application.js +++ b/ui/app/routes/application.js @@ -11,6 +11,7 @@ export default Route.extend({ actions: { didTransition() { + this.controllerFor('application').set('error', null); window.scrollTo(0, 0); }, diff --git a/ui/tests/acceptance/application-errors-test.js b/ui/tests/acceptance/application-errors-test.js new file mode 100644 index 000000000..385961325 --- /dev/null +++ b/ui/tests/acceptance/application-errors-test.js @@ -0,0 +1,27 @@ +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) { + server.pretender.get('/v1/nodes', () => [403, {}, null]); + + visit('/nodes'); + + andThen(() => { + assert.ok(find('.error-message'), 'Application has errored'); + }); + + visit('/jobs'); + + andThen(() => { + assert.notOk(find('.error-message'), 'Application is no longer in an error state'); + }); +});