From 2f19b522510dc48594989604982e960e6c56b6a7 Mon Sep 17 00:00:00 2001 From: Camille Moinier Date: Thu, 7 Dec 2023 16:53:48 +0100 Subject: [PATCH] fix(e2e): fix e2e test --- .../src/e2e/datasetDetailPage.cy.ts | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts b/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts index 0a0c695e94..d23edbb3a2 100644 --- a/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts +++ b/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts @@ -373,15 +373,30 @@ describe('dataset pages', () => { }) }) it('downloads a file on click', () => { + // cy.get('datahub-record-downloads') + // .find('gn-ui-download-item') + // .first() + // .click() + // // eslint-disable-next-line cypress/no-unnecessary-waiting + // cy.wait(3000) + // cy.exec('ls cypress/downloads').then((result) => { + // const fileList = result.stdout.split('\n') + + // const isFileDownloaded = fileList[0] + // expect(/\S/.test(isFileDownloaded)).to.be.true + // }) + cy.intercept( + 'GET', + 'https://www.geo2france.fr/geoserver/insee/ows?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=insee%3Arectangles_200m_menage_erbm&OUTPUTFORMAT=csv' + ).as('downloadRequest') // Replace with your download URL + cy.get('datahub-record-downloads') .find('gn-ui-download-item') .first() .click() - cy.exec('ls cypress/downloads').then((result) => { - const fileList = result.stdout.split('\n') - const isFileDownloaded = fileList[0] - expect(/\S/.test(isFileDownloaded)).to.be.true + cy.wait('@downloadRequest').then((interception) => { + expect(interception.response.statusCode).to.equal(200) // Check if the download request was successful }) }) it('displays the full list after clicking two times on one filter', () => {