Skip to content

Commit

Permalink
Revert "refactor e2e download check steps"
Browse files Browse the repository at this point in the history
This reverts commit d212183.
  • Loading branch information
choucw045 committed Jan 10, 2025
1 parent 1c2373a commit 493d231
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 32 deletions.
10 changes: 8 additions & 2 deletions e2e_test/config/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'))

Expand Down
22 changes: 0 additions & 22 deletions e2e_test/start/downloadChecker.ts

This file was deleted.

2 changes: 0 additions & 2 deletions e2e_test/start/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -18,7 +17,6 @@ const start = {
recall,
assumeCirclePage,
notebookCard,
...downloadChecker(),
expectToast(message: string) {
cy.get('.Vue-Toastification__toast-body', { timeout: 10000 })
.should('be.visible')
Expand Down
12 changes: 6 additions & 6 deletions e2e_test/step_definitions/notebook_export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit 493d231

Please sign in to comment.