Skip to content

Commit f9007c1

Browse files
committed
tests: Add "failed login" test case
1 parent 49ab5e3 commit f9007c1

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<p id="flash" class={{if this.message "shown"}} ...attributes>
1+
<p id="flash" class={{if this.message "shown"}} data-test-flash-message ...attributes>
22
{{this.message}}
33
</p>

tests/acceptance/login-test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,38 @@ module('Acceptance | Login', function(hooks) {
5353

5454
assert.dom('[data-test-user-menu] [data-test-toggle]').hasText('John Doe');
5555
});
56+
57+
test('failed login', async function(assert) {
58+
let deferred = defer();
59+
let fakeWindow = { closed: false };
60+
window.open = () => {
61+
deferred.resolve();
62+
return fakeWindow;
63+
};
64+
65+
await visit('/');
66+
assert.equal(currentURL(), '/');
67+
68+
await click('[data-test-login-link]');
69+
assert.equal(currentURL(), '/');
70+
71+
// wait for `window.open()` to be called
72+
await deferred.promise;
73+
74+
// simulate the response from the `github-authorize` route
75+
window.github_response = JSON.stringify({
76+
ok: false,
77+
data: {
78+
errors: [{ detail: 'Forbidden' }],
79+
},
80+
});
81+
82+
// simulate that the window has been closed by the `github-authorize` route
83+
fakeWindow.closed = true;
84+
85+
// wait for the error message to show up after the failed login
86+
await waitFor('[data-test-flash-message].shown');
87+
88+
assert.dom('[data-test-flash-message]').hasText('Failed to log in: Forbidden');
89+
});
5690
});

0 commit comments

Comments
 (0)