Skip to content

Commit

Permalink
wip! Add tests for checkboxes and radios with same name
Browse files Browse the repository at this point in the history
  • Loading branch information
lfdebrux committed Jun 22, 2021
1 parent 2c5a334 commit 32f116d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/govuk/components/checkboxes/checkboxes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,34 @@ describe('Checkboxes with a None checkbox and conditional reveals', () => {
})
})
})

describe('Checkboxes with multiple groups and a None checkbox and conditional reveals', () => {
describe('when JavaScript is available', () => {
it('unchecks other checkboxes in other groups', async () => {
await page.goto(`${baseUrl}/examples/conditional-reveals`)
const html = await page.evaluate(() => document.body.innerHTML)
const $ = cheerio.load(html)

// Check the second checkbox in the first group, which reveals additional content
await page.click('#colour-primary-2')

const $checkedInput = $('#colour-primary-2')
const conditionalContentId = $checkedInput.attr('aria-controls')

// Expect conditional reveal to be visible
const isConditionalContentVisible = await waitForVisibleSelector(`[id="${conditionalContentId}"]`)
expect(isConditionalContentVisible).toBeTruthy()

// Check the None checkbox
await page.click('#colour-other-3')

// Expect the second checkbox in the first group to be unchecked
const otherCheckboxIsUnchecked = await waitForVisibleSelector('[id="colour-primary-2"]:not(:checked)')
expect(otherCheckboxIsUnchecked).toBeTruthy()

// Expect conditional content to have been hidden
const isConditionalContentHidden = await waitForHiddenSelector(`[id="${conditionalContentId}"]`)
expect(isConditionalContentHidden).toBeTruthy()
})
})
})

0 comments on commit 32f116d

Please sign in to comment.