Skip to content

Commit

Permalink
fix: fix cypress tests and color/icon buttons (#402)
Browse files Browse the repository at this point in the history
* fix(color-icon-picker): fix to not submit form when color/icon is clicked

* fix(test): fix cypress tests

* fix: fix workflow file
  • Loading branch information
Birkbjo authored Jun 7, 2024
1 parent 7724823 commit 251d76c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dhis2-verify-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
with:
token: ${{ secrets.DHIS2_BOT_GITHUB_TOKEN }}

- uses: actions/setup-node@v3
- uses: actions/setup-node@v3
with:
node-version: 16

Expand Down
26 changes: 7 additions & 19 deletions cypress/e2e/dataElements/New.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ describe('Data elements', () => {
cy.get('[data-test="formfields-shortname-content"] input').type(
`shortname ${now}`
)

// verify default catcombo is selected
cy.get(
'[data-test="formfields-categorycombo"] [data-test="dhis2-uicore-select-input"]'
).click()
cy.get(
'[data-test="dhis2-uicore-singleselectoption"]:contains("None")'
).click()
).should('contain', 'None')

// Submit form
cy.get('button:contains("Create data element")').click()
Expand Down Expand Up @@ -105,23 +104,15 @@ describe('Data elements', () => {
'[data-test="dhis2-uicore-singleselectoption"]:contains("Sum")'
).click()

// Select category combo
cy.get(
'[data-test="formfields-categorycombo"] [data-test="dhis2-uicore-select-input"]'
).click()
cy.get(
'[data-test="dhis2-uicore-singleselectoption"]:contains("None")'
).click()

// Select category combo
// Select option set
cy.get(
'[data-test="formfields-optionset"] [data-test="dhis2-uicore-select-input"]'
).click()
cy.get(
'[data-test="dhis2-uicore-singleselectoption"]:contains("ARV drugs")'
).click()

// Select category combo
// Select comment optionset combo
cy.get(
'[data-test="formfields-commentoptionset"] [data-test="dhis2-uicore-select-input"]'
).click()
Expand Down Expand Up @@ -191,19 +182,16 @@ describe('Data elements', () => {
// Submit form
cy.get('button:contains("Create data element")').click()

// Should have required errors for name, shortname and cat combo
// Should have required errors for name, shortname
cy.get('[data-test$="-validation"]:contains("Required")').should(
'have.length',
3
2
)
cy.get(
'[data-test="formfields-name-validation"]:contains("Required")'
).should('exist')
cy.get(
'[data-test="formfields-shortname-validation"]:contains("Required")'
).should('exist')
cy.get(
'[data-test="formfields-categorycombo-validation"]:contains("Required")'
).should('exist')
})
})
1 change: 1 addition & 0 deletions src/components/ColorAndIconPicker/ColorPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function ColorPicker({
return (
<>
<button
type="button"
ref={ref}
onClick={() => setShowPicker(true)}
className={cx(classes.container, {
Expand Down
1 change: 1 addition & 0 deletions src/components/ColorAndIconPicker/IconPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function IconPicker({
return (
<>
<button
type="button"
onClick={() => setShowPicker(true)}
className={cx(classes.container, {
[classes.hasIcon]: !!icon,
Expand Down

0 comments on commit 251d76c

Please sign in to comment.