Skip to content

Commit afffc7a

Browse files
committed
Add e2e tests for creating and removing hybrid stop
1 parent 57bb003 commit afffc7a

1 file changed

Lines changed: 130 additions & 0 deletions

File tree

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
import {
2+
Priority,
3+
ReusableComponentsVehicleModeEnum,
4+
StopAreaInput,
5+
StopRegistryGeoJsonType,
6+
StopRegistryTransportModeType,
7+
} from '@hsl/jore4-test-db-manager/dist/CypressSpecExports';
8+
import { Tag } from '../../enums';
9+
import { MapPage, StopDetailsPage, Toast } from '../../pageObjects';
10+
import { InsertedStopRegistryIds } from '../utils';
11+
12+
// Test labels
13+
const busStopLabel = 'H9901';
14+
const busAreaCode = 'HYB01';
15+
const tramAreaCode = 'HYB02';
16+
17+
// Coordinates where bus infra links are known to exist (same as createStop.cy.ts)
18+
const testCoordinates = {
19+
lat: 60.164074274478054,
20+
lng: 24.93021804533524,
21+
};
22+
23+
const stopAreaInput: Array<StopAreaInput> = [
24+
{
25+
StopArea: {
26+
transportMode: StopRegistryTransportModeType.Bus,
27+
name: { lang: 'fin', value: 'Hybrid bussi-alue' },
28+
privateCode: { type: 'HSL/TEST', value: busAreaCode },
29+
geometry: {
30+
coordinates: [testCoordinates.lng, testCoordinates.lat],
31+
type: StopRegistryGeoJsonType.Point,
32+
},
33+
},
34+
organisations: null,
35+
},
36+
{
37+
StopArea: {
38+
transportMode: StopRegistryTransportModeType.Tram,
39+
name: { lang: 'fin', value: 'Hybrid ratikka-alue' },
40+
privateCode: { type: 'HSL/TEST', value: tramAreaCode },
41+
geometry: {
42+
coordinates: [testCoordinates.lng, testCoordinates.lat],
43+
type: StopRegistryGeoJsonType.Point,
44+
},
45+
},
46+
organisations: null,
47+
},
48+
];
49+
50+
describe(
51+
'Hybrid stop (multi-transport-mode)',
52+
{ tags: [Tag.StopRegistry, Tag.Stops] },
53+
() => {
54+
beforeEach(() => {
55+
cy.task('resetDbs');
56+
57+
cy.task<InsertedStopRegistryIds>('insertStopRegistryData', {
58+
stopPlaces: stopAreaInput,
59+
stopPointsRequired: false,
60+
});
61+
62+
cy.setupTests();
63+
cy.mockLogin();
64+
});
65+
66+
it('Should create a bus stop, make it hybrid (add tram), then remove tram', () => {
67+
// Step 1: Create a bus stop on the map
68+
MapPage.map.visit({
69+
zoom: 16,
70+
lat: testCoordinates.lat,
71+
lng: testCoordinates.lng,
72+
});
73+
74+
MapPage.createStopAtLocation({
75+
stopFormInfo: {
76+
publicCode: busStopLabel,
77+
stopPlace: busAreaCode,
78+
validityStartISODate: '2024-01-01',
79+
priority: Priority.Standard,
80+
reasonForChange: 'E2E test',
81+
},
82+
clickRelativePoint: {
83+
xPercentage: 40,
84+
yPercentage: 55,
85+
},
86+
vehicleMode: ReusableComponentsVehicleModeEnum.Bus,
87+
});
88+
89+
MapPage.gqlStopShouldBeCreatedSuccessfully();
90+
MapPage.checkStopSubmitSuccessToast();
91+
92+
// Step 2: Navigate to stop details page
93+
StopDetailsPage.visit(busStopLabel);
94+
StopDetailsPage.page().shouldBeVisible();
95+
96+
// Step 3: Open "Make hybrid" modal via extra actions menu
97+
cy.getByTestId('StopTitleRow::extraActions::menu').click();
98+
cy.getByTestId('StopTitleRow::extraActions::makeHybrid').click();
99+
100+
// Step 4: Select tram transport mode
101+
cy.getByTestId('MakeHybridStopModal').shouldBeVisible();
102+
cy.getByTestId('MakeHybridStopModal::transportMode::ListboxButton').click();
103+
cy.get('[role="option"]').contains('Raitiovaunu').click();
104+
105+
// Step 5: Search and select the tram stop area
106+
cy.getByTestId('MakeHybridStopModal::stopAreaInput').type(tramAreaCode);
107+
cy.getByTestId(`MakeHybridStopModal::stopArea::${tramAreaCode}`).click();
108+
109+
// Step 6: Confirm
110+
cy.getByTestId('MakeHybridStopModal::confirm').click();
111+
112+
Toast.expectSuccessToast('Yhteiskäyttöpysäkki luotu onnistuneesti');
113+
114+
// Step 7: Verify the mirrored quay card appears
115+
// The page should now show a mirrored quay details card
116+
cy.get('[data-testid^="MirroredQuayDetails::"]').should('exist');
117+
118+
// Step 8: Remove the hybrid relation
119+
cy.get('[data-testid$="::remove"]')
120+
.filter('[data-testid^="MirroredQuayDetails::"]')
121+
.click();
122+
123+
// Confirm removal in the dialog
124+
cy.getByTestId('ConfirmationDialog::confirmButton').click();
125+
126+
// Step 9: Verify the mirrored card is gone
127+
cy.get('[data-testid^="MirroredQuayDetails::"]').should('not.exist');
128+
});
129+
},
130+
);

0 commit comments

Comments
 (0)