From b4cb4b14389e65160c317bc10dbec209d1526533 Mon Sep 17 00:00:00 2001 From: Martijn Dirkse Date: Mon, 5 Aug 2024 19:39:03 +0200 Subject: [PATCH 1/2] Work in progress - make test succeed after updates of ladybug-frontend --- cypress/e2e/cypress/support/commands.ts | 14 ++++++-------- cypress/e2e/cypress/testing.cy.ts | 6 +++--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cypress/e2e/cypress/support/commands.ts b/cypress/e2e/cypress/support/commands.ts index c6ea2b2..1dda039 100644 --- a/cypress/e2e/cypress/support/commands.ts +++ b/cypress/e2e/cypress/support/commands.ts @@ -72,7 +72,7 @@ Cypress.Commands.add('getNumLadybugReports', () => { // // cy.getIframeBody().find('[data-cy-debug="amountShown"]') // .should('equal', "/" + count); - cy.getIframeBody().find('[data-cy-debug="tableBody"] tr') + cy.getIframeBody().find('[data-cy-debug="tableRow"]') .should('have.length', count) return cy.wrap(count) }) @@ -100,11 +100,11 @@ Cypress.Commands.add('getNumLadybugReportsForNameFilter', (name) => { cy.getIframeBody().find('app-filter-side-drawer').find('label:contains(Name)') .parent().find('input') .type(name + '{enter}') - cy.getIframeBody().find('[data-cy-debug="tableBody"] tr').its('length') + cy.getIframeBody().find('[data-cy-debug="tableRow"]').its('length') .should('be.lessThan', totalNumReports).then(result => { cy.getIframeBody().find('app-filter-side-drawer').find('label:contains(Name)') .parent().find('button:contains(Clear)').click() - cy.getIframeBody().find('[data-cy-debug="tableBody"] tr').should('have.length', totalNumReports) + cy.getIframeBody().find('[data-cy-debug="tableRow"]').should('have.length', totalNumReports) cy.getIframeBody().find('app-filter-side-drawer').find('button:contains(Close)').click() cy.getIframeBody().find('app-filter-side-drawer').find('label').should('not.exist') return cy.wrap(result) @@ -126,7 +126,7 @@ Cypress.Commands.add('createReportInLadybug', (config: string, adapter: string, Cypress.Commands.add('getAllStorageIdsInTable', () => { const storageIds: number[] = [] - cy.getIframeBody().find('[data-cy-debug="tableBody"]').find('tr').each($row => { + cy.getIframeBody().find('[data-cy-debug="tableRow"]').each($row => { cy.wrap($row).find('td:eq(1)').invoke('text').then(s => { storageIds.push(parseInt(s)) }) @@ -139,7 +139,6 @@ Cypress.Commands.add('getAllStorageIdsInTable', () => { Cypress.Commands.add('guardedCopyReportToTestTab', (alias) => { cy.intercept({ method: 'PUT', - hostname: 'localhost', url: /\/api\/report\/store\/*?/g, times: 1 }).as(alias) @@ -155,11 +154,10 @@ Cypress.Commands.add('guardedCopyReportToTestTab', (alias) => { Cypress.Commands.add('checkTestTabHasReportNamed', (name) => { cy.intercept({ method: 'GET', - hostname: 'localhost', - url: /\/iaf\/ladybug\/api\/metadata\/Test*/g + url: '/iaf/ladybug/api/metadata/Test/?' }).as('apiGetTestReports') cy.getIframeBody().find('[data-cy-nav-tab="testTab"]').click() - cy.wait('@apiGetTestReports') + // cy.wait('@apiGetTestReports', { timeout: 10000 }) cy.getIframeBody().find('[data-cy-test="table"] tr') .should('have.length', 1) .as('testtabReportRow') diff --git a/cypress/e2e/cypress/testing.cy.ts b/cypress/e2e/cypress/testing.cy.ts index 58b99b7..8b2ea76 100644 --- a/cypress/e2e/cypress/testing.cy.ts +++ b/cypress/e2e/cypress/testing.cy.ts @@ -11,8 +11,8 @@ describe('Test user stories about testing with Ladybug', () => { it('Run report', () => { cy.createReportInLadybug('Example1a', 'Adapter1a', 'xxx').then(storageId => { - cy.getIframeBody().find('[data-cy-debug="tableBody"]') - .find('tr > td:nth-child(2)').each($cell => { + cy.getIframeBody().find('[data-cy-debug="tableRow"]') + .find('td:nth-child(2)').each($cell => { if (parseInt($cell.text()) === storageId) { cy.wrap($cell).click() } @@ -26,7 +26,7 @@ describe('Test user stories about testing with Ladybug', () => { cy.checkTestTabHasReportNamed('Pipeline Adapter1a').as('testTabReportRow') .find('[data-cy-test="runReport"]').click() // TODO: Use data-cy. This can only be done if there is a data-cy* tag to request - cy.get('@testTabReportRow').find('td:eq(4)').should('contain', 'stubbed') + cy.get('@testTabReportRow').find('td:eq(5)').should('contain', 'stubbed') }) }) }) From 80a685e9d6d7e23758bed2674060a3cfc2a37a32 Mon Sep 17 00:00:00 2001 From: Martijn Dirkse Date: Mon, 5 Aug 2024 20:28:07 +0200 Subject: [PATCH 2/2] Fix the test again by intercepting earlier --- cypress/e2e/cypress/support/commands.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/cypress/support/commands.ts b/cypress/e2e/cypress/support/commands.ts index 1dda039..09152ea 100644 --- a/cypress/e2e/cypress/support/commands.ts +++ b/cypress/e2e/cypress/support/commands.ts @@ -142,6 +142,10 @@ Cypress.Commands.add('guardedCopyReportToTestTab', (alias) => { url: /\/api\/report\/store\/*?/g, times: 1 }).as(alias) + cy.intercept({ + method: 'GET', + url: /\/iaf\/ladybug\/api\/metadata\/Test*/g + }).as('apiGetTestReports') cy.getIframeBody().find('[data-cy-debug-editor="copy"]').click() cy.wait(`@${alias}`).then((interception) => { cy.wrap(interception).its('request.url').should('contain', 'Test') @@ -149,15 +153,11 @@ Cypress.Commands.add('guardedCopyReportToTestTab', (alias) => { cy.get('@requestBody').its('Debug').should('have.length', 1) cy.wrap(interception).its('response.statusCode').should('equal', 200) }) + cy.wait('@apiGetTestReports', { timeout: 30000 }) }) Cypress.Commands.add('checkTestTabHasReportNamed', (name) => { - cy.intercept({ - method: 'GET', - url: '/iaf/ladybug/api/metadata/Test/?' - }).as('apiGetTestReports') cy.getIframeBody().find('[data-cy-nav-tab="testTab"]').click() - // cy.wait('@apiGetTestReports', { timeout: 10000 }) cy.getIframeBody().find('[data-cy-test="table"] tr') .should('have.length', 1) .as('testtabReportRow')