Skip to content

Commit

Permalink
Add an acceptance test exercising errors from an HTTP response to a n…
Browse files Browse the repository at this point in the history
…otification
  • Loading branch information
DingoEatingFuzz committed Jan 28, 2021
1 parent 5dfa556 commit 3aa4cf3
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion ui/tests/acceptance/task-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
});
Expand Down

1 comment on commit 3aa4cf3

@backspace
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, I love it! 🤩

Please sign in to comment.