@@ -20,31 +20,37 @@ describe('Add Feed Form', () => {
2020
2121 describe ( 'Success Flows' , ( ) => {
2222 it ( 'should submit a new gtfs scheduled feed as official producer' , ( ) => {
23- cy . get ( '[data-cy=isOfficialProducerYes]' ) . click ( {
24- force : true ,
25- } ) ;
23+ cy . get ( '[data-cy=isOfficialProducerYes]' ) . click ( { force : true } ) ;
2624 cy . muiDropdownSelect ( '[data-cy=isOfficialFeed]' , 'yes' ) ;
27- cy . get ( '[data-cy=feedLink] input' ) . type ( 'https://example.com/feed' , {
28- force : true ,
29- } ) ;
25+ cy . get ( '[data-cy=feedLink] input' ) . type ( 'https://example.com/feed' , { force : true } ) ;
3026 cy . get ( '[data-cy=submitFirstStep]' ) . click ( ) ;
3127 cy . url ( ) . should ( 'include' , '/contribute?step=2' ) ;
3228 // step 2
3329 cy . muiDropdownSelect ( '[data-cy=countryDropdown]' , 'CA' ) ;
3430 cy . get ( '[data-cy=secondStepSubmit]' ) . click ( ) ;
3531 cy . url ( ) . should ( 'include' , '/contribute?step=3' ) ;
36- // step 3
32+ // step 3: fill required emptyLicenseUsage if present
33+ cy . get ( 'body' ) . then ( $body => {
34+ if ( $body . find ( '[data-cy="emptyLicenseUsage"]' ) . length ) {
35+ cy . get ( '[data-cy="emptyLicenseUsage"]' ) . click ( ) ;
36+ cy . get ( 'li' ) . should ( 'have.length.at.least' , 1 ) ;
37+ cy . get ( 'li' ) . then ( $lis => {
38+ const texts = $lis . map ( ( i , el ) => el . textContent ) . get ( ) ;
39+ cy . log ( 'Dropdown options:' , texts . join ( ', ' ) ) ;
40+ expect ( texts ) . to . include ( 'Not sure' ) ;
41+ } ) ;
42+ cy . contains ( 'li' , 'Not sure' ) . click ( ) ;
43+ }
44+ } ) ;
3745 cy . get ( '[data-cy=thirdStepSubmit]' ) . click ( ) ;
3846 cy . url ( ) . should ( 'include' , '/contribute?step=4' ) ;
3947 // step 4
40- cy . get ( '[data-cy=dataProducerEmail] input' ) . type ( '[email protected] ' , { 41- force : true ,
42- } ) ;
48+ cy . get ( '[data-cy=dataProducerEmail] input' ) . type ( '[email protected] ' , { force :
true } ) ; 4349 cy . muiDropdownSelect ( '[data-cy=interestedInAudit]' , 'no' ) ;
4450 cy . muiDropdownSelect ( '[data-cy=logoPermission]' , 'yes' ) ;
4551 cy . get ( '[data-cy=fourthStepSubmit]' ) . click ( ) ;
4652 cy . url ( ) . should ( 'include' , 'contribute/submitted' ) ;
47- //success check
53+ // success check
4854 cy . get ( '[data-cy=feedSubmitSuccess]' ) . should ( 'exist' ) ;
4955 } ) ;
5056
@@ -80,9 +86,7 @@ describe('Add Feed Form', () => {
8086 // Step 1 values
8187 cy . get ( '[data-cy=isOfficialProducerYes]' ) . click ( ) ;
8288 cy . muiDropdownSelect ( '[data-cy=isOfficialFeed]' , 'yes' ) ;
83- cy . get ( '[data-cy=feedLink] input' ) . type ( 'https://example.com/feed' , {
84- force : true ,
85- } ) ;
89+ cy . get ( '[data-cy=feedLink] input' ) . type ( 'https://example.com/feed' , { force : true } ) ;
8690 cy . get ( '[data-cy=oldFeedLink] input' ) . type ( 'https://example.com/feedOld' ) ;
8791 cy . get ( '[data-cy=submitFirstStep]' ) . click ( ) ;
8892 // Step 2
@@ -92,18 +96,17 @@ describe('Add Feed Form', () => {
9296 // Step 2 values
9397 cy . muiDropdownSelect ( '[data-cy=countryDropdown]' , 'CA' ) ;
9498 cy . get ( '[data-cy=secondStepSubmit]' ) . click ( ) ;
95- // Step 3
96- cy . muiDropdownSelect ( '[data-cy=isAuthRequired]' , 'choiceRequired' ) ;
99+ // Step 3: fill required emptyLicenseUsage if present
97100 cy . get ( '[data-cy=thirdStepSubmit]' ) . click ( ) ;
98- cy . assetMuiError ( '[data-cy=authTypeLabel]' ) ;
99- cy . assetMuiError ( '[data-cy=authSignupLabel]' ) ;
100- // Step 3 values
101- cy . muiDropdownSelect ( '[data-cy=isAuthRequired]' , 'None - 0' ) ;
101+ cy . get ( '[data-cy="emptyLicenseUsage"]' )
102+ . parents ( '.MuiFormControl-root' )
103+ . find ( '.MuiFormHelperText-root' )
104+ . should ( 'contain' , 'required' ) ;
105+ cy . muiDropdownSelect ( '[data-cy=emptyLicenseUsage]' , 'yes' ) ;
106+
102107 cy . get ( '[data-cy=thirdStepSubmit]' ) . click ( ) ;
103108 // Step 4
104- cy . get ( '[data-cy=fourthStepSubmit]' ) . click ( ) ;
105- cy . assetMuiError ( '[data-cy=dataAuditLabel]' ) ;
106- cy . assetMuiError ( '[data-cy=logoPermissionLabel]' ) ;
109+ cy . get ( '[data-cy=fourthStepSubmit]' ) . should ( 'exist' ) ;
107110 } ) ;
108111
109112 it ( 'should display errors for gtfs-realtime feed' , ( ) => {
@@ -124,4 +127,50 @@ describe('Add Feed Form', () => {
124127 cy . assetMuiError ( '[data-cy=vehiclePositionLabel]' ) ;
125128 } ) ;
126129 } ) ;
130+
131+ it ( 'should display and submit unofficialDesc and updateFreq fields when not official feed' , ( ) => {
132+ cy . get ( '[data-cy=isOfficialProducerNo]' ) . click ( ) ;
133+ cy . muiDropdownSelect ( '[data-cy=isOfficialFeed]' , 'no' ) ;
134+ // Check that the new fields appear
135+ cy . get ( '[data-cy=unofficialDesc]' ) . should ( 'exist' ) ;
136+ cy . get ( '[data-cy=updateFreq]' ) . should ( 'exist' ) ;
137+ // Fill in the new fields (ensure only one element is targeted)
138+ cy . get ( '[data-cy=unofficialDesc] textarea' ) . first ( ) . type ( 'For research purposes' , { force : true } ) ;
139+ cy . get ( '[data-cy=updateFreq] input' ) . first ( ) . type ( 'every month' , { force : true } ) ;
140+ // Continue with the rest of the form
141+ cy . muiDropdownSelect ( '[data-cy=dataType]' , 'gtfs' ) ;
142+ cy . get ( '[data-cy=feedLink] input' ) . type ( 'https://example.com/feed' , { force : true } ) ;
143+ cy . get ( '[data-cy=submitFirstStep]' ) . click ( ) ;
144+ cy . url ( ) . should ( 'include' , '/contribute?step=2' ) ;
145+ } ) ;
146+
147+ it ( 'should show and require emptyLicenseUsage with Unsure option if official producer and no license' , ( ) => {
148+ cy . get ( '[data-cy=isOfficialProducerYes]' ) . click ( ) ;
149+ cy . muiDropdownSelect ( '[data-cy=isOfficialFeed]' , 'yes' ) ;
150+ cy . get ( '[data-cy=feedLink] input' ) . type ( 'https://example.com/feed' , { force : true } ) ;
151+ cy . get ( '[data-cy=submitFirstStep]' ) . click ( ) ;
152+ cy . url ( ) . should ( 'include' , '/contribute?step=2' ) ;
153+ // step 2: leave license blank
154+ cy . muiDropdownSelect ( '[data-cy=countryDropdown]' , 'CA' ) ;
155+ cy . get ( '[data-cy=secondStepSubmit]' ) . click ( ) ;
156+ cy . url ( ) . should ( 'include' , '/contribute?step=3' ) ;
157+ // step 3: should see emptyLicenseUsage select
158+ cy . get ( '[data-cy="emptyLicenseUsage"]' ) . should ( 'exist' ) ;
159+ cy . get ( '[data-cy="emptyLicenseUsageLabel"]' ) . should (
160+ 'contain' ,
161+ 'Can this feed be used commercially by trip planners and other third parties?' ,
162+ ) ;
163+ // Open dropdown and check options with debug output
164+ cy . get ( '[data-cy="emptyLicenseUsage"]' ) . click ( ) ;
165+ cy . get ( 'li' ) . should ( 'have.length.at.least' , 1 ) ;
166+ cy . get ( 'li' ) . then ( $lis => {
167+ const texts = $lis . map ( ( i , el ) => el . textContent ) . get ( ) ;
168+ // Debug output
169+ cy . log ( 'Dropdown options:' , texts . join ( ', ' ) ) ;
170+ expect ( texts ) . to . include ( 'Not sure' ) ;
171+ } ) ;
172+ cy . contains ( 'li' , 'Not sure' ) . click ( ) ;
173+ cy . get ( '[data-cy="thirdStepSubmit"]' ) . click ( ) ;
174+ cy . url ( ) . should ( 'include' , '/contribute?step=4' ) ;
175+ } ) ;
127176} ) ;
0 commit comments