-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy path005-operational-studies.spec.ts
112 lines (89 loc) · 4.1 KB
/
005-operational-studies.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { expect } from '@playwright/test';
import type {
Infra,
LightRollingStock,
Project,
Scenario,
Study,
} from 'common/api/osrdEditoastApi';
import { electricRollingStockName } from './assets/project-const';
import RoutePage from './pages/op-route-page-model';
import OperationalStudiesPage from './pages/operational-studies-page-model';
import RollingStockSelectorPage from './pages/rollingstock-selector-page-model';
import test from './test-logger';
import { waitForInfraStateToBeCached } from './utils';
import { getInfra, getRollingStock } from './utils/api-setup';
import createScenario from './utils/scenario';
import { deleteScenario } from './utils/teardown-utils';
test.describe('Verify simulation configuration in operational studies', () => {
test.slow();
let project: Project;
let study: Study;
let scenario: Scenario;
let infra: Infra;
let rollingStock: LightRollingStock;
test.beforeAll('Fetch rolling stock and infrastructure ', async () => {
rollingStock = await getRollingStock(electricRollingStockName);
infra = await getInfra();
});
test.beforeEach('Set up the project, study, and scenario', async () => {
({ project, study, scenario } = await createScenario());
});
test.afterEach('Delete the created scenario', async () => {
await deleteScenario(project.id, study.id, scenario.name);
});
/** *************** Test **************** */
test('Pathfinding with rolling stock and composition code', async ({ page }) => {
// Page models
const [rollingstockPage, operationalStudiesPage, routePage] = [
new RollingStockSelectorPage(page),
new OperationalStudiesPage(page),
new RoutePage(page),
];
// Navigate to the scenario page for the given project and study
await page.goto(
`/operational-studies/projects/${project.id}/studies/${study.id}/scenarios/${scenario.id}`
);
// Wait for infra to be in 'CACHED' state before proceeding
await waitForInfraStateToBeCached(infra.id);
// Click the button to add a train schedule
await operationalStudiesPage.clickOnAddTrainButton();
// Set the train schedule name and number of trains
await operationalStudiesPage.setTrainScheduleName('TrainSchedule');
await operationalStudiesPage.setNumberOfTrains('7');
// Open the rolling stock modal
await rollingstockPage.openRollingstockModal();
await expect(rollingstockPage.rollingStockSelectorModal).toBeVisible();
// Test rolling stock search with normalization (spaces and capital letters)
await rollingstockPage.searchRollingstock(' electric_Rs_E2e ');
// Select the rolling stock card based on the test ID
const rollingstockCard = rollingstockPage.getRollingstockCardByTestID(
`rollingstock-${rollingStock.name}`
);
// Verify the rolling stock card is inactive initially
await expect(rollingstockCard).toHaveClass(/inactive/);
// Select the rolling stock and ensure it becomes active
await rollingstockCard.click();
await expect(rollingstockCard).not.toHaveClass(/inactive/);
// Confirm rolling stock selection by clicking the button on the card
await rollingstockCard.locator('button').click();
// Validate that the rolling stock's name and comfort class are displayed correctly
expect(await rollingstockPage.getRollingStockMiniCardInfo().first().textContent()).toMatch(
rollingStock.name
);
expect(await rollingstockPage.getRollingStockInfoComfort().textContent()).toMatch(
/ConfortSStandard/i
);
// Perform Pathfinding and verify the distance
await operationalStudiesPage.clickOnRouteTab();
await routePage.performPathfindingByTrigram('MWS', 'NES');
await operationalStudiesPage.checkPathfindingDistance('33.950 km');
// Adding Train Schedule
await operationalStudiesPage.addTrainSchedule();
// Verify the train has been added and the simulation results
await operationalStudiesPage.checkTrainHasBeenAdded();
await operationalStudiesPage.returnSimulationResult();
// Confirm the number of trains added matches the expected number
await operationalStudiesPage.checkNumberOfTrains(7);
});
});