File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,8 +88,17 @@ describe('My DSpace page', () => {
8888 // The Submission edit form tag should be visible
8989 cy . get ( 'ds-submission-edit' ) . should ( 'be.visible' ) ;
9090
91- // A Collection menu button should exist & its value should be the selected collection
92- cy . get ( '#collectionControlsMenuButton span' ) . should ( 'have.text' , TEST_SUBMIT_COLLECTION_NAME ) ;
91+ // A Collection menu button should exist(based on collection visibility) & its value should be the selected collection
92+ cy . get ( '#collectionControlsMenuButton span' )
93+ . should ( ( $span ) => {
94+ if ( $span . length > 0 ) {
95+ // If the element exists in the DOM (it's visible or read-only)
96+ expect ( $span ) . to . have . text ( TEST_SUBMIT_COLLECTION_NAME ) ;
97+ } else {
98+ // If the element doesn't exist in the DOM, the length will be 0
99+ expect ( $span ) . to . have . length ( 0 ) ;
100+ }
101+ } ) ;
93102
94103 // Now that we've created a submission, we'll test that we can go back and Edit it.
95104 // Get our Submission URL, to parse out the ID of this new submission
Original file line number Diff line number Diff line change @@ -16,8 +16,17 @@ describe('New Submission page', () => {
1616 // The Submission edit form tag should be visible
1717 cy . get ( 'ds-submission-edit' ) . should ( 'be.visible' ) ;
1818
19- // A Collection menu button should exist & it's value should be the selected collection
20- cy . get ( '#collectionControlsMenuButton span' ) . should ( 'have.text' , TEST_SUBMIT_COLLECTION_NAME ) ;
19+ // A Collection menu button should exist(if it's visible or read-only) & it's value should be the selected collection
20+ cy . get ( '#collectionControlsMenuButton span' )
21+ . should ( ( $span ) => {
22+ if ( $span . length > 0 ) {
23+ // If the element exists in the DOM (it's visible or read-only)
24+ expect ( $span ) . to . have . text ( TEST_SUBMIT_COLLECTION_NAME ) ;
25+ } else {
26+ // If the element doesn't exist in the DOM, the length will be 0
27+ expect ( $span ) . to . have . length ( 0 ) ;
28+ }
29+ } ) ;
2130
2231 // 4 sections should be visible by default
2332 cy . get ( 'div#section_traditionalpageone' ) . should ( 'be.visible' ) ;
You can’t perform that action at this time.
0 commit comments