From 3aa4cf3f2d58499bd719a0b4e5faaa1b9e6ce80b Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 28 Jan 2021 13:47:22 -0800 Subject: [PATCH] Add an acceptance test exercising errors from an HTTP response to a notification --- ui/tests/acceptance/task-detail-test.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ui/tests/acceptance/task-detail-test.js b/ui/tests/acceptance/task-detail-test.js index 1d548095b..8a842c808 100644 --- a/ui/tests/acceptance/task-detail-test.js +++ b/ui/tests/acceptance/task-detail-test.js @@ -223,7 +223,7 @@ module('Acceptance | task detail', function(hooks) { ); }); - test('when task restart fails, an error message is shown', async function(assert) { + test('when task restart fails (403), an ACL permissions error message is shown', async function(assert) { server.pretender.put('/v1/client/allocation/:id/restart', () => [403, {}, '']); await Task.restart.idle(); @@ -241,6 +241,22 @@ module('Acceptance | task detail', function(hooks) { assert.notOk(Task.inlineError.isShown, 'Inline error is no longer shown'); }); + test('when task restart fails (500), the error message from the API is piped through to the alert', async function(assert) { + const message = 'A plaintext error message'; + server.pretender.put('/v1/client/allocation/:id/restart', () => [500, {}, message]); + + await Task.restart.idle(); + await Task.restart.confirm(); + + assert.ok(Task.inlineError.isShown); + assert.ok(Task.inlineError.title.includes('Could Not Restart Task')); + assert.equal(Task.inlineError.message, message); + + await Task.inlineError.dismiss(); + + assert.notOk(Task.inlineError.isShown); + }); + test('exec button is present', async function(assert) { assert.ok(Task.execButton.isPresent); });