11import { StepNameType } from 'src/store/app'
22
3- const basicStepNames = [ 'start' , 'authors' ] as Array < StepNameType >
4- const advancedStepNames = [
3+ const stepNames = [
4+ 'start' ,
5+ 'authors' ,
56 'identifiers' ,
67 'related-resources' ,
78 'abstract' ,
89 'keywords' ,
910 'license' ,
1011 'version-specific'
1112] as Array < StepNameType >
12- const allStepNames = [ ...basicStepNames , ...advancedStepNames ]
1313
1414describe ( 'App navigation' , ( ) => {
1515 it ( 'should be able to go back through the logo button' , ( ) => {
@@ -18,70 +18,25 @@ describe('App navigation', () => {
1818 . click ( )
1919 cy . url ( ) . then ( ( e ) => expect ( e . endsWith ( '#/' ) ) . to . be . true )
2020 } )
21- describe ( 'during basic mode' , ( ) => {
22- it ( `should have ${ basicStepNames . length + 1 } steps on stepper` , ( ) => {
23- cy . visit ( '/start' )
24- cy . get ( '.q-stepper__tab' )
25- . should ( 'have.length' , basicStepNames . length + 1 )
26- } )
27- it ( 'should allow navigation using next/previous' , ( ) => {
28- cy . visit ( '/start' )
29- cy . dataCy ( 'btn-previous' )
30- . should ( 'not.be.visible' )
31- basicStepNames . forEach ( ( step ) => {
32- cy . url ( ) . should ( 'include' , `/${ step } ` )
33- cy . dataCy ( 'btn-next' )
34- . click ( )
35- cy . dataCy ( 'btn-previous' )
36- . should ( 'be.visible' )
37- } )
38- cy . url ( ) . should ( 'include' , '/finish' )
39- cy . dataCy ( 'btn-next' )
40- . should ( 'not.be.visible' )
41- Array . from ( basicStepNames ) . reverse ( ) . forEach ( ( step ) => {
42- cy . dataCy ( 'btn-previous' )
43- . click ( )
44- cy . url ( ) . should ( 'include' , `/${ step } ` )
45- cy . dataCy ( 'btn-next' )
46- . should ( 'be.visible' )
47- } )
48- cy . url ( ) . should ( 'include' , '/start' )
49- cy . dataCy ( 'btn-previous' )
50- . should ( 'not.be.visible' )
51- } )
52- it ( 'should be navigable through the stepper' , ( ) => {
53- [ 'finish' , ...basicStepNames , ...[ ...basicStepNames ] . reverse ( ) ] . forEach ( ( step ) => {
54- cy . visit ( step === 'start' ? '/authors' : `/${ step } ` )
55- cy . dataCy ( `step-${ step } ` )
56- . click ( )
57- cy . url ( )
58- . should ( 'contain' , `/${ step } ` )
59- } )
60- } )
61- } )
62-
63- describe ( 'during advanced mode' , ( ) => {
21+ describe ( 'basic checks' , ( ) => {
6422 beforeEach ( ( ) => {
6523 cy . visit ( '/start' )
6624 cy . dataCy ( 'input-title' )
6725 . type ( 'A' )
6826 cy . visit ( '/authors' )
6927 cy . dataCy ( 'btn-add-author' )
7028 . click ( )
71- cy . visit ( '/finish' )
72- cy . dataCy ( 'btn-add-more' )
73- . click ( )
7429 } )
75- it ( `should have ${ allStepNames . length + 1 } steps on stepper` , ( ) => {
30+ it ( `should have ${ stepNames . length + 1 } steps on stepper` , ( ) => {
7631 cy . visit ( '/start' )
7732 cy . get ( '.q-stepper__tab' )
78- . should ( 'have.length' , allStepNames . length + 1 )
33+ . should ( 'have.length' , stepNames . length + 1 )
7934 } )
8035 it ( 'should allow navigation using next/previous ' , ( ) => {
8136 cy . visit ( '/start' )
8237 cy . dataCy ( 'btn-previous' )
8338 . should ( 'not.be.visible' )
84- allStepNames . forEach ( ( step ) => {
39+ stepNames . forEach ( ( step ) => {
8540 cy . url ( ) . should ( 'include' , `/${ step } ` )
8641 cy . dataCy ( 'btn-next' )
8742 . click ( )
@@ -91,7 +46,7 @@ describe('App navigation', () => {
9146 cy . url ( ) . should ( 'include' , '/finish' )
9247 cy . dataCy ( 'btn-next' )
9348 . should ( 'not.be.visible' )
94- Array . from ( allStepNames ) . reverse ( ) . forEach ( ( step ) => {
49+ Array . from ( stepNames ) . reverse ( ) . forEach ( ( step ) => {
9550 cy . dataCy ( 'btn-previous' )
9651 . click ( )
9752 cy . url ( ) . should ( 'include' , `/${ step } ` )
@@ -103,7 +58,7 @@ describe('App navigation', () => {
10358 . should ( 'not.be.visible' )
10459 } )
10560 it ( 'should be navigable through the stepper' , ( ) => {
106- [ 'finish' , ...allStepNames , ...[ ...allStepNames ] . reverse ( ) ] . forEach ( ( step ) => {
61+ [ 'finish' , ...stepNames , ...[ ...stepNames ] . reverse ( ) ] . forEach ( ( step ) => {
10762 cy . visit ( step === 'start' ? '/authors' : `/${ step } ` )
10863 cy . dataCy ( `step-${ step } ` )
10964 . click ( )
@@ -113,7 +68,7 @@ describe('App navigation', () => {
11368 } )
11469 describe ( 'if there are no errors' , ( ) => {
11570 it ( 'should jump from step to finish when finish is clicked' , ( ) => {
116- allStepNames . forEach ( ( step ) => {
71+ stepNames . forEach ( ( step ) => {
11772 cy . visit ( `/${ step } ` )
11873 // The next test is just to make sure the page loaded without using cy.wait
11974 cy . get ( '#form-title' ) . should ( 'not.contain' , 'Congratulations' )
@@ -128,48 +83,19 @@ describe('App navigation', () => {
12883 } )
12984
13085 describe ( 'while navigating directly to a page' , ( ) => {
131- it ( `should have ${ allStepNames . length + 1 } steps and visible finish/next/previous` , ( ) => {
132- advancedStepNames . forEach ( ( step ) => {
86+ it ( `should have ${ stepNames . length + 1 } steps and visible finish/next/previous` , ( ) => {
87+ stepNames . forEach ( ( step ) => {
13388 cy . visit ( `/${ step } ` )
13489 cy . get ( '.q-stepper__tab' )
135- . should ( 'have.length' , allStepNames . length + 1 )
90+ . should ( 'have.length' , stepNames . length + 1 )
13691 cy . dataCy ( 'btn-finish' )
13792 . should ( 'be.visible' )
13893 cy . dataCy ( 'btn-next' )
13994 . should ( 'be.visible' )
14095 cy . dataCy ( 'btn-previous' )
141- . should ( 'be.visible' )
96+ . should ( ( step === 'start' ? 'not.' : '' ) + 'be.visible' )
14297 } )
14398 } )
144- it ( `should have ${ basicStepNames . length + 1 } steps, visible next/previous, and hidden finish` , ( ) => {
145- basicStepNames . forEach ( ( step ) => {
146- cy . visit ( `/${ step } ` )
147- cy . get ( '.q-stepper__tab' )
148- . should ( 'have.length' , basicStepNames . length + 1 )
149- cy . dataCy ( 'btn-finish' )
150- . should ( 'not.be.visible' )
151- cy . dataCy ( 'btn-next' )
152- . should ( 'be.visible' )
153- if ( step === 'start' ) {
154- cy . dataCy ( 'btn-previous' )
155- . should ( 'not.be.visible' )
156- } else {
157- cy . dataCy ( 'btn-previous' )
158- . should ( 'be.visible' )
159- }
160- } )
161- } )
162- it ( `should have ${ basicStepNames . length + 1 } steps, visible previous, hidden next/finish for step finish` , ( ) => {
163- cy . visit ( '/finish' )
164- cy . get ( '.q-stepper__tab' )
165- . should ( 'have.length' , basicStepNames . length + 1 )
166- cy . dataCy ( 'btn-finish' )
167- . should ( 'not.be.visible' )
168- cy . dataCy ( 'btn-next' )
169- . should ( 'not.be.visible' )
170- cy . dataCy ( 'btn-previous' )
171- . should ( 'be.visible' )
172- } )
17399 } )
174100
175101 describe ( 'On the screen Authors' , ( ) => {
0 commit comments