Skip to content

Commit

Permalink
Merge pull request #17 from wearefrank/update-for-data-cy-debug-tableRow
Browse files Browse the repository at this point in the history
Update for data-cy-debug="tableRow"
  • Loading branch information
ricklue committed Aug 9, 2024
2 parents a8bd202 + 80a685e commit 0b90573
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
20 changes: 9 additions & 11 deletions cypress/e2e/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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)
Expand All @@ -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))
})
Expand All @@ -139,27 +139,25 @@ Cypress.Commands.add('getAllStorageIdsInTable', () => {
Cypress.Commands.add('guardedCopyReportToTestTab', (alias) => {
cy.intercept({
method: 'PUT',
hostname: 'localhost',
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')
cy.wrap(interception).its('request.body').as('requestBody')
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',
hostname: 'localhost',
url: /\/iaf\/ladybug\/api\/metadata\/Test*/g
}).as('apiGetTestReports')
cy.getIframeBody().find('[data-cy-nav-tab="testTab"]').click()
cy.wait('@apiGetTestReports')
cy.getIframeBody().find('[data-cy-test="table"] tr')
.should('have.length', 1)
.as('testtabReportRow')
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/cypress/testing.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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')
})
})
})

0 comments on commit 0b90573

Please sign in to comment.