radio-visuals.cy.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. // To update snapshots, run `yarn cypress:snapshots`
  3. // DO NOT update snapshots, when running with --open flag (Cypress GUI)
  4. import { mountFormField, checkFormMatchesSnapshot } from '#cy/utils.ts'
  5. const radioOptions = [
  6. { label: 'Incoming Phone', value: 1, icon: 'phone-in' },
  7. { label: 'Outgoing Phone', value: 2, icon: 'phone-out' },
  8. { label: 'Send Email', value: 3, icon: 'mail-out' },
  9. ]
  10. describe('testing visuals for "FieldRadio"', () => {
  11. it('renders as buttons', () => {
  12. mountFormField('radio', {
  13. buttons: true,
  14. options: radioOptions,
  15. })
  16. checkFormMatchesSnapshot()
  17. cy.findByText('Incoming Phone')
  18. .click()
  19. .then(() => {
  20. checkFormMatchesSnapshot({ subTitle: 'checked' })
  21. })
  22. })
  23. it('renders as disabled buttons', () => {
  24. mountFormField('radio', {
  25. buttons: true,
  26. disabled: true,
  27. options: radioOptions,
  28. })
  29. checkFormMatchesSnapshot()
  30. })
  31. it(`renders hidden radio`, () => {
  32. mountFormField('radio', { label: 'Radio', labelSrOnly: true })
  33. checkFormMatchesSnapshot()
  34. })
  35. })