Skip to content

Commit

Permalink
test(data element list view): cover filterting by name and pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammer5 committed May 2, 2024
1 parent bb165b4 commit cbc4947
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions cypress/e2e/dataElements/List.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
describe('Data elements / List', () => {
it('should show the second of three pages of all "ART" data elements', () => {
cy.visit('/')

// Open data elements group in side nav
cy.get('[data-test="sidenav"] button:contains("Data elements")', {
timeout: 10000,
}).click()

// Navigate to data element list view
cy.get('[data-test="sidenav"] a:contains("Data element")')
.first() // the selector will also grab "Data element group" and "Data element group set"
.click()

// search
cy.get('[data-test="input-search-name"]').type('ART')

// wait for search result
cy.contains('ART new clients started on ARV').should('exist')

// each data element contains "art" (not case-sensitive)
cy.get('[data-test^="section-list-row-"] > td:nth-child(2)').then(
($nameCells) => {
$nameCells.each((_, nameCell) => {
expect(Cypress.$(nameCell).text()).to.match(/art/i)
})
}
)

// go to second page
cy.get('[data-test="dhis2-uiwidgets-pagination-page-next"]').click()

// wait for second page result
cy.contains('Receiving ART').should('exist')
cy.get(
'[data-test="dhis2-uiwidgets-pagination-page-select-prefix"] + div'
)
.invoke('text')
.should('equal', '2')

// each data element contains "art" (not case-sensitive)
cy.get('[data-test^="section-list-row-"] > td:nth-child(2)').then(
($nameCells) => {
$nameCells.each((_, nameCell) => {
expect(Cypress.$(nameCell).text()).to.match(/art/i)
})
}
)
})
})

0 comments on commit cbc4947

Please sign in to comment.