From 493d23193d359eeee8fa7d4620715c43ee3c432b Mon Sep 17 00:00:00 2001 From: choucw045 Date: Fri, 10 Jan 2025 14:24:22 +0800 Subject: [PATCH] Revert "refactor e2e download check steps" This reverts commit d212183fc2a8289a146e132263492bd69e39cebc. --- e2e_test/config/common.ts | 10 +++++++-- e2e_test/start/downloadChecker.ts | 22 -------------------- e2e_test/start/index.ts | 2 -- e2e_test/step_definitions/notebook_export.ts | 12 +++++------ 4 files changed, 14 insertions(+), 32 deletions(-) delete mode 100644 e2e_test/start/downloadChecker.ts diff --git a/e2e_test/config/common.ts b/e2e_test/config/common.ts index 5dcea4db8..393e9c711 100644 --- a/e2e_test/config/common.ts +++ b/e2e_test/config/common.ts @@ -7,7 +7,13 @@ import createBundler from '@bahmutov/cypress-esbuild-preprocessor' import fs from 'fs' import path from 'path' import AdmZip from 'adm-zip' -import { ExpectedFile } from '../start/downloadChecker' + +interface ExpectedFile { + Filename: string + Format: string + Content?: string + validateMetadata?: boolean +} const commonConfig = { chromeWebSecurity: false, @@ -70,7 +76,7 @@ const commonConfig = { return checker(retryCount) }, checkDownloadedZipContent(expectedFiles: ExpectedFile[]) { - const downloadsFolder = config.downloadsFolder + const downloadsFolder = config.downloadsFolder || 'cypress/downloads' const files = fs.readdirSync(downloadsFolder) const zipFile = files.find((file) => file.endsWith('.zip')) diff --git a/e2e_test/start/downloadChecker.ts b/e2e_test/start/downloadChecker.ts deleted file mode 100644 index 8ef25375d..000000000 --- a/e2e_test/start/downloadChecker.ts +++ /dev/null @@ -1,22 +0,0 @@ -/// - -export interface ExpectedFile { - Filename: string - Format: string - Content: string - validateMetadata?: boolean -} - -const downloadChecker = () => { - return { - checkDownloadFiles() { - return { - hasZipFileWith(files: ExpectedFile[]) { - return cy.task('checkDownloadedZipContent', files) - }, - } - }, - } -} - -export default downloadChecker \ No newline at end of file diff --git a/e2e_test/start/index.ts b/e2e_test/start/index.ts index 80f20697d..dbdbf0e28 100644 --- a/e2e_test/start/index.ts +++ b/e2e_test/start/index.ts @@ -7,7 +7,6 @@ import { assimilation } from './pageObjects/assimilationPage' import { recall } from './pageObjects/recallPage' import { assumeCirclePage } from './pageObjects/circlePage' import { notebookCard } from './pageObjects/notebookCard' -import downloadChecker from './downloadChecker' const start = { ...basicActions, @@ -18,7 +17,6 @@ const start = { recall, assumeCirclePage, notebookCard, - ...downloadChecker(), expectToast(message: string) { cy.get('.Vue-Toastification__toast-body', { timeout: 10000 }) .should('be.visible') diff --git a/e2e_test/step_definitions/notebook_export.ts b/e2e_test/step_definitions/notebook_export.ts index 5e3451189..4f4d272eb 100644 --- a/e2e_test/step_definitions/notebook_export.ts +++ b/e2e_test/step_definitions/notebook_export.ts @@ -5,7 +5,6 @@ import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor' import type { DataTable } from '@cucumber/cucumber' import start from '../start' -import type { ExpectedFile } from '../start/downloadChecker' // First step already exists in user.ts: // Given('I am logged in as an existing user', () => { @@ -37,12 +36,13 @@ When( Then('I should receive a zip file containing', (table: DataTable) => { const expectedFiles = table.hashes().map((file) => ({ - Filename: file.Filename || '', - Format: file.Format || '', - Content: file.Content || '', - validateMetadata: true + Filename: file.Filename, + Format: file.Format, + Content: file.Content, + validateMetadata: true, // Add flag to check for metadata })) - start.checkDownloadFiles().hasZipFileWith(expectedFiles) + + cy.task('checkDownloadedZipContent', expectedFiles) }) Given('I have an empty notebook titled {string}', (notebookTitle: string) => {