Skip to content

Commit

Permalink
front: add e2e tests search and filter rolling stock
Browse files Browse the repository at this point in the history
  • Loading branch information
Maymanaf committed Jul 5, 2024
1 parent 3d68871 commit ec84144
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions front/tests/009-rollingstock-editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ test.describe('Rollingstock editor page', () => {
await findAndDeleteRollingStock(uniqueRollingStockName);
await findAndDeleteRollingStock(uniqueUpdatedRollingStockName);
await findAndDeleteRollingStock(uniqueDeletedRollingStockName);
await findAndDeleteRollingStock(thermalElectricRollingStockName);
});

test.afterEach(async () => {
Expand Down
1 change: 0 additions & 1 deletion front/tests/assets/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export const getRollingStock = async () => {
) as RollingStock;
return rollingStock;
};

// Find and delete rolling stock with the given name
export async function findAndDeleteRollingStock(rollingStockName: string) {
const rollingStocks = await getApiRequest(`/api/light_rolling_stock/`, { page_size: 500 });
Expand Down
37 changes: 36 additions & 1 deletion front/tests/pages/rollingstock-editor-page-model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, type Locator, type Page } from '@playwright/test';

import PlaywrightCommonPage from './common-page-model';
import { fillAndCheckInputById } from '../assets/utils';
import { fillAndCheckInputById, extractNumberFromString } from '../assets/utils';

export default class PlaywrightRollingstockEditorPage extends PlaywrightCommonPage {
readonly getNewRollingstockButton: Locator;
Expand Down Expand Up @@ -42,6 +42,26 @@ export default class PlaywrightRollingstockEditorPage extends PlaywrightCommonPa

readonly getDeleteRollingStockButton: Locator;

readonly getElectricRollingStockFilter: Locator;

readonly getThermalRollingStockFilter: Locator;

readonly getRollingStockSearchResult: Locator;

readonly getThermalRollingStockIcons: Locator;

readonly getElectricRollingStockIcons: Locator;

readonly getElectricRollingStockFirstIcon: Locator;

readonly getThermalRollingStockFirstIcon: Locator;

readonly getRollingStockList: Locator;

readonly getThermalElectricRollingStockIcons: Locator;

readonly getNoRollingStockResult: Locator;

constructor(page: Page) {
super(page);
this.getNewRollingstockButton = page.getByTestId('new-rollingstock-button');
Expand Down Expand Up @@ -295,4 +315,19 @@ export default class PlaywrightRollingstockEditorPage extends PlaywrightCommonPa
await this.getDeleteRollingStockButton.click();
await this.getConfirmModalButtonYes.click();
}

// Select Combustion engine RS filter
async themalRollingStockFilter() {
await this.getThermalRollingStockFilter.click();
}

// Select Electic RS filter
async electricRollingStockFilter() {
await this.getElectricRollingStockFilter.click();
}

// Get the number of RS from the search result text
async getRollingStockSearchNumber(): Promise<number> {
return extractNumberFromString(await this.getRollingStockSearchResult.innerText());
}
}

0 comments on commit ec84144

Please sign in to comment.