Skip to content

Commit

Permalink
test: assert on patch request
Browse files Browse the repository at this point in the history
  • Loading branch information
ismay committed Oct 14, 2024
1 parent 92b6083 commit ac1b8e8
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions cypress/e2e/dataElements/Edit.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
const saveAndExpect = (expected) => {
cy.intercept({ pathname: /dataElements/, method: 'PATCH' }, (req) => {
expect(req.body).to.deep.equal(expected)
req.reply({ statusCode: 200 })
})

cy.get('button:contains("Save and close")').click()
}

describe('Data elements / Edit', () => {
it('should change a value', () => {
const now = Date.now()
Expand Down Expand Up @@ -28,20 +37,13 @@ describe('Data elements / Edit', () => {
.clear()
.type(`description ${now}`)

// Submit form
cy.get('button:contains("Save and close")').click()

// cy.contains('Data element management').should('exist')

// Go to Edit form
cy.get('[data-test="dhis2-uicore-tablebody"] tr:first-child')
.find('td:last-child a')
.click()

cy.get('[data-test="formfields-description"] textarea').should(
'have.value',
`description ${now}`
)
saveAndExpect([
{
op: 'replace',
path: '/description',
value: `description ${now}`,
},
])
})

// it('should not submit successfully when a required value has been removed', () => {
Expand Down

0 comments on commit ac1b8e8

Please sign in to comment.