@@ -6,7 +6,14 @@ import {
66 StopRegistryTransportModeType ,
77} from '@hsl/jore4-test-db-manager/dist/CypressSpecExports' ;
88import { Tag } from '../../enums' ;
9- import { MapPage , StopDetailsPage , Toast } from '../../pageObjects' ;
9+ import {
10+ FilterPanel ,
11+ MapPage ,
12+ StopDetailsPage ,
13+ StopSearchResultsPage ,
14+ Toast ,
15+ } from '../../pageObjects' ;
16+ import { StopTransportModeIcon } from '../../pageObjects/stop-registry/StopTransportModeIcon' ;
1017import { InsertedStopRegistryIds } from '../utils' ;
1118
1219// Test labels
@@ -134,96 +141,185 @@ describe(
134141 } ) ;
135142
136143 it ( 'Should change the stop state of a mirrored quay' , ( ) => {
137- // Step 1: Create a bus stop on the map
138- MapPage . map . visit ( {
139- zoom : 16 ,
140- lat : testCoordinates . lat ,
141- lng : testCoordinates . lng ,
142- } ) ;
144+ cy . section ( ' Create a bus stop on the map' , ( ) => {
145+ MapPage . map . visit ( {
146+ zoom : 16 ,
147+ lat : testCoordinates . lat ,
148+ lng : testCoordinates . lng ,
149+ } ) ;
143150
144- MapPage . createStopAtLocation ( {
145- stopFormInfo : {
146- publicCode : busStopLabel ,
147- stopPlace : busAreaCode ,
148- validityStartISODate : '2024-01-01' ,
149- priority : Priority . Standard ,
150- reasonForChange : 'E2E test' ,
151- } ,
152- clickRelativePoint : {
153- xPercentage : 40 ,
154- yPercentage : 55 ,
155- } ,
156- vehicleMode : ReusableComponentsVehicleModeEnum . Bus ,
151+ MapPage . createStopAtLocation ( {
152+ stopFormInfo : {
153+ publicCode : busStopLabel ,
154+ stopPlace : busAreaCode ,
155+ validityStartISODate : '2024-01-01' ,
156+ priority : Priority . Standard ,
157+ reasonForChange : 'E2E test' ,
158+ } ,
159+ clickRelativePoint : {
160+ xPercentage : 40 ,
161+ yPercentage : 55 ,
162+ } ,
163+ vehicleMode : ReusableComponentsVehicleModeEnum . Bus ,
164+ } ) ;
165+
166+ MapPage . gqlStopShouldBeCreatedSuccessfully ( ) ;
167+ MapPage . checkStopSubmitSuccessToast ( ) ;
157168 } ) ;
158169
159- MapPage . gqlStopShouldBeCreatedSuccessfully ( ) ;
160- MapPage . checkStopSubmitSuccessToast ( ) ;
170+ cy . section ( 'Navigate to stop details and make it hybrid' , ( ) => {
171+ StopDetailsPage . visit ( busStopLabel ) ;
172+ StopDetailsPage . page ( ) . shouldBeVisible ( ) ;
161173
162- // Step 2: Navigate to stop details and make it hybrid
163- StopDetailsPage . visit ( busStopLabel ) ;
164- StopDetailsPage . page ( ) . shouldBeVisible ( ) ;
174+ StopDetailsPage . titleRow . actionsMenuButton ( ) . click ( ) ;
175+ StopDetailsPage . titleRow . actionsMenuMakeHybridButton ( ) . click ( ) ;
165176
166- StopDetailsPage . titleRow . actionsMenuButton ( ) . click ( ) ;
167- StopDetailsPage . titleRow . actionsMenuMakeHybridButton ( ) . click ( ) ;
177+ StopDetailsPage . makeHybridModal . modal ( ) . shouldBeVisible ( ) ;
178+ StopDetailsPage . makeHybridModal . transportModeDropdown ( ) . click ( ) ;
179+ cy . get ( '[role="option"]' ) . contains ( 'Raitiovaunu' ) . click ( ) ;
168180
169- StopDetailsPage . makeHybridModal . modal ( ) . shouldBeVisible ( ) ;
170- StopDetailsPage . makeHybridModal . transportModeDropdown ( ) . click ( ) ;
171- cy . get ( '[role="option"]' ) . contains ( 'Raitiovaunu' ) . click ( ) ;
181+ StopDetailsPage . makeHybridModal . stopAreaInput ( ) . type ( tramAreaCode ) ;
182+ StopDetailsPage . makeHybridModal . stopAreaOption ( tramAreaCode ) . click ( ) ;
183+ StopDetailsPage . makeHybridModal . confirmButton ( ) . click ( ) ;
172184
173- StopDetailsPage . makeHybridModal . stopAreaInput ( ) . type ( tramAreaCode ) ;
174- StopDetailsPage . makeHybridModal . stopAreaOption ( tramAreaCode ) . click ( ) ;
175- StopDetailsPage . makeHybridModal . confirmButton ( ) . click ( ) ;
176-
177- Toast . expectSuccessToast ( 'Yhteiskäyttöpysäkki luotu onnistuneesti' ) ;
178-
179- // Step 3: Open mirrored quay edit mode
180- StopDetailsPage . mirroredQuayDetails . cards ( ) . should ( 'exist' ) ;
181- StopDetailsPage . mirroredQuayDetails
182- . cards ( )
183- . first ( )
184- . within ( ( ) => {
185- StopDetailsPage . mirroredQuayDetails . getEditButton ( ) . click ( ) ;
186- } ) ;
187-
188- // Step 4: Change stop state to "Pois käytöstä"
189- StopDetailsPage . mirroredQuayDetails
190- . cards ( )
191- . first ( )
192- . within ( ( ) => {
193- StopDetailsPage . mirroredQuayDetails
194- . getStopStateDropdownButton ( )
195- . click ( ) ;
196- } ) ;
185+ Toast . expectSuccessToast ( 'Yhteiskäyttöpysäkki luotu onnistuneesti' ) ;
186+ } ) ;
197187
198- StopDetailsPage . mirroredQuayDetails
199- . getStopStateDropdownOptions ( )
200- . contains ( 'Pois käytöstä' )
201- . click ( ) ;
188+ cy . section (
189+ 'Verify the Details page lists correct Transport Mode icons' ,
190+ ( ) => {
191+ StopTransportModeIcon . assertTransportModeIcons ( {
192+ inUse : [
193+ StopRegistryTransportModeType . Bus ,
194+ StopRegistryTransportModeType . Tram ,
195+ ] ,
196+ } ) ;
197+ } ,
198+ ) ;
199+
200+ cy . section ( 'Ensure the stop shows correctly on the map' , ( ) => {
201+ StopDetailsPage . titleRow . openOnMapButton ( ) . click ( ) ;
202+ MapPage . map . waitForLoadToComplete ( ) ;
203+
204+ FilterPanel . setShowStops ( ReusableComponentsVehicleModeEnum . Bus , true ) ;
205+ FilterPanel . setShowStops ( ReusableComponentsVehicleModeEnum . Tram , true ) ;
206+ MapPage . map
207+ . getStopByStopLabelAndPriority ( busStopLabel , Priority . Standard )
208+ . shouldBeVisible ( )
209+ . and ( 'have.attr' , 'data-transport-modes' , 'bus,tram' ) ;
210+
211+ FilterPanel . setShowStops ( ReusableComponentsVehicleModeEnum . Bus , false ) ;
212+ MapPage . map
213+ . getStopByStopLabelAndPriority ( busStopLabel , Priority . Standard )
214+ . shouldBeVisible ( ) ;
215+
216+ FilterPanel . setShowStops ( ReusableComponentsVehicleModeEnum . Bus , true ) ;
217+ FilterPanel . setShowStops ( ReusableComponentsVehicleModeEnum . Tram , false ) ;
218+ MapPage . map
219+ . getStopByStopLabelAndPriority ( busStopLabel , Priority . Standard )
220+ . shouldBeVisible ( ) ;
221+
222+ FilterPanel . setShowStops ( ReusableComponentsVehicleModeEnum . Bus , false ) ;
223+ MapPage . map
224+ . getStopByStopLabelAndPriority ( busStopLabel , Priority . Standard )
225+ . should ( 'not.exist' ) ;
226+ } ) ;
202227
203- // Step 5: Fill in reason for change and save
204- StopDetailsPage . mirroredQuayDetails
205- . cards ( )
206- . first ( )
207- . within ( ( ) => {
208- StopDetailsPage . mirroredQuayDetails . reasonForChange
209- . getReasonForChangeInput ( )
210- . type ( 'E2E tilan muutos' ) ;
228+ cy . section ( 'Mark the tram stop to be out of use' , ( ) => {
229+ MapPage . getCloseButton ( ) . click ( ) ;
230+ StopDetailsPage . mirroredQuayDetails . cards ( ) . should ( 'exist' ) ;
231+ StopDetailsPage . mirroredQuayDetails
232+ . cards ( )
233+ . first ( )
234+ . within ( ( ) => {
235+ StopDetailsPage . mirroredQuayDetails . getEditButton ( ) . click ( ) ;
236+ } ) ;
237+
238+ StopDetailsPage . mirroredQuayDetails
239+ . cards ( )
240+ . first ( )
241+ . within ( ( ) => {
242+ StopDetailsPage . mirroredQuayDetails
243+ . getStopStateDropdownButton ( )
244+ . click ( ) ;
245+ } ) ;
246+
247+ StopDetailsPage . mirroredQuayDetails
248+ . getStopStateDropdownOptions ( )
249+ . contains ( 'Pois käytöstä' )
250+ . click ( ) ;
251+
252+ StopDetailsPage . mirroredQuayDetails
253+ . cards ( )
254+ . first ( )
255+ . within ( ( ) => {
256+ StopDetailsPage . mirroredQuayDetails . reasonForChange
257+ . getReasonForChangeInput ( )
258+ . type ( 'E2E tilan muutos' ) ;
259+
260+ StopDetailsPage . mirroredQuayDetails . getSaveButton ( ) . click ( ) ;
261+ } ) ;
262+
263+ Toast . expectSuccessToast ( ) ;
264+ } ) ;
211265
212- StopDetailsPage . mirroredQuayDetails . getSaveButton ( ) . click ( ) ;
266+ cy . section ( 'Verify the stop state is updated on the page' , ( ) => {
267+ StopDetailsPage . mirroredQuayDetails
268+ . cards ( )
269+ . first ( )
270+ . within ( ( ) => {
271+ cy . getByTestId ( 'BasicDetailsSection::stopState' ) . should (
272+ 'contain' ,
273+ 'Pois käytöstä' ,
274+ ) ;
275+ } ) ;
276+
277+ StopTransportModeIcon . assertTransportModeIcons ( {
278+ inUse : [ StopRegistryTransportModeType . Bus ] ,
279+ outOfUse : [ StopRegistryTransportModeType . Tram ] ,
213280 } ) ;
281+ } ) ;
214282
215- Toast . expectSuccessToast ( ) ;
283+ cy . section ( 'Ensure the updated stop shows correctly on the map' , ( ) => {
284+ StopDetailsPage . titleRow . openOnMapButton ( ) . click ( ) ;
285+ MapPage . map . waitForLoadToComplete ( ) ;
286+
287+ // Show as bus
288+ FilterPanel . setShowStops ( ReusableComponentsVehicleModeEnum . Bus , true ) ;
289+ MapPage . map
290+ . getStopByStopLabelAndPriority ( busStopLabel , Priority . Standard )
291+ . shouldBeVisible ( )
292+ . and ( 'have.attr' , 'data-transport-modes' , 'bus' ) ;
293+
294+ // Does still also show under tram stops (it's just out of use)
295+ FilterPanel . setShowStops ( ReusableComponentsVehicleModeEnum . Bus , false ) ;
296+ FilterPanel . setShowStops ( ReusableComponentsVehicleModeEnum . Tram , true ) ;
297+ MapPage . map
298+ . getStopByStopLabelAndPriority ( busStopLabel , Priority . Standard )
299+ . shouldBeVisible ( ) ;
300+ } ) ;
216301
217- // Step 6: Verify the stop state is updated in the view card
218- StopDetailsPage . mirroredQuayDetails
219- . cards ( )
220- . first ( )
221- . within ( ( ) => {
222- cy . getByTestId ( 'BasicDetailsSection::stopState' ) . should (
223- 'contain' ,
224- 'Pois käytöstä' ,
225- ) ;
226- } ) ;
302+ cy . section (
303+ 'Ensure the updated stop shows correctly on the search' ,
304+ ( ) => {
305+ cy . visit ( {
306+ url : '/stop-registry/search' ,
307+ qs : { query : busStopLabel } ,
308+ } ) ;
309+
310+ StopSearchResultsPage . getContainer ( ) . should ( 'be.visible' ) ;
311+
312+ // Ordered by label.
313+ StopSearchResultsPage . getResultRows ( )
314+ . first ( )
315+ . within ( ( ) => {
316+ StopTransportModeIcon . assertTransportModeIcons ( {
317+ inUse : [ StopRegistryTransportModeType . Bus ] ,
318+ outOfUse : [ StopRegistryTransportModeType . Tram ] ,
319+ } ) ;
320+ } ) ;
321+ } ,
322+ ) ;
227323 } ) ;
228324 } ,
229325) ;
0 commit comments