@@ -6,7 +6,7 @@ import path from 'path';
66const __filename = fileURLToPath ( import . meta. url ) ;
77const __dirname = path . dirname ( __filename ) ;
88
9- test ( 'JSON Schema validation' , async ( { page, workflow } ) => {
9+ test ( 'JSON Schema validation' , async ( { page, browserName , workflow } ) => {
1010 await page . waitForURL ( workflow . url ) ;
1111 await waitPageLoading ( page ) ;
1212
@@ -97,8 +97,11 @@ test('JSON Schema validation', async ({ page, workflow }) => {
9797
9898 await test . step ( 'Fill required integer with min and max' , async ( ) => {
9999 const input = form . getByLabel ( 'minMaxRequiredInt' , { exact : true } ) ;
100- await input . pressSequentially ( 'foo' ) ;
101- expect ( form . getByText ( 'Should be a number' ) ) . toHaveCount ( 1 ) ;
100+ if ( browserName === 'firefox' ) {
101+ // chrome doesn't allow to insert text inside numeric inputs
102+ await input . pressSequentially ( 'foo' ) ;
103+ expect ( form . getByText ( 'Should be a number' ) ) . toHaveCount ( 1 ) ;
104+ }
102105 await input . fill ( '1' ) ;
103106 expect ( form . getByText ( 'Should be greater or equal than 5' ) ) . toHaveCount ( 1 ) ;
104107 await input . fill ( '15' ) ;
@@ -111,8 +114,11 @@ test('JSON Schema validation', async ({ page, workflow }) => {
111114
112115 await test . step ( 'Fill optional integer with min and max' , async ( ) => {
113116 const input = form . getByLabel ( 'minMaxOptionalInt' , { exact : true } ) ;
114- await input . pressSequentially ( 'foo' ) ;
115- expect ( form . getByText ( 'Should be a number' ) ) . toHaveCount ( 1 ) ;
117+ if ( browserName === 'firefox' ) {
118+ // chrome doesn't allow to insert text inside numeric inputs
119+ await input . pressSequentially ( 'foo' ) ;
120+ expect ( form . getByText ( 'Should be a number' ) ) . toHaveCount ( 1 ) ;
121+ }
116122 await input . fill ( '-7' ) ;
117123 expect ( form . getByText ( 'Should be greater or equal than 0' ) ) . toHaveCount ( 1 ) ;
118124 await input . fill ( '33' ) ;
@@ -123,8 +129,11 @@ test('JSON Schema validation', async ({ page, workflow }) => {
123129
124130 await test . step ( 'Fill optional integer with exclusive min and max' , async ( ) => {
125131 const input = form . getByLabel ( 'exclusiveMinMaxOptionalInt' , { exact : true } ) ;
126- await input . pressSequentially ( 'foo' ) ;
127- expect ( form . getByText ( 'Should be a number' ) ) . toHaveCount ( 1 ) ;
132+ if ( browserName === 'firefox' ) {
133+ // chrome doesn't allow to insert text inside numeric inputs
134+ await input . pressSequentially ( 'foo' ) ;
135+ expect ( form . getByText ( 'Should be a number' ) ) . toHaveCount ( 1 ) ;
136+ }
128137 await input . fill ( '2' ) ;
129138 expect ( form . getByText ( 'Should be greater or equal than 4' ) ) . toHaveCount ( 1 ) ;
130139 await input . fill ( '99' ) ;
@@ -138,21 +147,39 @@ test('JSON Schema validation', async ({ page, workflow }) => {
138147 await addBtn . click ( ) ;
139148 await addBtn . click ( ) ;
140149 await addBtn . click ( ) ;
150+ // Fill items
141151 await form . locator ( 'id=property-requiredArrayWithMinMaxItems###0' ) . fill ( 'a' ) ;
142152 await form . locator ( 'id=property-requiredArrayWithMinMaxItems###1' ) . fill ( 'b' ) ;
143153 await form . locator ( 'id=property-requiredArrayWithMinMaxItems###2' ) . fill ( 'c' ) ;
144154 await form . locator ( 'id=property-requiredArrayWithMinMaxItems###3' ) . fill ( 'd' ) ;
155+ // Move "d" up
156+ await page . getByRole ( 'button' , { name : 'Move item up' } ) . nth ( 3 ) . click ( ) ;
157+ await page . getByRole ( 'button' , { name : 'Move item up' } ) . nth ( 2 ) . click ( ) ;
158+ await page . getByRole ( 'button' , { name : 'Move item up' } ) . nth ( 1 ) . click ( ) ;
159+ await checkFirstArray ( [ 'd' , 'a' , 'b' , 'c' ] ) ;
160+ // Move "d" down
161+ await page . getByRole ( 'button' , { name : 'Move item down' } ) . first ( ) . click ( ) ;
162+ await page . getByRole ( 'button' , { name : 'Move item down' } ) . nth ( 1 ) . click ( ) ;
163+ await checkFirstArray ( [ 'a' , 'b' , 'd' , 'c' ] ) ;
164+ // Remove items
145165 await form . getByRole ( 'button' , { name : 'Remove' } ) . nth ( 3 ) . click ( ) ;
146166 await form . getByRole ( 'button' , { name : 'Remove' } ) . nth ( 2 ) . click ( ) ;
147- expect ( await form . locator ( 'id=property-requiredArrayWithMinMaxItems###1' ) . inputValue ( ) ) . toEqual (
148- 'b'
149- ) ;
167+ await checkFirstArray ( [ 'a' , 'b' ] ) ;
150168 await form . getByRole ( 'button' , { name : 'Remove' } ) . nth ( 1 ) . click ( ) ;
151- expect ( await form . locator ( 'id=property-requiredArrayWithMinMaxItems###1' ) . inputValue ( ) ) . toEqual (
152- ''
153- ) ;
169+ await checkFirstArray ( [ 'a' , '' ] ) ;
154170 } ) ;
155171
172+ /**
173+ * @param {string[] } expectedValues
174+ */
175+ async function checkFirstArray ( expectedValues ) {
176+ for ( let i = 0 ; i < expectedValues . length ; i ++ ) {
177+ expect (
178+ await form . locator ( 'id=property-requiredArrayWithMinMaxItems###' + i ) . inputValue ( )
179+ ) . toEqual ( expectedValues [ i ] ) ;
180+ }
181+ }
182+
156183 await test . step ( 'Optional array with minItems and maxItems' , async ( ) => {
157184 await form . getByText ( 'optionalArrayWithMinMaxItems' ) . first ( ) . click ( ) ;
158185 const addBtn = form . getByRole ( 'button' , { name : 'Add argument to list' } ) . nth ( 1 ) ;
@@ -179,6 +206,24 @@ test('JSON Schema validation', async ({ page, workflow }) => {
179206 expect ( form . getByText ( 'Field is required' ) ) . toHaveCount ( 2 ) ;
180207 } ) ;
181208
209+ await test . step ( 'Save values' , async ( ) => {
210+ const stringInput = form . getByLabel ( 'Required string' , { exact : true } ) ;
211+ await stringInput . fill ( 'foo' ) ;
212+ const intInput = form . getByLabel ( 'minMaxRequiredInt' , { exact : true } ) ;
213+ await intInput . fill ( '7' ) ;
214+ await form . locator ( 'id=property-requiredArrayWithMinMaxItems###1' ) . fill ( 'b' ) ;
215+ await page . getByRole ( 'button' , { name : 'Move item up' } ) . nth ( 1 ) . click ( ) ;
216+ await page . getByRole ( 'button' , { name : 'Save changes' } ) . click ( ) ;
217+ await page . getByText ( 'Arguments changes saved successfully' ) . waitFor ( ) ;
218+ await page . reload ( ) ;
219+ await waitPageLoading ( page ) ;
220+ await page . getByText ( `${ randomTaskName } #` ) . first ( ) . click ( ) ;
221+ expect ( await page . getByLabel ( 'Required string' , { exact : true } ) . inputValue ( ) ) . toEqual ( 'foo' ) ;
222+ expect ( await page . getByLabel ( 'minMaxRequiredInt' , { exact : true } ) . inputValue ( ) ) . toEqual ( '7' ) ;
223+ expect ( await page . locator ( 'id=property-requiredEnum' ) . inputValue ( ) ) . toEqual ( 'option1' ) ;
224+ await checkFirstArray ( [ 'b' , 'a' ] ) ;
225+ } ) ;
226+
182227 await test . step ( 'Delete workflow task' , async ( ) => {
183228 await page . getByLabel ( 'Delete workflow task' ) . click ( ) ;
184229 const modal = page . locator ( '.modal.show' ) ;
0 commit comments