|
| 1 | +import { test } from '@playwright/test'; |
| 2 | + |
| 3 | +import { assertScreenshot, fillForm, runBeforeEach, testDraftValues } from '../utils'; |
| 4 | +import { MockMessageFormProps } from '../__fixtures__/form/interface'; |
| 5 | + |
| 6 | +runBeforeEach(); |
| 7 | + |
| 8 | +// 201: Form with one text input (no fill), one text area input (no fill), and one chip input (no select) |
| 9 | +test('201', async ({ page }) => { |
| 10 | + const form: MockMessageFormProps = { |
| 11 | + name: 'test form', |
| 12 | + items: [ |
| 13 | + { |
| 14 | + name: 'Text form', |
| 15 | + required: true, |
| 16 | + sort_order: 0, |
| 17 | + placeholder: 'Text hint', |
| 18 | + style: { |
| 19 | + layout: 'text', |
| 20 | + }, |
| 21 | + draft_values: [], |
| 22 | + }, |
| 23 | + { |
| 24 | + name: 'Textarea form', |
| 25 | + required: true, |
| 26 | + sort_order: 0, |
| 27 | + placeholder: 'Textarea hint', |
| 28 | + style: { |
| 29 | + layout: 'textarea', |
| 30 | + }, |
| 31 | + }, |
| 32 | + { |
| 33 | + name: 'Chip form', |
| 34 | + required: true, |
| 35 | + sort_order: 0, |
| 36 | + style: { |
| 37 | + layout: 'chip', |
| 38 | + options: [ |
| 39 | + 'Chip1', |
| 40 | + 'Chip2', |
| 41 | + 'Chip3', |
| 42 | + 'Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4' |
| 43 | + + 'Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4', |
| 44 | + ], |
| 45 | + }, |
| 46 | + }, |
| 47 | + ], |
| 48 | + }; |
| 49 | + await fillForm(page, JSON.stringify(form)); |
| 50 | + await testDraftValues(page, form); |
| 51 | + await assertScreenshot(page); |
| 52 | +}); |
| 53 | + |
| 54 | +// 202: Form with one text input (no fill), one text input (no fill, not required) |
| 55 | +test('202', async ({ page }) => { |
| 56 | + const form: MockMessageFormProps = { |
| 57 | + name: 'test form', |
| 58 | + items: [ |
| 59 | + { |
| 60 | + name: 'Text form 1', |
| 61 | + required: true, |
| 62 | + sort_order: 0, |
| 63 | + placeholder: 'Text 1 hint', |
| 64 | + style: { |
| 65 | + layout: 'text', |
| 66 | + }, |
| 67 | + }, |
| 68 | + { |
| 69 | + name: 'Text form 1', |
| 70 | + required: false, |
| 71 | + sort_order: 1, |
| 72 | + placeholder: 'Text 2 hint', |
| 73 | + style: { |
| 74 | + layout: 'text', |
| 75 | + }, |
| 76 | + }, |
| 77 | + ], |
| 78 | + }; |
| 79 | + await fillForm(page, JSON.stringify(form)); |
| 80 | + await testDraftValues(page, form); |
| 81 | + await assertScreenshot(page); |
| 82 | +}); |
| 83 | + |
| 84 | +// 203: Form with one text area input (no fill), one text area input (no fill, not required) and one chip input (no select) |
| 85 | +test('203', async ({ page }) => { |
| 86 | + const form: MockMessageFormProps = { |
| 87 | + name: 'test form', |
| 88 | + items: [ |
| 89 | + { |
| 90 | + name: 'Textarea form 1', |
| 91 | + required: true, |
| 92 | + sort_order: 0, |
| 93 | + placeholder: 'Textarea 1 hint', |
| 94 | + style: { |
| 95 | + layout: 'textarea', |
| 96 | + }, |
| 97 | + }, |
| 98 | + { |
| 99 | + name: 'Textarea form 2', |
| 100 | + required: false, |
| 101 | + sort_order: 1, |
| 102 | + placeholder: 'Textarea 2 hint', |
| 103 | + style: { |
| 104 | + layout: 'textarea', |
| 105 | + }, |
| 106 | + }, |
| 107 | + ], |
| 108 | + }; |
| 109 | + await fillForm(page, JSON.stringify(form)); |
| 110 | + await testDraftValues(page, form); |
| 111 | + await assertScreenshot(page); |
| 112 | +}); |
| 113 | + |
| 114 | +// 204: Form with one chip input (no select), and one chip input (select one chip) |
| 115 | +test('204', async ({ page }) => { |
| 116 | + const form: MockMessageFormProps = { |
| 117 | + name: 'test form', |
| 118 | + items: [ |
| 119 | + { |
| 120 | + name: 'Chip form 1', |
| 121 | + required: true, |
| 122 | + sort_order: 0, |
| 123 | + style: { |
| 124 | + layout: 'chip', |
| 125 | + options: [ |
| 126 | + 'Chip1', |
| 127 | + 'Chip2', |
| 128 | + 'Chip3', |
| 129 | + 'Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4Chip4', |
| 130 | + ], |
| 131 | + }, |
| 132 | + }, |
| 133 | + { |
| 134 | + name: 'Chip form 2', |
| 135 | + required: true, |
| 136 | + sort_order: 1, |
| 137 | + style: { |
| 138 | + layout: 'chip', |
| 139 | + options: [ |
| 140 | + 'Chip5', |
| 141 | + 'Chip6', |
| 142 | + 'Chip7', |
| 143 | + 'Chip8', |
| 144 | + ], |
| 145 | + default_options: [ |
| 146 | + 'Chip5', |
| 147 | + ], |
| 148 | + }, |
| 149 | + }, |
| 150 | + { |
| 151 | + name: 'Chip form 3', |
| 152 | + required: true, |
| 153 | + sort_order: 2, |
| 154 | + style: { |
| 155 | + layout: 'chip', |
| 156 | + options: [ |
| 157 | + 'Chip9', |
| 158 | + 'Chip10', |
| 159 | + 'Chip11', |
| 160 | + 'Chip12', |
| 161 | + ], |
| 162 | + }, |
| 163 | + }, |
| 164 | + ], |
| 165 | + }; |
| 166 | + await fillForm(page, JSON.stringify(form)); |
| 167 | + await testDraftValues(page, form); |
| 168 | + await assertScreenshot(page); |
| 169 | +}); |
0 commit comments