checkbox-visuals.cy.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. // To update snapshots, run `pnpm cypress:snapshots`
  3. // DO NOT update snapshots, when running with --open flag (Cypress GUI)
  4. import { mountFormField, checkFormMatchesSnapshot } from '#cy/utils.ts'
  5. import { FormValidationVisibility } from '#shared/components/Form/types.ts'
  6. describe('testing visuals for "FieldCheckbox"', () => {
  7. describe('basic checkbox', () => {
  8. it('renders default basic checkbox', () => {
  9. mountFormField('checkbox', { label: 'Checkbox' })
  10. cy.get('.formkit-outer').then(($el) => {
  11. $el.css('min-height', '24px')
  12. checkFormMatchesSnapshot({ subTitle: 'unchecked' })
  13. cy.findByLabelText('Checkbox')
  14. .check()
  15. .then(() => {
  16. checkFormMatchesSnapshot({ subTitle: 'checked' })
  17. })
  18. })
  19. })
  20. it('renders default required checkbox', () => {
  21. mountFormField('checkbox', { label: 'Checkbox', required: true })
  22. cy.get('.formkit-outer').then(($el) => {
  23. $el.css('min-height', '24px')
  24. checkFormMatchesSnapshot()
  25. })
  26. })
  27. it('renders checkbox with help', () => {
  28. mountFormField('checkbox', { label: 'Checkbox', help: 'Help Message!' })
  29. cy.get('.formkit-outer').then(($el) => {
  30. $el.css('min-height', '24px')
  31. checkFormMatchesSnapshot()
  32. })
  33. })
  34. it('renders default invalid checkbox', () => {
  35. mountFormField('checkbox', {
  36. label: 'Checkbox',
  37. required: true,
  38. validationVisibility: FormValidationVisibility.Live,
  39. })
  40. cy.get('.formkit-outer').then(($el) => {
  41. $el.css('min-height', '24px')
  42. checkFormMatchesSnapshot()
  43. })
  44. })
  45. it('renders default disabled checkbox', () => {
  46. mountFormField('checkbox', { label: 'Checkbox', disabled: true })
  47. cy.get('.formkit-outer').then(($el) => {
  48. $el.css('min-height', '24px')
  49. checkFormMatchesSnapshot()
  50. })
  51. })
  52. it(`renders hidden checkbox`, () => {
  53. mountFormField('checkbox', { label: 'Checkbox', labelSrOnly: true })
  54. checkFormMatchesSnapshot()
  55. })
  56. })
  57. })