Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

front: don't use front/tests/ to write PDF files #10718

Merged
merged 1 commit into from
Feb 7, 2025
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
12 changes: 7 additions & 5 deletions front/tests/013-stdcm-simulation-sheet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ test.describe('Verify stdcm simulation page', () => {
await waitForInfraStateToBeCached(infra.id);
});

let downloadDir: string | undefined;

/** *************** Test 1 **************** */
test('Verify STDCM stops and simulation sheet', async ({ browserName, context }) => {
test('Verify STDCM stops and simulation sheet', async ({ browserName, context }, testInfo) => {
// Populate STDCM page with origin, destination, and via details
await stdcmPage.fillAndVerifyConsistDetails(
consistDetails,
Expand Down Expand Up @@ -77,7 +79,8 @@ test.describe('Verify stdcm simulation page', () => {
await stdcmPage.displayAllOperationalPoints();
await stdcmPage.verifyTableData('./tests/assets/stdcm/stdcmWithAllVia.json');
await stdcmPage.retainSimulation();
await stdcmPage.downloadSimulation(browserName);
downloadDir = testInfo.outputDir;
await stdcmPage.downloadSimulation(downloadDir);
// Reset and verify empty fields
const [newPage] = await Promise.all([context.waitForEvent('page'), stdcmPage.startNewQuery()]);
await newPage.waitForLoadState();
Expand All @@ -86,9 +89,8 @@ test.describe('Verify stdcm simulation page', () => {
});

/** *************** Test 2 **************** */
test('Verify simulation sheet content', async ({ browserName }) => {
const downloadDir = `./tests/stdcm-results/${browserName}`;
const pdfFilePath = findFirstPdf(downloadDir);
test('Verify simulation sheet content', async () => {
const pdfFilePath = findFirstPdf(downloadDir!);

if (!pdfFilePath) {
throw new Error(`No PDF files found in directory: ${downloadDir}`);
Expand Down
8 changes: 4 additions & 4 deletions front/tests/014-stdcm-linked-train.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test.describe('Verify stdcm simulation page', () => {
});

/** *************** Test 1 **************** */
test('Verify STDCM anterior linked train', async ({ browserName }) => {
test('Verify STDCM anterior linked train', async ({}, testInfo) => {
await stdcmPage.fillAndVerifyConsistDetails(
towedConsistDetails,
fastRollingStockPrefilledValues.tonnage,
Expand All @@ -72,11 +72,11 @@ test.describe('Verify stdcm simulation page', () => {
'./tests/assets/stdcm/linkedTrain/anteriorLinkedTrainTable.json'
);
await stdcmPage.retainSimulation();
await stdcmPage.downloadSimulation(browserName, true);
await stdcmPage.downloadSimulation(testInfo.outputDir);
});

/** *************** Test 2 **************** */
test('Verify STDCM posterior linked train', async ({ browserName }) => {
test('Verify STDCM posterior linked train', async ({}, testInfo) => {
await stdcmPage.fillAndVerifyConsistDetails(
towedConsistDetails,
fastRollingStockPrefilledValues.tonnage,
Expand All @@ -97,6 +97,6 @@ test.describe('Verify stdcm simulation page', () => {
'./tests/assets/stdcm/linkedTrain/posteriorLinkedTrainTable.json'
);
await stdcmPage.retainSimulation();
await stdcmPage.downloadSimulation(browserName, true);
await stdcmPage.downloadSimulation(testInfo.outputDir);
});
});
5 changes: 1 addition & 4 deletions front/tests/pages/stdcm-page-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ class STDCMPage extends HomePage {
await expect(this.startNewQueryWithDataButton).toBeVisible();
}

async downloadSimulation(browserName: string, isLinkedTrain: boolean = false): Promise<void> {
async downloadSimulation(downloadDir: string): Promise<void> {
try {
// Wait until there are no network requests for stability
await this.page.waitForLoadState('networkidle');
Expand All @@ -720,9 +720,6 @@ class STDCMPage extends HomePage {
const suggestedFilename = await this.downloadLink.getAttribute('download');
expect(suggestedFilename).toMatch(/^Stdcm.*\.pdf$/);

const downloadDir = isLinkedTrain
? path.join('./tests/stdcm-results/linkedTrain', browserName)
: path.join('./tests/stdcm-results', browserName);
const downloadPath = path.join(downloadDir, suggestedFilename!);

await fs.promises.mkdir(downloadDir, { recursive: true });
Expand Down
Loading