1
- import { click , currentRouteName , currentURL , visit , waitFor } from '@ember/test-helpers' ;
1
+ import { click , currentRouteName , currentURL , waitFor } from '@ember/test-helpers' ;
2
2
import { module , skip , test } from 'qunit' ;
3
3
4
4
import percySnapshot from '@percy/ember' ;
@@ -8,6 +8,7 @@ import { getPageTitle } from 'ember-page-title/test-support';
8
8
import { setupApplicationTest } from 'cargo/tests/helpers' ;
9
9
10
10
import axeConfig from '../axe-config' ;
11
+ import { visit } from '../helpers/visit-ignoring-abort' ;
11
12
12
13
module ( 'Acceptance | crate page' , function ( hooks ) {
13
14
setupApplicationTest ( hooks ) ;
@@ -80,6 +81,22 @@ module('Acceptance | crate page', function (hooks) {
80
81
await a11yAudit ( axeConfig ) ;
81
82
} ) ;
82
83
84
+ test ( 'unknown crate shows an error message' , async function ( assert ) {
85
+ await visit ( '/crates/nanomsg' ) ;
86
+ assert . equal ( currentURL ( ) , '/' ) ;
87
+ assert . dom ( '[data-test-notification-message]' ) . hasText ( "Crate 'nanomsg' does not exist" ) ;
88
+ } ) ;
89
+
90
+ test ( 'other crate loading error shows an error message' , async function ( assert ) {
91
+ this . server . get ( '/api/v1/crates/:crate_name' , { } , 500 ) ;
92
+
93
+ await visit ( '/crates/nanomsg' ) ;
94
+ assert . equal ( currentURL ( ) , '/' ) ;
95
+ assert
96
+ . dom ( '[data-test-notification-message]' )
97
+ . hasText ( "Loading data for the 'nanomsg' crate failed. Please try again later!" ) ;
98
+ } ) ;
99
+
83
100
test ( 'unknown versions fall back to latest version and show an error message' , async function ( assert ) {
84
101
this . server . create ( 'crate' , { name : 'nanomsg' } ) ;
85
102
this . server . create ( 'version' , { crateId : 'nanomsg' , num : '0.6.0' } ) ;
@@ -93,6 +110,21 @@ module('Acceptance | crate page', function (hooks) {
93
110
assert . dom ( '[data-test-notification-message]' ) . hasText ( "Version '0.7.0' of crate 'nanomsg' does not exist" ) ;
94
111
} ) ;
95
112
113
+ test ( 'other versions loading error shows an error message' , async function ( assert ) {
114
+ this . server . create ( 'crate' , { name : 'nanomsg' } ) ;
115
+ this . server . create ( 'version' , { crateId : 'nanomsg' , num : '0.6.0' } ) ;
116
+ this . server . create ( 'version' , { crateId : 'nanomsg' , num : '0.6.1' } ) ;
117
+
118
+ this . server . get ( '/api/v1/crates/:crate_name/versions' , { } , 500 ) ;
119
+
120
+ await visit ( '/' ) ;
121
+ await click ( '[data-test-just-updated] [data-test-crate-link="0"]' ) ;
122
+ assert . equal ( currentURL ( ) , '/' ) ;
123
+ assert
124
+ . dom ( '[data-test-notification-message]' )
125
+ . hasText ( "Loading data for the 'nanomsg' crate failed. Please try again later!" ) ;
126
+ } ) ;
127
+
96
128
test ( 'navigating to the all versions page' , async function ( assert ) {
97
129
this . server . loadFixtures ( ) ;
98
130
0 commit comments