Skip to content

Commit

Permalink
fix: checked not testable html attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
awesthouse committed Dec 13, 2024
1 parent 4afa9a2 commit 58747c6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('BooleanField', () => {
const inputNode: Element | null =
container.querySelector(` input[id="foo"]`)
expect(inputNode).toBeDefined()
const value = inputNode !== null ? inputNode.getAttribute('checked') : ''
const value = inputNode !== null ? inputNode.getAttribute('data-test-checked') : ''
expect(value).toBe('true')

})
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('BooleanField', () => {
const inputNode: Element | null =
container.querySelector(` input[id="foo"]`)
expect(inputNode).toBeDefined()
const value = inputNode !== null ? inputNode.getAttribute('checked') : ''
const value = inputNode !== null ? inputNode.getAttribute('data-test-checked') : ''
expect(value).toBe('true')
userEvent.click(screen.getByTestId('form-checkbox'))
fireEvent.click(screen.getByTestId('form-submit'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ test('should show foo after bar if order states it', async () => {
test('should handle a default object value', async () => {
const utils = await setupSimple({ idReference: 'ds/$1', type: 'MyBlueprint' })
expect(utils.fooInput.getAttribute('value')).toBe('beep')
expect(utils.barInput.getAttribute('value')).toBe('false')
expect(utils.barInput.getAttribute('data-test-checked')).toBe('false')
})

test('should handle object fields change events', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const CheckboxWidget = (props: TWidget) => {
ref={inputRef}
disabled={readOnly}
checked={value !== undefined ? value : false}
type='checkbox'
data-test-checked={value !== undefined ? value : false}
data-testid='form-checkbox'
/>
</span>
Expand Down

0 comments on commit 58747c6

Please sign in to comment.