Skip to content

Commit

Permalink
front: editor: split tests in separated files, add line feeds in end …
Browse files Browse the repository at this point in the history
…of files
  • Loading branch information
blemoineovh committed Dec 6, 2023
1 parent 5f3df61 commit ec1e301
Show file tree
Hide file tree
Showing 6 changed files with 19,590 additions and 13,928 deletions.
1 change: 1 addition & 0 deletions front/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# testing
/coverage
front/tests/unit/coverage

# production
/build
Expand Down
1 change: 1 addition & 0 deletions front/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
206 changes: 103 additions & 103 deletions front/tests/005-operational-studies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,107 +9,107 @@ import { ProjectPage } from './pages/project-page-model';
import { StudyPage } from './pages/study-page-model';

test.describe('Testing if all mandatory elements simulation configuration are loaded in operationnal studies app', () => {
test('Testing pathfinding with rollingstock an composition code', async ({ page }) => {
test.setTimeout(90000); // 1min30
const playwrightHomePage = new PlaywrightHomePage(page);
const scenarioPage = new PlaywrightScenarioPage(page);
const projectPage = new ProjectPage(page);
const studyPage = new StudyPage(page);

await playwrightHomePage.goToHomePage();

// Real click on project, study, scenario
await playwrightHomePage.goToOperationalStudiesPage();
await projectPage.openProjectByTestId('_@Test integration project');
await studyPage.openStudyByTestId('_@Test integration study');

await scenarioPage.openScenarioCreationModal();
await scenarioPage.setScenarioName('_@Test integration scenario created');
await scenarioPage.setScenarioInfraByName(VARIABLES.infraName);
const createButton = playwrightHomePage.page.getByText('Créer le scénario');
await createButton.click();

await scenarioPage.checkInfraLoaded();
await playwrightHomePage.page.getByTestId('scenarios-add-train-schedule-button').click();

await scenarioPage.setTrainScheduleName('TrainSchedule');
const trainCount = '7';
await scenarioPage.setNumberOfTrains(trainCount);

// ***************** Test Rolling Stock *****************
const playwrightRollingstockModalPage = new PlaywrightRollingstockModalPage(
playwrightHomePage.page
);
await expect(scenarioPage.getRollingStockSelector).toBeVisible();
await playwrightRollingstockModalPage.openRollingstockModal();
const rollingstockModal = playwrightRollingstockModalPage.getRollingstockModal;
await expect(rollingstockModal).toBeVisible();

await playwrightRollingstockModalPage.checkNumberOfRollingstockFound(
VARIABLES.numberOfRollingstock
);

await playwrightRollingstockModalPage.getElectricalCheckbox.click();
await playwrightRollingstockModalPage.checkNumberOfRollingstockFound(
VARIABLES.numberOfRollingstockWithElectrical
);

await playwrightRollingstockModalPage.searchRollingstock(VARIABLES.searchRollingstock);
await playwrightRollingstockModalPage.checkNumberOfRollingstockFound(
VARIABLES.numberOfRollingstockWithSearch
);

const rollingstockCard = playwrightRollingstockModalPage.getRollingstockCardByTestID(
VARIABLES.rollingstockTestID
);
await expect(rollingstockCard).toHaveClass(/inactive/);
await rollingstockCard.click();
await expect(rollingstockCard).not.toHaveClass(/inactive/);

await rollingstockCard.locator('button').click();

expect(
await playwrightRollingstockModalPage.getRollingStockMiniCardInfo().first().textContent()
).toMatch(VARIABLES.rollingStockInfo);
expect(
await playwrightRollingstockModalPage.getRollingStockInfoComfort().textContent()
).toMatch(/ConfortSStandard/i);

// ***************** Test Composition Code *****************
await scenarioPage.openTabByText('Paramètres de simulation');
await expect(scenarioPage.getSpeedLimitSelector).toBeVisible();
await scenarioPage.getSpeedLimitSelector.click();
await scenarioPage.getSpeedLimitSelector.locator('input').fill('32');
await scenarioPage.getSpeedLimitSelector
.getByRole('button', { name: 'Voyageurs - Automoteurs - E32C' })
.click();
expect(await scenarioPage.getSpeedLimitSelector.textContent()).toMatch(
/Voyageurs - Automoteurs - E32C/i
);

// ***************** Test choice Origin/Destination *****************
const playwrightMap = new PlaywrightMap(playwrightHomePage.page);
await scenarioPage.openTabByText('Itinéraire');
await playwrightMap.page.waitForTimeout(2000);
const itinerary = scenarioPage.getItineraryModule;
await expect(itinerary).toBeVisible();
await expect(scenarioPage.getMapModule).toBeVisible();

// Search and select origin
await playwrightMap.selectOrigin(PATH_VARIABLES.originSearch);

// Search and select destination
await playwrightMap.selectDestination(PATH_VARIABLES.destinationSearch);

await scenarioPage.checkPathfindingDistance(VARIABLES.pathfindingDistance);

// ***************** Test Add Train Schedule *****************
await scenarioPage.addTrainSchedule();
await scenarioPage.page.waitForSelector('.dots-loader', { state: 'hidden' });
await scenarioPage.checkToastSNCFTitle('Train ajouté');
await scenarioPage.returnSimulationResult();
await scenarioPage.checkNumberOfTrains(Number(trainCount));

// Delete all trains when the selection of multiple trains has been added
});
test('Testing pathfinding with rollingstock an composition code', async ({ page }) => {
test.setTimeout(90000); // 1min30
const playwrightHomePage = new PlaywrightHomePage(page);
const scenarioPage = new PlaywrightScenarioPage(page);
const projectPage = new ProjectPage(page);
const studyPage = new StudyPage(page);

await playwrightHomePage.goToHomePage();

// Real click on project, study, scenario
await playwrightHomePage.goToOperationalStudiesPage();
await projectPage.openProjectByTestId('_@Test integration project');
await studyPage.openStudyByTestId('_@Test integration study');

await scenarioPage.openScenarioCreationModal();
await scenarioPage.setScenarioName('_@Test integration scenario created');
await scenarioPage.setScenarioInfraByName(VARIABLES.infraName);
const createButton = playwrightHomePage.page.getByText('Créer le scénario');
await createButton.click();

await scenarioPage.checkInfraLoaded();
await playwrightHomePage.page.getByTestId('scenarios-add-train-schedule-button').click();

await scenarioPage.setTrainScheduleName('TrainSchedule');
const trainCount = '7';
await scenarioPage.setNumberOfTrains(trainCount);

// ***************** Test Rolling Stock *****************
const playwrightRollingstockModalPage = new PlaywrightRollingstockModalPage(
playwrightHomePage.page
);
await expect(scenarioPage.getRollingStockSelector).toBeVisible();
await playwrightRollingstockModalPage.openRollingstockModal();
const rollingstockModal = playwrightRollingstockModalPage.getRollingstockModal;
await expect(rollingstockModal).toBeVisible();

await playwrightRollingstockModalPage.checkNumberOfRollingstockFound(
VARIABLES.numberOfRollingstock
);

await playwrightRollingstockModalPage.getElectricalCheckbox.click();
await playwrightRollingstockModalPage.checkNumberOfRollingstockFound(
VARIABLES.numberOfRollingstockWithElectrical
);

await playwrightRollingstockModalPage.searchRollingstock(VARIABLES.searchRollingstock);
await playwrightRollingstockModalPage.checkNumberOfRollingstockFound(
VARIABLES.numberOfRollingstockWithSearch
);

const rollingstockCard = playwrightRollingstockModalPage.getRollingstockCardByTestID(
VARIABLES.rollingstockTestID
);
await expect(rollingstockCard).toHaveClass(/inactive/);
await rollingstockCard.click();
await expect(rollingstockCard).not.toHaveClass(/inactive/);

await rollingstockCard.locator('button').click();

expect(
await playwrightRollingstockModalPage.getRollingStockMiniCardInfo().first().textContent()
).toMatch(VARIABLES.rollingStockInfo);
expect(
await playwrightRollingstockModalPage.getRollingStockInfoComfort().textContent()
).toMatch(/ConfortSStandard/i);

// ***************** Test Composition Code *****************
await scenarioPage.openTabByText('Paramètres de simulation');
await expect(scenarioPage.getSpeedLimitSelector).toBeVisible();
await scenarioPage.getSpeedLimitSelector.click();
await scenarioPage.getSpeedLimitSelector.locator('input').fill('32');
await scenarioPage.getSpeedLimitSelector
.getByRole('button', { name: 'Voyageurs - Automoteurs - E32C' })
.click();
expect(await scenarioPage.getSpeedLimitSelector.textContent()).toMatch(
/Voyageurs - Automoteurs - E32C/i
);

// ***************** Test choice Origin/Destination *****************
const playwrightMap = new PlaywrightMap(playwrightHomePage.page);
await scenarioPage.openTabByText('Itinéraire');
await playwrightMap.page.waitForTimeout(2000);
const itinerary = scenarioPage.getItineraryModule;
await expect(itinerary).toBeVisible();
await expect(scenarioPage.getMapModule).toBeVisible();

// Search and select origin
await playwrightMap.selectOrigin(PATH_VARIABLES.originSearch);

// Search and select destination
await playwrightMap.selectDestination(PATH_VARIABLES.destinationSearch);

await scenarioPage.checkPathfindingDistance(VARIABLES.pathfindingDistance);

// ***************** Test Add Train Schedule *****************
await scenarioPage.addTrainSchedule();
await scenarioPage.page.waitForSelector('.dots-loader', { state: 'hidden' });
await scenarioPage.checkToastSNCFTitle('Train ajouté');
await scenarioPage.returnSimulationResult();
await scenarioPage.checkNumberOfTrains(Number(trainCount));

// Delete all trains when the selection of multiple trains has been added
});
});
14 changes: 14 additions & 0 deletions front/tests/010-editor.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import {expect, test} from '@playwright/test';
import {PlaywrightEditorPage} from "./pages/editor-page-model";

test.describe('Testing the Editor app', () => {
test('Testing there is no error by default in the Editor', async ({page}) => {
const playwrightEditorPage = new PlaywrightEditorPage(page);
await playwrightEditorPage.goToEditorPage()

await expect(
playwrightEditorPage.getErrorBox
).not.toBeVisible();
})
})
20 changes: 20 additions & 0 deletions front/tests/pages/editor-page-model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@


/* eslint-disable import/prefer-default-export */
import { expect, Locator, Page } from '@playwright/test';

export class PlaywrightEditorPage {
// The current page object
readonly page: Page;
readonly getErrorBox: Locator;

constructor(page: Page) {
this.page = page;
this.getErrorBox = page.locator('.error-box');
}
// Navigate to the Home page
async goToEditorPage() {
await this.page.goto('/editor');
}

}
Loading

0 comments on commit ec1e301

Please sign in to comment.