textarea-visuals.cy.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. import './hide-scroll.css'
  7. const longText =
  8. 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vestibulum sem quis purus elementum pulvinar. Quisque placerat nibh et dignissim tincidunt. Morbi semper tortor at dolor mollis laoreet. Aenean fringilla fermentum leo non finibus. Nulla porttitor lacus diam, at vestibulum risus viverra a'
  9. describe('testing visuals for "FieldTextarea"', () => {
  10. it('renders basic textarea', () => {
  11. mountFormField('textarea', { label: 'textarea' })
  12. checkFormMatchesSnapshot()
  13. cy.get('textarea')
  14. .click()
  15. .then(() => {
  16. checkFormMatchesSnapshot()
  17. })
  18. cy.get('textarea')
  19. .type('Some Text')
  20. .then(() => {
  21. checkFormMatchesSnapshot()
  22. })
  23. })
  24. it(`renders required textarea`, () => {
  25. mountFormField('textarea', { label: 'textarea', required: true })
  26. checkFormMatchesSnapshot()
  27. cy.get('textarea')
  28. .focus()
  29. .then(() => {
  30. checkFormMatchesSnapshot()
  31. })
  32. cy.get('textarea')
  33. .type('Some Text')
  34. .then(() => {
  35. checkFormMatchesSnapshot()
  36. })
  37. })
  38. it('renders invalid textarea', () => {
  39. mountFormField('textarea', {
  40. label: 'textarea',
  41. required: true,
  42. validationVisibility: FormValidationVisibility.Live,
  43. })
  44. checkFormMatchesSnapshot()
  45. })
  46. it('renders textarea with help', () => {
  47. mountFormField('textarea', {
  48. label: 'textarea',
  49. help: 'Help Message!',
  50. })
  51. checkFormMatchesSnapshot()
  52. })
  53. it(`renders disabled textarea`, () => {
  54. mountFormField('textarea', { label: 'textarea', disabled: true })
  55. checkFormMatchesSnapshot()
  56. })
  57. it('scrolled textarea has correct label', () => {
  58. mountFormField('textarea', { label: 'textarea', value: longText })
  59. checkFormMatchesSnapshot()
  60. cy.get('textarea')
  61. .scrollTo('bottom')
  62. .then(() => {
  63. checkFormMatchesSnapshot()
  64. })
  65. })
  66. it(`renders hidden textarea`, () => {
  67. mountFormField('textarea', { label: 'textarea', labelSrOnly: true })
  68. checkFormMatchesSnapshot()
  69. cy.get('textarea')
  70. .type('Some text')
  71. .then(() => {
  72. checkFormMatchesSnapshot({ subTitle: 'filled' })
  73. })
  74. })
  75. })