File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 1
- <p id =" flash" class ={{ if this.message " shown" }} ...attributes>
1
+ <p id =" flash" class ={{ if this.message " shown" }} data-test-flash-message ...attributes>
2
2
{{ this.message }}
3
3
</p >
Original file line number Diff line number Diff line change @@ -53,4 +53,38 @@ module('Acceptance | Login', function(hooks) {
53
53
54
54
assert . dom ( '[data-test-user-menu] [data-test-toggle]' ) . hasText ( 'John Doe' ) ;
55
55
} ) ;
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
+ } ) ;
56
90
} ) ;
You can’t perform that action at this time.
0 commit comments