Skip to content

Commit

Permalink
fixup! tests: add feedback mail test
Browse files Browse the repository at this point in the history
  • Loading branch information
Caracol3 committed Mar 5, 2025
1 parent 6594571 commit 1f4c658
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 26 deletions.
59 changes: 33 additions & 26 deletions front/tests/015-stdcm-feedback-mail.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
import { test } from '@playwright/test';
import STDCMPage from './pages/stdcm-page-model';
import STDCMPage from './pages/stdcm/stdcm-page';
import { waitForInfraStateToBeCached } from './utils';
import { getInfra } from './utils/api-utils';
import type { Infra } from 'common/api/osrdEditoastApi';
import type { ConsistFields } from './utils/types';
import ConsistSection from './pages/stdcm/consist-section';
import OriginSection from './pages/stdcm/origin-section';
import ViaSection from './pages/stdcm/via-section';
import DestinationSection from './pages/stdcm/destination-section';
import SimulationResultPage from './pages/stdcm/simulation-results-page';
import { expectedBody, expectedSubject } from './assets/constants/mail-feedback-const';

test.describe('FeedbackCard Tests', () => {
test.slow(); // Mark test as slow due to multiple steps
test.use({ viewport: { width: 1920, height: 1080 } });

let stdcmPage: STDCMPage;
let consistSection: ConsistSection;
let originSection: OriginSection;
let viaSection: ViaSection;
let destinationSection: DestinationSection;
let simulationResultPage: SimulationResultPage;
let infra: Infra;

const consistDetails: ConsistFields = {
Expand All @@ -25,41 +36,37 @@ test.describe('FeedbackCard Tests', () => {
});

test.beforeEach('Navigate to the STDCM page', async ({ page }) => {
stdcmPage = new STDCMPage(page);
[
stdcmPage,
consistSection,
originSection,
viaSection,
destinationSection,
simulationResultPage,
] = [
new STDCMPage(page),
new ConsistSection(page),
new OriginSection(page),
new ViaSection(page),
new DestinationSection(page),
new SimulationResultPage(page),
];
await page.goto('/stdcm');
await page.waitForLoadState('networkidle');
await stdcmPage.removeViteOverlay();

// Wait for infra to be in 'CACHED' state before proceeding
await waitForInfraStateToBeCached(infra.id);
});

test('Verify FeedbackCard visibility', async () => {
await stdcmPage.fillAndVerifyConsistDetails(consistDetails, '180', '40');
await stdcmPage.fillAndVerifyOriginDetails();
await stdcmPage.fillAndVerifyDestinationDetails();
await consistSection.fillAndVerifyConsistDetails(consistDetails, '180', '40');
await originSection.fillAndVerifyOriginDetails();
await destinationSection.fillAndVerifyDestinationDetails();
await stdcmPage.launchSimulation();

await stdcmPage.verifyFeedbackCardVisibility();
await stdcmPage.clickFeedbackButton();
const expectedSubject = 'Feedback on the STDCM simulator';
const expectedBody = `
********
Simulation details:
Traction Engine: electricRollingStockName
Composition Code: HLP
Tonnage: 180 t
Length: 40 m
Max Speed: 100 km/h
Origin: Perrigny BV
Destination: Miramas BV
Departure Time: 14:30
Please share your feedback here.
`;
await simulationResultPage.verifyFeedbackCardVisibility();
await simulationResultPage.clickFeedbackButton();

await stdcmPage.verifyMailRedirection(expectedSubject, expectedBody);
await simulationResultPage.verifyMailRedirection(expectedSubject, expectedBody);
});
});
18 changes: 18 additions & 0 deletions front/tests/assets/constants/mail-feedback-const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const expectedSubject = 'Feedback on the STDCM simulator';

export const expectedBody = `
********
Simulation details:
Traction Engine: electricRollingStockName
Composition Code: HLP
Tonnage: 180 t
Length: 40 m
Max Speed: 100 km/h
Origin: Perrigny BV
Destination: Miramas BV
Departure Time: 14:30
Please share your feedback here.
`;

0 comments on commit 1f4c658

Please sign in to comment.