Commit 2fa095f 1 parent 1d4b4b8 commit 2fa095f Copy full SHA for 2fa095f
File tree 1 file changed +24
-8
lines changed
1 file changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -23,20 +23,36 @@ describe('API Test', () => {
23
23
24
24
it ( 'should include at least 1 element in each module' , ( ) => {
25
25
cy . get ( '.api-group' ) . each ( ( $el ) => {
26
- cy . wrap ( $el ) . get ( 'li a[href]' ) . should ( 'have.length.above' , 0 ) ;
26
+ cy . wrap ( $el ) . within ( ( ) => {
27
+ cy . get ( 'li a[href]' ) . should ( 'have.length.above' , 0 ) ;
28
+ } ) ;
27
29
} ) ;
28
30
} ) ;
29
31
30
32
it ( 'should not have dead links' , ( ) => {
33
+ const checked = new Set < string > ( ) ;
31
34
cy . get ( '.api-group li' ) . each ( ( $el ) => {
32
- const text = $el . find ( 'a' ) . text ( ) ;
33
- const link = $el . find ( 'a' ) . attr ( 'href' ) ;
35
+ const anchor = $el . find ( 'a' ) ;
36
+ const text = anchor . text ( ) ;
37
+ const link = anchor . attr ( 'href' ) . split ( '#' ) [ 0 ] ;
38
+ if ( checked . has ( link ) ) {
39
+ return ;
40
+ }
34
41
35
- cy . request ( `/api/${ link } ` ) . should ( ( response ) => {
36
- expect ( response . status ) . to . eq ( 200 ) ;
37
- expect ( response . body ) . to . include ( text ) ;
38
- expect ( response . body ) . to . not . include ( 'PAGE NOT FOUND' ) ;
39
- } ) ;
42
+ checked . add ( link ) ;
43
+
44
+ cy . request ( {
45
+ method : 'HEAD' ,
46
+ url : `/api/${ link } ` ,
47
+ failOnStatusCode : false ,
48
+ } )
49
+ . should ( ( { status } ) => {
50
+ expect (
51
+ status ,
52
+ `${ text } to have a working link: /api/${ link } `
53
+ ) . to . eq ( 200 ) ;
54
+ } )
55
+ . end ( ) ;
40
56
} ) ;
41
57
} ) ;
42
58
} ) ;
You can’t perform that action at this time.
0 commit comments