Skip to content

Commit

Permalink
Fix tests because of new DOM structure in Debug tree (#15)
Browse files Browse the repository at this point in the history
* Fix tests because of new DOM structure in Debug tree

* Fix previous commit

* Filtering is now done in a so-called side drawer

* Fix previous commit

* Omit assertion that there are no more than two nested Pipeline nodes

* Correct check that side drawer is gone

* Now it works on my device

---------

Co-authored-by: Martijn Dirkse <martijn@integrationpartners.nl>
  • Loading branch information
mhdirkse and Martijn Dirkse committed Jul 16, 2024
1 parent cf81304 commit 5208567
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Testing
on:
push:
branches:
- master
- main
pull_request:
workflow_dispatch:
jobs:
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/cypress/basic.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ describe('Basic tests', () => {
cy.runInTestAPipeline('Example1a', 'Adapter1a', 'xxx')
cy.runInTestAPipeline('Example1b', 'Adapter1b', 'xxx')
cy.getNumLadybugReports().should('at.least', 2).then(total => {
cy.getNumLadybugReportsForNameFilter('Adapter1a', true).then(reportsA => {
cy.getNumLadybugReportsForNameFilter('Adapter1a').then(reportsA => {
expect(reportsA).not.to.be.undefined
expect(reportsA).to.be.lessThan(total as number)
cy.getNumLadybugReportsForNameFilter('Adapter1b', true).then(reportsB => {
cy.getNumLadybugReportsForNameFilter('Adapter1b').then(reportsB => {
expect(reportsB).to.be.lessThan(total as number)
expect(reportsA + reportsB).to.equal(total)
})
Expand Down
39 changes: 13 additions & 26 deletions cypress/e2e/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ declare namespace Cypress {
getIframeBody(): Chainable<any>
getNumLadybugReports(): Chainable<any>
runInTestAPipeline(config: string, adapter: string, message: string): Chainable<any>
getNumLadybugReportsForNameFilter(name: string, expectReports: boolean): Chainable<number>
getNumLadybugReportsForNameFilter(name: string): Chainable<number>
createReportInLadybug(config: string, adapter: string, message: string): Chainable<number>
getAllStorageIdsInTable(): Chainable<number[]>
guardedCopyReportToTestTab(alias: string)
Expand Down Expand Up @@ -93,36 +93,23 @@ Cypress.Commands.add('runInTestAPipeline', (config: string, adapter: string, mes
cy.get('[data-cy-test-pipeline="runResult"]').should('contain', 'SUCCESS')
})

Cypress.Commands.add('getNumLadybugReportsForNameFilter', (name, expectReports) => {
// Only works if some reports are expected to be omitted because of the filter
Cypress.Commands.add('getNumLadybugReportsForNameFilter', (name) => {
cy.getNumLadybugReports().then(totalNumReports => {
cy.getIframeBody().find('[data-cy-debug="filter"]').click()
cy.getIframeBody().find('[data-cy-debug="tableFilterRow"]')
cy.getIframeBody().find('[data-cy-debug="tableFilter"]:eq(3)')
cy.getIframeBody().find('app-filter-side-drawer').find('label:contains(Name)')
.parent().find('input')
.type(name + '{enter}')
if (expectReports) {
cy.getIframeBody().find('[data-cy-debug="tableBody"] tr').then(nodes => {
wrapUp(totalNumReports, nodes.length)
cy.getIframeBody().find('[data-cy-debug="tableBody"] tr').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('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)
})
} else {
cy.getIframeBody().find('[data-cy-debug="tableBody"] tr').should('not.exist').then(() => {
wrapUp(totalNumReports, 0)
})
}
})

function wrapUp (totalNumReports, filteredNumReports: number): Cypress.Chainable<number> {
cy.getIframeBody().find('[data-cy-debug="tableFilter"]:eq(3)')
.clear()
.type('{enter}')
if (totalNumReports === 0) {
cy.getIframeBody().find('[data-cy-debug="tableBody"] tr').should('not.exist')
} else {
cy.getIframeBody().find('[data-cy-debug="tableBody"] tr').should('have.length', totalNumReports)
}
cy.getIframeBody().find('[data-cy-debug="filter"]').click()
cy.getIframeBody().find('[data-cy-debug="tableFilterRow"]').should('not.exist')
return cy.wrap(filteredNumReports)
}
})

Cypress.Commands.add('createReportInLadybug', (config: string, adapter: string, message: string) => {
Expand Down
6 changes: 5 additions & 1 deletion cypress/e2e/cypress/testing.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ describe('Test user stories about testing with Ladybug', () => {
cy.wrap($cell).click()
}
})
cy.getIframeBody().find('[data-cy-debug-tree="root"] .jqx-tree-dropdown-root > li').should('have.length', 1)
cy.getIframeBody().find('[data-cy-debug-tree="root"]')
.contains('Pipeline Adapter1a').within(_ => {
cy.contains('Pipeline Adapter1a')
// TODO: Check that there is no 'Pipeline Adapter1a' inside of this anymore
})
cy.guardedCopyReportToTestTab('apiCopyTheReportToTestTab')
cy.checkTestTabHasReportNamed('Pipeline Adapter1a').as('testTabReportRow')
.find('[data-cy-test="runReport"]').click()
Expand Down

0 comments on commit 5208567

Please sign in to comment.