Skip to content

Commit f352189

Browse files
committed
Add e2e tests for creating and removing hybrid stop
1 parent 15d3370 commit f352189

1 file changed

Lines changed: 136 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)