Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
252 changes: 174 additions & 78 deletions cypress/e2e/stop-registry/hybridStop.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import {
StopRegistryTransportModeType,
} from '@hsl/jore4-test-db-manager/dist/CypressSpecExports';
import { Tag } from '../../enums';
import { MapPage, StopDetailsPage, Toast } from '../../pageObjects';
import {
FilterPanel,
MapPage,
StopDetailsPage,
StopSearchResultsPage,
Toast,
} from '../../pageObjects';
import { StopTransportModeIcon } from '../../pageObjects/stop-registry/StopTransportModeIcon';
import { InsertedStopRegistryIds } from '../utils';

// Test labels
Expand Down Expand Up @@ -134,96 +141,185 @@ describe(
});

it('Should change the stop state of a mirrored quay', () => {
// Step 1: Create a bus stop on the map
MapPage.map.visit({
zoom: 16,
lat: testCoordinates.lat,
lng: testCoordinates.lng,
});
cy.section('Create a bus stop on the map', () => {
MapPage.map.visit({
zoom: 16,
lat: testCoordinates.lat,
lng: testCoordinates.lng,
});

MapPage.createStopAtLocation({
stopFormInfo: {
publicCode: busStopLabel,
stopPlace: busAreaCode,
validityStartISODate: '2024-01-01',
priority: Priority.Standard,
reasonForChange: 'E2E test',
},
clickRelativePoint: {
xPercentage: 40,
yPercentage: 55,
},
vehicleMode: ReusableComponentsVehicleModeEnum.Bus,
MapPage.createStopAtLocation({
stopFormInfo: {
publicCode: busStopLabel,
stopPlace: busAreaCode,
validityStartISODate: '2024-01-01',
priority: Priority.Standard,
reasonForChange: 'E2E test',
},
clickRelativePoint: {
xPercentage: 40,
yPercentage: 55,
},
vehicleMode: ReusableComponentsVehicleModeEnum.Bus,
});

MapPage.gqlStopShouldBeCreatedSuccessfully();
MapPage.checkStopSubmitSuccessToast();
});

MapPage.gqlStopShouldBeCreatedSuccessfully();
MapPage.checkStopSubmitSuccessToast();
cy.section('Navigate to stop details and make it hybrid', () => {
StopDetailsPage.visit(busStopLabel);
StopDetailsPage.page().shouldBeVisible();

// Step 2: Navigate to stop details and make it hybrid
StopDetailsPage.visit(busStopLabel);
StopDetailsPage.page().shouldBeVisible();
StopDetailsPage.titleRow.actionsMenuButton().click();
StopDetailsPage.titleRow.actionsMenuMakeHybridButton().click();

StopDetailsPage.titleRow.actionsMenuButton().click();
StopDetailsPage.titleRow.actionsMenuMakeHybridButton().click();
StopDetailsPage.makeHybridModal.modal().shouldBeVisible();
StopDetailsPage.makeHybridModal.transportModeDropdown().click();
cy.get('[role="option"]').contains('Raitiovaunu').click();

StopDetailsPage.makeHybridModal.modal().shouldBeVisible();
StopDetailsPage.makeHybridModal.transportModeDropdown().click();
cy.get('[role="option"]').contains('Raitiovaunu').click();
StopDetailsPage.makeHybridModal.stopAreaInput().type(tramAreaCode);
StopDetailsPage.makeHybridModal.stopAreaOption(tramAreaCode).click();
StopDetailsPage.makeHybridModal.confirmButton().click();

StopDetailsPage.makeHybridModal.stopAreaInput().type(tramAreaCode);
StopDetailsPage.makeHybridModal.stopAreaOption(tramAreaCode).click();
StopDetailsPage.makeHybridModal.confirmButton().click();

Toast.expectSuccessToast('Yhteiskäyttöpysäkki luotu onnistuneesti');

// Step 3: Open mirrored quay edit mode
StopDetailsPage.mirroredQuayDetails.cards().should('exist');
StopDetailsPage.mirroredQuayDetails
.cards()
.first()
.within(() => {
StopDetailsPage.mirroredQuayDetails.getEditButton().click();
});

// Step 4: Change stop state to "Pois käytöstä"
StopDetailsPage.mirroredQuayDetails
.cards()
.first()
.within(() => {
StopDetailsPage.mirroredQuayDetails
.getStopStateDropdownButton()
.click();
});
Toast.expectSuccessToast('Yhteiskäyttöpysäkki luotu onnistuneesti');
});

StopDetailsPage.mirroredQuayDetails
.getStopStateDropdownOptions()
.contains('Pois käytöstä')
.click();
cy.section(
'Verify the Details page lists correct Transport Mode icons',
() => {
StopTransportModeIcon.assertTransportModeIcons({
inUse: [
StopRegistryTransportModeType.Bus,
StopRegistryTransportModeType.Tram,
],
});
},
);

cy.section('Ensure the stop shows correctly on the map', () => {
StopDetailsPage.titleRow.openOnMapButton().click();
MapPage.map.waitForLoadToComplete();

FilterPanel.setShowStops(ReusableComponentsVehicleModeEnum.Bus, true);
FilterPanel.setShowStops(ReusableComponentsVehicleModeEnum.Tram, true);
MapPage.map
.getStopByStopLabelAndPriority(busStopLabel, Priority.Standard)
.shouldBeVisible()
.and('have.attr', 'data-transport-modes', 'bus,tram');

FilterPanel.setShowStops(ReusableComponentsVehicleModeEnum.Bus, false);
MapPage.map
.getStopByStopLabelAndPriority(busStopLabel, Priority.Standard)
.shouldBeVisible();

FilterPanel.setShowStops(ReusableComponentsVehicleModeEnum.Bus, true);
FilterPanel.setShowStops(ReusableComponentsVehicleModeEnum.Tram, false);
MapPage.map
.getStopByStopLabelAndPriority(busStopLabel, Priority.Standard)
.shouldBeVisible();

FilterPanel.setShowStops(ReusableComponentsVehicleModeEnum.Bus, false);
MapPage.map
.getStopByStopLabelAndPriority(busStopLabel, Priority.Standard)
.should('not.exist');
});

// Step 5: Fill in reason for change and save
StopDetailsPage.mirroredQuayDetails
.cards()
.first()
.within(() => {
StopDetailsPage.mirroredQuayDetails.reasonForChange
.getReasonForChangeInput()
.type('E2E tilan muutos');
cy.section('Mark the tram stop to be out of use', () => {
MapPage.getCloseButton().click();
StopDetailsPage.mirroredQuayDetails.cards().should('exist');
StopDetailsPage.mirroredQuayDetails
.cards()
.first()
.within(() => {
StopDetailsPage.mirroredQuayDetails.getEditButton().click();
});

StopDetailsPage.mirroredQuayDetails
.cards()
.first()
.within(() => {
StopDetailsPage.mirroredQuayDetails
.getStopStateDropdownButton()
.click();
});

StopDetailsPage.mirroredQuayDetails
.getStopStateDropdownOptions()
.contains('Pois käytöstä')
.click();

StopDetailsPage.mirroredQuayDetails
.cards()
.first()
.within(() => {
StopDetailsPage.mirroredQuayDetails.reasonForChange
.getReasonForChangeInput()
.type('E2E tilan muutos');

StopDetailsPage.mirroredQuayDetails.getSaveButton().click();
});

Toast.expectSuccessToast();
});

StopDetailsPage.mirroredQuayDetails.getSaveButton().click();
cy.section('Verify the stop state is updated on the page', () => {
StopDetailsPage.mirroredQuayDetails
.cards()
.first()
.within(() => {
cy.getByTestId('BasicDetailsSection::stopState').should(
'contain',
'Pois käytöstä',
);
});

StopTransportModeIcon.assertTransportModeIcons({
inUse: [StopRegistryTransportModeType.Bus],
outOfUse: [StopRegistryTransportModeType.Tram],
});
});

Toast.expectSuccessToast();
cy.section('Ensure the updated stop shows correctly on the map', () => {
StopDetailsPage.titleRow.openOnMapButton().click();
MapPage.map.waitForLoadToComplete();

// Show as bus
FilterPanel.setShowStops(ReusableComponentsVehicleModeEnum.Bus, true);
MapPage.map
.getStopByStopLabelAndPriority(busStopLabel, Priority.Standard)
.shouldBeVisible()
.and('have.attr', 'data-transport-modes', 'bus');

// Does still also show under tram stops (it's just out of use)
FilterPanel.setShowStops(ReusableComponentsVehicleModeEnum.Bus, false);
FilterPanel.setShowStops(ReusableComponentsVehicleModeEnum.Tram, true);
MapPage.map
.getStopByStopLabelAndPriority(busStopLabel, Priority.Standard)
.shouldBeVisible();
});

// Step 6: Verify the stop state is updated in the view card
StopDetailsPage.mirroredQuayDetails
.cards()
.first()
.within(() => {
cy.getByTestId('BasicDetailsSection::stopState').should(
'contain',
'Pois käytöstä',
);
});
cy.section(
'Ensure the updated stop shows correctly on the search',
() => {
cy.visit({
url: '/stop-registry/search',
qs: { query: busStopLabel },
});

StopSearchResultsPage.getContainer().should('be.visible');

// Ordered by label.
StopSearchResultsPage.getResultRows()
.first()
.within(() => {
StopTransportModeIcon.assertTransportModeIcons({
inUse: [StopRegistryTransportModeType.Bus],
outOfUse: [StopRegistryTransportModeType.Tram],
});
});
},
);
});
},
);
4 changes: 4 additions & 0 deletions cypress/e2e/stop-registry/stopDetails.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
Toast,
} from '../../pageObjects';
import { StopVersionForm } from '../../pageObjects/stop-registry/stop-details/StopVersionForm';
import { StopTransportModeIcon } from '../../pageObjects/stop-registry/StopTransportModeIcon';
import { UUID } from '../../types';
import { SupportedResources, insertToDbHelper } from '../../utils';
import { expectGraphQLCallToSucceed } from '../../utils/assertions';
Expand Down Expand Up @@ -716,6 +717,9 @@ describe('Stop details', { tags: [Tag.StopRegistry] }, () => {
StopDetailsPage.headerSummaryRow
.stopState()
.should('have.text', 'Pois käytöstä');
StopTransportModeIcon.assertTransportModeIcons({
outOfUse: ['TrunkLine'],
});

StopDetailsPage.basicDetails.getEditButton().click();

Expand Down
24 changes: 19 additions & 5 deletions cypress/pageObjects/map/FilterPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@ import { ReusableComponentsVehicleModeEnum } from '@hsl/jore4-test-db-manager/di
import { capitalizeFirstLetter } from '../../e2e/utils';

export class FilterPanel {
static getToggle(vehicleMode: ReusableComponentsVehicleModeEnum) {
return cy.getByTestId(
`FilterPanel::toggleShowAll${capitalizeFirstLetter(vehicleMode)}Stops`,
);
}

static toggleShowStops(vehicleMode: ReusableComponentsVehicleModeEnum) {
return cy
.getByTestId(
`FilterPanel::toggleShowAll${capitalizeFirstLetter(vehicleMode)}Stops`,
)
.click();
FilterPanel.getToggle(vehicleMode).click();
}

static setShowStops(
vehicleMode: ReusableComponentsVehicleModeEnum,
shouldBeActive: boolean,
) {
FilterPanel.getToggle(vehicleMode).then((toggle) => {
const isActive = toggle.attr('aria-pressed') === 'true';
if (isActive !== shouldBeActive) {
FilterPanel.toggleShowStops(vehicleMode);
}
});
}
}
Loading
Loading