123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
- // To update snapshots, run `pnpm cypress:snapshots`
- // DO NOT update snapshots, when running with --open flag (Cypress GUI)
- import { mountFormField, checkFormMatchesSnapshot } from '#cy/utils.ts'
- import { FormValidationVisibility } from '#shared/components/Form/types.ts'
- const options = [
- {
- value: 0,
- label: 'Item A',
- children: [
- {
- value: 1,
- label: 'Item 1',
- children: [
- {
- value: 2,
- label: 'Item I',
- },
- {
- value: 3,
- label: 'Item II',
- },
- {
- value: 4,
- label: 'Item III',
- },
- ],
- },
- {
- value: 5,
- label:
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vestibulum sem quis purus elementum pulvinar.',
- children: [
- {
- value: 6,
- label: 'Item IV',
- },
- ],
- },
- {
- value: 7,
- label: 'Item 3',
- },
- ],
- },
- {
- value: 8,
- label: 'Item B',
- },
- {
- value: 9,
- label: 'Ítem C',
- },
- ]
- const value = 0
- describe('testing visuals for "FieldTreeSelect"', () => {
- it('renders basic disabled select', () => {
- mountFormField('treeselect', {
- label: 'treeselect',
- disabled: true,
- })
- checkFormMatchesSnapshot()
- })
- it('renders basic required select', () => {
- mountFormField('treeselect', {
- label: 'treeselect',
- required: true,
- })
- checkFormMatchesSnapshot()
- })
- it('renders basic invalid treeselect', () => {
- mountFormField('treeselect', {
- label: 'treeselect',
- required: true,
- validationVisibility: FormValidationVisibility.Live,
- })
- checkFormMatchesSnapshot()
- })
- it(`renders focused treeselect`, () => {
- mountFormField('treeselect', { label: 'treeselect' })
- cy.get('output')
- .focus()
- .then(() => {
- checkFormMatchesSnapshot()
- })
- })
- it(`renders focused linked treeselect`, () => {
- mountFormField('treeselect', { label: 'treeselect', link: '/' })
- cy.get('output')
- .focus()
- .then(() => {
- checkFormMatchesSnapshot()
- })
- })
- it('renders linked select', () => {
- mountFormField('treeselect', { label: 'treeselect', link: '/' })
- checkFormMatchesSnapshot()
- })
- it('renders selected select', () => {
- mountFormField('treeselect', { label: 'treeselect', options, value })
- checkFormMatchesSnapshot()
- })
- it('renders selected disabled select', () => {
- mountFormField('treeselect', {
- label: 'treeselect',
- options,
- value,
- disabled: true,
- })
- checkFormMatchesSnapshot()
- })
- it('renders selected required select', () => {
- mountFormField('treeselect', {
- label: 'treeselect',
- options,
- value,
- required: true,
- })
- checkFormMatchesSnapshot()
- })
- it('renders selected select linked', () => {
- mountFormField('treeselect', {
- label: 'treeselect',
- options,
- value,
- link: '/',
- })
- checkFormMatchesSnapshot()
- })
- it('renders multiple selected select', () => {
- mountFormField('treeselect', {
- label: 'treeselect',
- options,
- value: [0, 1],
- multiple: true,
- })
- checkFormMatchesSnapshot()
- })
- it('renders multiple selected disabled select', () => {
- mountFormField('treeselect', {
- label: 'treeselect',
- options,
- value: [0, 1],
- multiple: true,
- disabled: true,
- })
- checkFormMatchesSnapshot()
- })
- it('renders multiple selected required select', () => {
- mountFormField('treeselect', {
- label: 'treeselect',
- options,
- value: [0, 1],
- multiple: true,
- required: true,
- })
- checkFormMatchesSnapshot()
- })
- it('renders long multiple selected', () => {
- mountFormField('treeselect', {
- label: 'treeselect',
- options,
- value: [0, 1, 2, 3, 4, 6, 7, 8],
- multiple: true,
- })
- checkFormMatchesSnapshot()
- })
- it('renders long selected', () => {
- mountFormField('treeselect', {
- label: 'treeselect',
- options,
- value: 5,
- })
- checkFormMatchesSnapshot()
- })
- it(`renders hidden treeselect`, () => {
- mountFormField('treeselect', { label: 'treeselect', labelSrOnly: true })
- checkFormMatchesSnapshot()
- })
- it(`renders treeselect with help`, () => {
- mountFormField('treeselect', { label: 'treeselect', help: 'Help Message!' })
- checkFormMatchesSnapshot()
- })
- it(`renders selected hidden treeselect`, () => {
- mountFormField('treeselect', {
- label: 'treeselect',
- value: 1,
- options,
- labelSrOnly: true,
- })
- checkFormMatchesSnapshot()
- })
- })
|