itemengine-cypress-automation 1.0.23 → 1.0.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (18) hide show
  1. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextAdditionalSettingsAdvanceSettingsForAllResponseAreas.js +511 -0
  2. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextAdditionalSettingsBasic.js +263 -0
  3. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextAdditionalSettingsResponseAccordions.js +734 -0
  4. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextAdditionalSettingsStudentResponseAreaAndLayout.js +603 -0
  5. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextAllOrNothingWithAlternateAnswer.js +54 -0
  6. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextAlternateAnswer.js +104 -0
  7. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextAutoScoredScoring.js +38 -0
  8. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextCaseSensitiveAndIgnoreExtraSpacesCheckboxes.js +174 -0
  9. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextEditTabBasicSections.js +176 -0
  10. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextEditTabScoringSection.js +150 -0
  11. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextHeaderSection.js +112 -0
  12. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextManuallyAndNonScoredScoring.js +49 -0
  13. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextPartialDifferentWeights.js +47 -0
  14. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextPartialDifferentWeightsWithAlternateAnswer.js +60 -0
  15. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextPartialEqualWeights.js +45 -0
  16. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextPartialEqualWeightsWithAlternateAnswer.js +58 -0
  17. package/cypress/e2e/ILC/FillInTheGapsText/fillInTheGapsTextSetCorrectAnswerSection.js +70 -0
  18. package/package.json +1 -1
@@ -0,0 +1,734 @@
1
+ import { fillInTheGapsTextPage } from "../../../pages";
2
+ import { commonComponents } from "../../../pages/components";
3
+ import abortEarlySetup from "../../../support/helpers/abortEarly";
4
+ const css = Cypress.env('css');
5
+
6
+ describe('Fill In the Gaps Additional settings: Responses accordion', () => {
7
+ before(() => {
8
+ cy.loginAs('admin');
9
+ });
10
+
11
+ describe('Additional Settings : Response accordion', () => {
12
+ abortEarlySetup();
13
+ before(() => {
14
+ fillInTheGapsTextPage.steps.navigateToCreateQuestion('fill in the gaps with text');
15
+ fillInTheGapsTextPage.steps.expandAdditonalSettings();
16
+ });
17
+
18
+ fillInTheGapsTextPage.tests.verifyAdditionalSettingsResponseAccordionLabelCSSAndA11y();
19
+ });
20
+
21
+ describe('Response Accordions: ARIA label', () => {
22
+ abortEarlySetup();
23
+ before(() => {
24
+ fillInTheGapsTextPage.steps.navigateToCreateQuestion('fill in the gaps with text');
25
+ fillInTheGapsTextPage.steps.expandAdditonalSettings();
26
+ fillInTheGapsTextPage.steps.expandResponseAccordion(0);
27
+ fillInTheGapsTextPage.steps.expandResponseAccordion(1);
28
+ });
29
+
30
+ fillInTheGapsTextPage.tests.verifyDefaultStateOfAriaLabelInputFieldInResponseAccordionAndCSS();
31
+
32
+ //Note: a11y covered in Additional Settings: Response accordion
33
+
34
+ //ARIA label test cases for set correct answer section
35
+ it('When the user has not set \'ARIA label\' input field then the default \'ARIA label\' should be present for the \'Set correct answer\' section response field', () => {
36
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
37
+ .each(($el, count) => {
38
+ cy.wrap($el)
39
+ .should('have.attr', 'aria-label', `Add answer for response ${count + 1}`);
40
+ });
41
+ });
42
+
43
+ fillInTheGapsTextPage.tests.verifyCustomLabelNotVisibleOnResponseAccordion('ARIA label');
44
+
45
+ it('When the user has set \'ARIA label\' in the response accordion then it should be present for the \'Set correct answer\' section response field and for the other response field, value of the aria-label should remain the same', () => {
46
+ fillInTheGapsTextPage.steps.setAriaLabelInResponseAccordion(0, 'Custom Aria Label');
47
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
48
+ .eq(0)
49
+ .should('have.attr', 'aria-label', 'Custom Aria Label');
50
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
51
+ .eq(1)
52
+ .should('have.attr', 'aria-label', 'Add answer for response 2');
53
+ });
54
+
55
+ fillInTheGapsTextPage.tests.verifyCustomLabelVisibleOnResponseAccordion('ARIA label');
56
+
57
+ fillInTheGapsTextPage.tests.verifyCustomLabelOnResponseAccordionCSS();
58
+
59
+ it('Accessibility of input field in \'Set correct answer\' section when custom \'ARIA label\' is set and Custom label', { tags: 'a11y' }, () => {
60
+ cy.checkAccessibility(fillInTheGapsTextPage.setCorrectAnswerResponseField().parents('.response-input-field'))
61
+ cy.checkAccessibility(fillInTheGapsTextPage.responseAccordionCustomLabel())
62
+ });
63
+
64
+ it('When the user clears the set value in the \'ARIA label\' input field, then the default \'ARIA label\' should be present for the response fields in the \'Set correct answer\' section', () => {
65
+ fillInTheGapsTextPage.responseAccordionWrapper()
66
+ .eq(0)
67
+ .within(() => {
68
+ fillInTheGapsTextPage.ariaLabelInputField()
69
+ .clear()
70
+ .should('have.value', '');
71
+ });
72
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
73
+ .each(($el, count) => {
74
+ cy.wrap($el)
75
+ .should('have.attr', 'aria-label', `Add answer for response ${count + 1}`);
76
+ });
77
+ });
78
+
79
+ //ARIA label test cases for preview tab
80
+ //https://redmine.zeuslearning.com/issues/537797
81
+ it('When the user has not set \'ARIA label\' input field then in the preview tab default \'ARIA label\' should be present for the response field in the preview tab', () => {
82
+ cy.log('Pre step: Switch to Preview tab')
83
+ fillInTheGapsTextPage.steps.switchToPreviewTab();
84
+ fillInTheGapsTextPage.previewTabResponseField()
85
+ .each(($el, count) => {
86
+ cy.wrap($el)
87
+ .should('have.attr', 'aria-label', `Add answer for response ${count + 1}`);
88
+ });
89
+ });
90
+
91
+ it('When the user has set \'ARIA label\' in the response accordion then it should be present for the response field in the preview tab', () => {
92
+ cy.log('Pre step: Switch to Edit tab')
93
+ fillInTheGapsTextPage.steps.switchToEditTab();
94
+ fillInTheGapsTextPage.steps.setAriaLabelInResponseAccordion(0, 'Custom Aria Label');
95
+ fillInTheGapsTextPage.steps.switchToPreviewTab();
96
+ fillInTheGapsTextPage.previewTabResponseField()
97
+ .eq(0)
98
+ .should('have.attr', 'aria-label', 'Custom Aria Label');
99
+ fillInTheGapsTextPage.previewTabResponseField()
100
+ .eq(1)
101
+ .should('have.attr', 'aria-label', 'Add answer for response 2');
102
+ });
103
+
104
+ it('Accessibility of input field in preview tab when custom \'ARIA label\' is set', { tags: 'a11y' }, () => {
105
+ cy.checkAccessibility(fillInTheGapsTextPage.previewTabResponseField().parents('.response-input-field'))
106
+ });
107
+
108
+ it('When the user clears the set value in the \'ARIA label\' input field, then the default \'ARIA label\' should be present for the response field in the preview tab', () => {
109
+ cy.log('Pre step: Switch to Edit tab')
110
+ fillInTheGapsTextPage.steps.switchToEditTab();
111
+ fillInTheGapsTextPage.responseAccordionWrapper()
112
+ .eq(0)
113
+ .within(() => {
114
+ fillInTheGapsTextPage.ariaLabelInputField()
115
+ .clear()
116
+ .should('have.value', '');
117
+ });
118
+ fillInTheGapsTextPage.steps.switchToPreviewTab();
119
+ fillInTheGapsTextPage.previewTabResponseField()
120
+ .each(($el, count) => {
121
+ cy.wrap($el)
122
+ .should('have.attr', 'aria-label', `Add answer for response ${count + 1}`);
123
+ });
124
+ });
125
+ });
126
+
127
+ describe('Response Accordions: Placeholder text', () => {
128
+ abortEarlySetup();
129
+ before(() => {
130
+ fillInTheGapsTextPage.steps.navigateToCreateQuestion('fill in the gaps with text');
131
+ fillInTheGapsTextPage.steps.expandAdditonalSettings();
132
+ fillInTheGapsTextPage.steps.expandResponseAccordion(0)
133
+ fillInTheGapsTextPage.steps.expandResponseAccordion(1)
134
+ });
135
+
136
+ fillInTheGapsTextPage.tests.verifyDefaultStateOfPlaceholderTextInputFieldInResponseAccordionAndCSS();
137
+
138
+ //Note: a11y covered in Additional Settings: Response accordion
139
+
140
+ //Placeholder test cases for Set correct answer section
141
+ it('When the user has not set Placeholder text in the Response accordion then placeholder should not be displayed in \'Set correct answer\' section', () => {
142
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
143
+ .each(($el) => {
144
+ cy.wrap($el)
145
+ .should('not.have.attr', 'placeholder');
146
+ });
147
+ });
148
+
149
+ fillInTheGapsTextPage.tests.verifyCustomLabelNotVisibleOnResponseAccordion('Placeholder text');
150
+
151
+ it('When the user has set a Placeholder text in either response accordion then a placeholder text should be displayed for the respective response in \'Set correct answer\' section', () => {
152
+ fillInTheGapsTextPage.steps.setPlaceholderTextInResponseAccordion(0, 'Lorem Ipsum');
153
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
154
+ .eq(0)
155
+ .should('have.attr', 'placeholder', 'Lorem Ipsum');
156
+ });
157
+
158
+ fillInTheGapsTextPage.tests.verifyCustomLabelVisibleOnResponseAccordion('Placeholder text');
159
+
160
+ it('When the user removes the Placeholder text from the individual responses the Placeholders should get updated accordingly in \'Set correct answer\' section', () => {
161
+ fillInTheGapsTextPage.responseAccordionWrapper()
162
+ .eq(0)
163
+ .within(() => {
164
+ fillInTheGapsTextPage.placeholderTextInputField()
165
+ .clear()
166
+ .should('have.value', '');
167
+ });
168
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
169
+ .eq(0)
170
+ .should('not.have.attr', 'placeholder');
171
+ });
172
+
173
+ it('When the user has set placeholder text in the individual response areas, then it should override the placeholder text set in the \'Advanced settings for all response areas\' in the \'Set correct answer\' section', () => {
174
+ fillInTheGapsTextPage.placeholderTextInputField()
175
+ .type('Global placeholder')
176
+ .should('have.value', 'Global placeholder');
177
+ fillInTheGapsTextPage.steps.setPlaceholderTextInResponseAccordion(0, 'Lorem Ipsum');
178
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
179
+ .eq(0)
180
+ .should('have.attr', 'placeholder', 'Lorem Ipsum');
181
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
182
+ .eq(1)
183
+ .should('have.attr', 'placeholder', 'Global placeholder');
184
+ });
185
+
186
+ //Comment: not possible to check css of placeholder since it is added as an attribute, properties of placeholder is not visible in dev tools
187
+
188
+ it('Accessibility of \'Placeholder text\' in \'Set correct answer\' section', { tags: 'a11y' }, () => {
189
+ cy.checkAccessibility(fillInTheGapsTextPage.setCorrectAnswerResponseField().parents('.response-input-field'));
190
+ });
191
+
192
+ it('When the user enters text in the response field, then the placeholder text should disappear and on clearing the input field the placeholder text should re-appear for the set correct answer section', () => {
193
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
194
+ .eq(0)
195
+ .type('Response')
196
+ .should('have.value', 'Response')
197
+ .should('not.have.attr', 'placeholder');
198
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
199
+ .clear()
200
+ .should('have.attr', 'placeholder', 'Lorem Ipsum');
201
+ });
202
+
203
+ //Placeholder test cases for preview tab
204
+ it('When the user has not set Placeholder text in the Response accordion then placeholder should not be displayed in preview tab response fields', () => {
205
+ cy.log('Pre step: Clearing the set Placeholder text')
206
+ fillInTheGapsTextPage.placeholderTextInputField()
207
+ .clear()
208
+ .should('have.value', '');
209
+ fillInTheGapsTextPage.responseAccordionWrapper()
210
+ .eq(0)
211
+ .within(() => {
212
+ fillInTheGapsTextPage.placeholderTextInputField()
213
+ .clear()
214
+ .should('have.value', '');
215
+ });
216
+ fillInTheGapsTextPage.steps.switchToPreviewTab();
217
+ fillInTheGapsTextPage.previewTabResponseField()
218
+ .each(($el) => {
219
+ cy.wrap($el)
220
+ .should('not.have.attr', 'placeholder');
221
+ });
222
+ });
223
+
224
+ it('When the user has set a Placeholder text in either individual response accordion a placeholder text should be displayed for the respective response in preview tab', () => {
225
+ fillInTheGapsTextPage.steps.switchToEditTab()
226
+ fillInTheGapsTextPage.steps.setPlaceholderTextInResponseAccordion(0, 'Lorem Ipsum');
227
+ fillInTheGapsTextPage.steps.switchToPreviewTab();
228
+ fillInTheGapsTextPage.previewTabResponseField()
229
+ .eq(0)
230
+ .should('have.attr', 'placeholder', 'Lorem Ipsum');
231
+ fillInTheGapsTextPage.previewTabResponseField()
232
+ .eq(1)
233
+ .should('not.have.attr', 'placeholder');
234
+ });
235
+
236
+ it('When the user removes the Placeholder text from individual responses the Placeholders should get updated accordingly for both the responses in preview tab', () => {
237
+ fillInTheGapsTextPage.steps.switchToEditTab()
238
+ fillInTheGapsTextPage.responseAccordionWrapper()
239
+ .eq(0)
240
+ .within(() => {
241
+ fillInTheGapsTextPage.placeholderTextInputField()
242
+ .clear()
243
+ .should('have.value', '');
244
+ });
245
+ fillInTheGapsTextPage.steps.switchToPreviewTab()
246
+ fillInTheGapsTextPage.previewTabResponseField()
247
+ .eq(0)
248
+ .should('not.have.attr', 'placeholder');
249
+ });
250
+
251
+ it('When the user has set placeholder text in the individual response area, then it should override the placeholder text set in the \'Advanced settings for all response areas\' in the preview tab response fields', () => {
252
+ fillInTheGapsTextPage.steps.switchToEditTab()
253
+ fillInTheGapsTextPage.placeholderTextInputField()
254
+ .type('Global placeholder')
255
+ .should('have.value', 'Global placeholder');
256
+ fillInTheGapsTextPage.steps.setPlaceholderTextInResponseAccordion(0, 'Lorem Ipsum');
257
+ fillInTheGapsTextPage.steps.switchToPreviewTab()
258
+ fillInTheGapsTextPage.previewTabResponseField()
259
+ .eq(0)
260
+ .should('have.attr', 'placeholder', 'Lorem Ipsum');
261
+ fillInTheGapsTextPage.previewTabResponseField()
262
+ .eq(1)
263
+ .should('have.attr', 'placeholder', 'Global placeholder');
264
+ });
265
+
266
+ //Comment: not possible to check css of placeholder since it is added as an attribute, properties of placeholder is not visible in dev tools
267
+
268
+ it('Accessibility of \'Placeholder text\' in preview tab', { tags: 'a11y' }, () => {
269
+ cy.checkAccessibility(fillInTheGapsTextPage.previewTabResponseField().parents('.response-input-field'))
270
+ });
271
+
272
+ //https://redmine.zeuslearning.com/issues/529544
273
+ it('When the user enters text in the response field, then the placeholder text should disappear and on clearing the input field the placeholder text should re-appear in the preview tab', () => {
274
+ fillInTheGapsTextPage.previewTabResponseField()
275
+ .eq(0)
276
+ .type('Response')
277
+ .should('have.value', 'Response')
278
+ .should('not.have.attr', 'placeholder');
279
+ fillInTheGapsTextPage.previewTabResponseField()
280
+ .eq(0)
281
+ .clear()
282
+ .blur()
283
+ .should('have.attr', 'placeholder', 'Lorem Ipsum');
284
+ });
285
+ });
286
+
287
+ describe('Response Accordions: Type of answer input', () => {
288
+ abortEarlySetup();
289
+ const typeOfAnswers = ['Text', 'Number'];
290
+ before(() => {
291
+ fillInTheGapsTextPage.steps.navigateToCreateQuestion('fill in the gaps with text');
292
+ cy.barsPreLoaderWait();
293
+ fillInTheGapsTextPage.steps.expandAdditonalSettings();
294
+ fillInTheGapsTextPage.steps.expandResponseAccordion(0);
295
+ fillInTheGapsTextPage.steps.expandResponseAccordion(1);
296
+ });
297
+
298
+ it('\'Type of answer\' label and dropdown should be displayed and by default in the \'Type of answer\' dropdown \'Text\' option should be selected for both response accordions', () => {
299
+ fillInTheGapsTextPage.responseAccordionWrapper()
300
+ .each(($el) => {
301
+ cy.wrap($el)
302
+ .within(() => {
303
+ fillInTheGapsTextPage.typeOfAnswerInputLabel()
304
+ .verifyInnerText('Type of answer input');
305
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
306
+ .verifyInnerText('Text');
307
+ });
308
+ })
309
+ });
310
+
311
+ it('CSS of \'Type of answer\' dropdown', { tags: 'css' }, () => {
312
+ fillInTheGapsTextPage.responseAccordionWrapper()
313
+ .eq(0)
314
+ .within(() => {
315
+ fillInTheGapsTextPage.typeOfAnswerInputLabel()
316
+ .verifyCSS(css.color.labels, css.fontSize.normal, css.fontWeight.semibold);
317
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
318
+ .verifyCSS(css.color.liText, css.fontSize.default, css.fontWeight.regular);
319
+ });
320
+ });
321
+
322
+ //Note: a11y covered in Additional Settings: Response accordion
323
+
324
+ it(`Clicking on Type of answer dropdown should open a list of 2 options - ${typeOfAnswers}`, () => {
325
+ cy.log('Checking dropdown contents for Response 1 accordion')
326
+ fillInTheGapsTextPage.responseAccordionWrapper()
327
+ .eq(0)
328
+ .within(() => {
329
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
330
+ .click();
331
+ });
332
+ fillInTheGapsTextPage.typeOfAnswerInputDropdownListOptions(0)
333
+ .should('be.visible');
334
+ typeOfAnswers.forEach((index, count) => {
335
+ fillInTheGapsTextPage.typeOfAnswerInputDropdownListOptions(count)
336
+ .verifyInnerText(index);
337
+ });
338
+ cy.get('body')
339
+ .click();
340
+ cy.log('Checking dropdown contents for Response 2 accordion')
341
+ fillInTheGapsTextPage.responseAccordionWrapper()
342
+ .eq(1)
343
+ .within(() => {
344
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
345
+ .click();
346
+ });
347
+ fillInTheGapsTextPage.typeOfAnswerInputDropdownListOptions(0)
348
+ .should('be.visible');
349
+ typeOfAnswers.forEach((index, count) => {
350
+ fillInTheGapsTextPage.typeOfAnswerInputDropdownListOptions(count)
351
+ .verifyInnerText(index);
352
+ });
353
+ });
354
+
355
+ it('CSS of Type of answer input dropdown in Active state', { tags: 'css' }, () => {
356
+ fillInTheGapsTextPage.typeOfAnswerInputDropdownListOptions(0)
357
+ .verifyCSS(css.color.liText, css.fontSize.default, css.fontWeight.regular)
358
+ .should('have.css', 'background-color', css.color.liTextSelectedBg);
359
+ fillInTheGapsTextPage.typeOfAnswerInputDropdownListOptions(1)
360
+ .should('have.css', 'background-color', css.color.transparent);
361
+ });
362
+
363
+ it('Accessibility of Type of answer input dropdown in active state', { tags: 'a11y' }, () => {
364
+ cy.checkAccessibility(commonComponents.dropdownList());
365
+ });
366
+
367
+ it('When the user has not set the Type of answer input in the response accordion then the custom label should not be displayed', () => {
368
+ fillInTheGapsTextPage.responseAccordionCustomLabel()
369
+ .should('not.exist');
370
+ });
371
+
372
+ //Type of answer input test cases for set correct answer section
373
+ it('When the user has set \'Text\' option in the response accordion, then user should be able to enter alpha-numeric characters in the \'Set correct answer\' section', () => {
374
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
375
+ .eq(0)
376
+ .type('Response 1')
377
+ .should('have.value', 'Response 1');
378
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
379
+ .eq(1)
380
+ .type('Response 1')
381
+ .should('have.value', 'Response 1');
382
+ });
383
+
384
+ it('When the user has set \'Number\' option the response accordion, then user should be able to enter only numeric characters in the \'Set correct answer\' section', () => {
385
+ fillInTheGapsTextPage.responseAccordionWrapper()
386
+ .eq(1)
387
+ .within(() => {
388
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
389
+ .click();
390
+ });
391
+ fillInTheGapsTextPage.typeOfAnswerInputDropdownListOptions(1)
392
+ .click();
393
+ fillInTheGapsTextPage.responseAccordionWrapper()
394
+ .eq(1)
395
+ .within(() => {
396
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
397
+ .verifyInnerText('Number');
398
+ });
399
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
400
+ .eq(1)
401
+ .type('Response 1')
402
+ .should('have.value', '1');
403
+ });
404
+
405
+ it('When the user has set \'Number\' option in the \'Advanced settings for all response areas\' then both the options in the Response accordions should change to \'Number\'', () => {
406
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
407
+ .click();
408
+ fillInTheGapsTextPage.typeOfAnswerInputDropdownListOptions(1)
409
+ .click();
410
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
411
+ .verifyInnerText('Number');
412
+ fillInTheGapsTextPage.responseAccordionWrapper()
413
+ .each(($el) => {
414
+ cy.wrap($el)
415
+ .within(() => {
416
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
417
+ .verifyInnerText('Number');
418
+ });
419
+ });
420
+ });
421
+
422
+ it('When the user has set \'Text\' option in Response accordion then it should override the \'Number\' option set in the \'Advanced settings for all response areas\' and user should be able to enter responses accordingly in the \'Set correct answer\' section', () => {
423
+ fillInTheGapsTextPage.responseAccordionWrapper()
424
+ .eq(0)
425
+ .within(() => {
426
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
427
+ .click();
428
+ });
429
+ fillInTheGapsTextPage.typeOfAnswerInputDropdownListOptions(0)
430
+ .click();
431
+ fillInTheGapsTextPage.responseAccordionWrapper()
432
+ .eq(0)
433
+ .within(() => {
434
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
435
+ .verifyInnerText('Text');
436
+ });
437
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
438
+ .eq(0)
439
+ .click()
440
+ .type('1 Response', { delay: 1000 })
441
+ .should('have.value', '1 Response');
442
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
443
+ .eq(1)
444
+ .clear()
445
+ .type('Response 1')
446
+ .should('have.value', '1');
447
+ });
448
+
449
+ it('When the user has set a Type of answer input in Response accordion then Custom label should be displayed', () => {
450
+ fillInTheGapsTextPage.responseAccordionWrapper()
451
+ .eq(0)
452
+ .within(() => {
453
+ fillInTheGapsTextPage.responseAccordionCustomLabel()
454
+ .should('be.visible');
455
+ });
456
+ fillInTheGapsTextPage.responseAccordionWrapper()
457
+ .eq(1)
458
+ .within(() => {
459
+ fillInTheGapsTextPage.responseAccordionCustomLabel()
460
+ .should('not.exist');
461
+ });
462
+ });
463
+
464
+ //Type of answer input test cases for preview tab
465
+ it('When the user has set \'Text\' option in the response accordion, then user should be able to enter alpha-numeric characters in preview tab response fields', () => {
466
+ cy.log('Pre step: Set the Type of answer input dropdowns to \'Text\'')
467
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
468
+ .click();
469
+ fillInTheGapsTextPage.typeOfAnswerInputDropdownListOptions(0)
470
+ .click();
471
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
472
+ .verifyInnerText('Text');
473
+ fillInTheGapsTextPage.responseAccordionWrapper()
474
+ .each(($el) => {
475
+ cy.wrap($el)
476
+ .within(() => {
477
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
478
+ .verifyInnerText('Text');
479
+ });
480
+ });
481
+ fillInTheGapsTextPage.steps.switchToPreviewTab()
482
+ fillInTheGapsTextPage.previewTabResponseField()
483
+ .each(($el) => {
484
+ cy.wrap($el)
485
+ .type('Response 1')
486
+ .should('have.value', 'Response 1');
487
+ });
488
+ });
489
+
490
+ it('When the user has set \'Number\' option in the response accordion, then the user should be able to enter only numeric characters in preview tab response fields', () => {
491
+ fillInTheGapsTextPage.steps.switchToEditTab()
492
+ fillInTheGapsTextPage.responseAccordionWrapper()
493
+ .eq(1)
494
+ .within(() => {
495
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
496
+ .click();
497
+ });
498
+ fillInTheGapsTextPage.typeOfAnswerInputDropdownListOptions(1)
499
+ .click();
500
+ fillInTheGapsTextPage.responseAccordionWrapper()
501
+ .eq(1)
502
+ .within(() => {
503
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
504
+ .verifyInnerText('Number');
505
+ });
506
+ fillInTheGapsTextPage.steps.switchToPreviewTab()
507
+ fillInTheGapsTextPage.previewTabResponseField()
508
+ .eq(1)
509
+ .type('Response 1')
510
+ .should('have.value', '1');
511
+ });
512
+
513
+ it('When the user has set \'Text\' option in Response accordion then it should override the \'Number\' option set in \'Advanced settings for all response areas\' and user should be able to enter responses accordingly in the preview tab section', () => {
514
+ cy.log('Pre step:Setting \'Number\' option in \'Advanced settings for all response areas\'')
515
+ fillInTheGapsTextPage.steps.switchToEditTab()
516
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
517
+ .click();
518
+ fillInTheGapsTextPage.typeOfAnswerInputDropdownListOptions(1)
519
+ .click();
520
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
521
+ .verifyInnerText('Number');
522
+ fillInTheGapsTextPage.responseAccordionWrapper()
523
+ .eq(0)
524
+ .within(() => {
525
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
526
+ .click();
527
+ });
528
+ fillInTheGapsTextPage.typeOfAnswerInputDropdownListOptions(0)
529
+ .click();
530
+ fillInTheGapsTextPage.responseAccordionWrapper()
531
+ .eq(0)
532
+ .within(() => {
533
+ fillInTheGapsTextPage.typeOfAnswerInputDropdown()
534
+ .verifyInnerText('Text');
535
+ });
536
+ fillInTheGapsTextPage.steps.switchToPreviewTab()
537
+ fillInTheGapsTextPage.previewTabResponseField()
538
+ .eq(0)
539
+ .type('Response 1')
540
+ .should('have.value', 'Response 1');
541
+ fillInTheGapsTextPage.previewTabResponseField()
542
+ .eq(1)
543
+ .type('Response 1')
544
+ .should('have.value', '1');
545
+ });
546
+ });
547
+
548
+ describe('Response Accordions: Height and Width', () => {
549
+ abortEarlySetup();
550
+ before(() => {
551
+ fillInTheGapsTextPage.steps.navigateToCreateQuestion('fill in the gaps with text');
552
+ fillInTheGapsTextPage.steps.expandAdditonalSettings();
553
+ fillInTheGapsTextPage.steps.expandResponseAccordion(0);
554
+ fillInTheGapsTextPage.steps.expandResponseAccordion(1);
555
+ });
556
+
557
+ fillInTheGapsTextPage.tests.verifyDefaultStateOfHeightAndWidthInputFieldInResponseAccordionAndCSS();
558
+
559
+ //Note: a11y covered in Additional Settings: Response accordion
560
+
561
+ //Height and width test cases for Set correct answer section
562
+ //TODO: We will need to revisit below case as it will fail for mobile view
563
+ it('When the user has not set \'Height\' and \'Width\' for response fields then the default dimension of the response field in the \'Set correct answer\' section response fields should be (197x46)px', () => {
564
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
565
+ .each(($el) => {
566
+ cy.wrap($el)
567
+ .parents('.response-input-field')
568
+ .should('have.attr', 'height', '46px')
569
+ .and('have.attr', 'width', '13.7em');
570
+ });
571
+ });
572
+
573
+ fillInTheGapsTextPage.tests.verifyCustomLabelNotVisibleOnResponseAccordion('Height and Width');
574
+
575
+ it('When the user has set \'Height\' for the response field then the Height of the response field should get updated accordingly in the \'Set correct answer\' section', () => {
576
+ fillInTheGapsTextPage.steps.setHeightInResponseAccordion(0, '100');
577
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
578
+ .eq(0)
579
+ .parents('.response-input-field')
580
+ .should('have.attr', 'height', '100px');
581
+ });
582
+
583
+ fillInTheGapsTextPage.tests.verifyCustomLabelVisibleOnResponseAccordion('Height and Width');
584
+
585
+ it('When the user has set \'Width\' for the response field then the Width of the response field should get updated accordingly in the \'Set correct answer\' section', () => {
586
+ fillInTheGapsTextPage.steps.setWidthInResponseAccordion(0, '100');
587
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
588
+ .eq(0)
589
+ .parents('.response-input-field')
590
+ .should('have.attr', 'width', '100px');
591
+ });
592
+
593
+ it('When the user has set width below 80px then the width should remain 80px in the \'Set correct answer\' section', () => {
594
+ fillInTheGapsTextPage.steps.setWidthInResponseAccordion(0, '20');
595
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
596
+ .eq(0)
597
+ .parents('.response-input-field')
598
+ .should('have.attr', 'width', '80px');
599
+ });
600
+
601
+ it('When the user has set width above 400px then the width should remain 400px in the \'Set correct answer\' section', () => {
602
+ fillInTheGapsTextPage.steps.setWidthInResponseAccordion(0, '800');
603
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
604
+ .eq(0)
605
+ .parents('.response-input-field')
606
+ .should('have.attr', 'width', '400px');
607
+ });
608
+
609
+ it('When the user has set \'Height\' and \'Width\' in the individual responses accordion then it should override the \'Height\' and \'Width\'set in the \'Advanced settings for all response areas\' in the \'Set correct answer\' section', () => {
610
+ fillInTheGapsTextPage.widthInputField()
611
+ .clear()
612
+ .type('250')
613
+ .should('have.value', '250');
614
+ fillInTheGapsTextPage.heightInputField()
615
+ .clear()
616
+ .type('180')
617
+ .should('have.value', '180');
618
+ fillInTheGapsTextPage.steps.setWidthInResponseAccordion(0, '175');
619
+ fillInTheGapsTextPage.steps.setHeightInResponseAccordion(0, '120');
620
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
621
+ .eq(0)
622
+ .parents('.response-input-field')
623
+ .should('have.attr', 'width', '175px')
624
+ .and('have.attr', 'height', '120px');
625
+ fillInTheGapsTextPage.setCorrectAnswerResponseField()
626
+ .eq(1)
627
+ .parents('.response-input-field')
628
+ .should('have.attr', 'width', '250px')
629
+ .and('have.attr', 'height', '180px');
630
+ });
631
+
632
+ //Height and width test cases for preview tab
633
+ //TODO: We will need to revisit below case as it will fail for mobile view
634
+ it('When the user has not set \'Height\' and \'Width\' for the response accordion then the default dimension of the response field in the preview tab response field should be (197x46)px', () => {
635
+ cy.log('Pre step: clearing the set values of height and width to bring back the dimensions of the response field to default dimensions')
636
+ fillInTheGapsTextPage.widthInputField()
637
+ .clear()
638
+ .should('have.value', '');
639
+ fillInTheGapsTextPage.heightInputField()
640
+ .clear()
641
+ .should('have.value', '');
642
+ fillInTheGapsTextPage.responseAccordionWrapper()
643
+ .each(($el) => {
644
+ cy.wrap($el)
645
+ .within(() => {
646
+ fillInTheGapsTextPage.heightInputField()
647
+ .clear()
648
+ .should('have.value', '');
649
+ fillInTheGapsTextPage.widthInputField()
650
+ .clear()
651
+ .should('have.value', '');
652
+ });
653
+ })
654
+ fillInTheGapsTextPage.steps.switchToPreviewTab();
655
+ fillInTheGapsTextPage.previewTabResponseField()
656
+ .each(($el) => {
657
+ cy.wrap($el)
658
+ .parents('.response-input-field')
659
+ .should('have.attr', 'height', '46px')
660
+ .and('have.attr', 'width', '13.7em');
661
+ });
662
+ });
663
+
664
+ it('When the user has set \'Height\' for the response field then the height of the preview tab response field should get updated accordingly in the preview tab', () => {
665
+ cy.log('Pre step: Switch to Edit tab')
666
+ fillInTheGapsTextPage.steps.switchToEditTab();
667
+ fillInTheGapsTextPage.steps.setHeightInResponseAccordion(0, '100');
668
+ fillInTheGapsTextPage.steps.switchToPreviewTab();
669
+ fillInTheGapsTextPage.previewTabResponseField()
670
+ .eq(0)
671
+ .parents('.response-input-field')
672
+ .should('have.attr', 'height', '100px');
673
+ });
674
+
675
+ it('When the user has set \'Width\' for the response field then the width of the preview tab response field should get updated accordingly in the preview tab', () => {
676
+ cy.log('Pre step: Switch to Edit tab')
677
+ fillInTheGapsTextPage.steps.switchToEditTab();
678
+ fillInTheGapsTextPage.steps.setWidthInResponseAccordion(0, '100');
679
+ fillInTheGapsTextPage.steps.switchToPreviewTab();
680
+ fillInTheGapsTextPage.previewTabResponseField()
681
+ .eq(0)
682
+ .parents('.response-input-field')
683
+ .should('have.attr', 'width', '100px');
684
+ });
685
+
686
+ it('When the user has set width below 80px then the width should remain 80px in the preview tab', () => {
687
+ cy.log('Pre step: Switch to Edit tab')
688
+ fillInTheGapsTextPage.steps.switchToEditTab();
689
+ fillInTheGapsTextPage.steps.setWidthInResponseAccordion(0, '20');
690
+ fillInTheGapsTextPage.steps.switchToPreviewTab();
691
+ fillInTheGapsTextPage.previewTabResponseField()
692
+ .eq(0)
693
+ .parents('.response-input-field')
694
+ .should('have.attr', 'width', '80px');
695
+ });
696
+
697
+ it('When the user has set width above 400px then the width should remain 400px in the preview tab', () => {
698
+ cy.log('Pre step: Switch to Edit tab')
699
+ fillInTheGapsTextPage.steps.switchToEditTab();
700
+ fillInTheGapsTextPage.steps.setWidthInResponseAccordion(0, '800');
701
+ fillInTheGapsTextPage.steps.switchToPreviewTab();
702
+ fillInTheGapsTextPage.previewTabResponseField()
703
+ .eq(0)
704
+ .parents('.response-input-field')
705
+ .should('have.attr', 'width', '400px');
706
+ });
707
+
708
+ it('When the user has set \'Height\' and \'Width\' in the individual responses accordion then it should override the \'Height\' and \'Width\'set in the \'Advanced settings for all response areas\' in the preview tab', () => {
709
+ cy.log('Pre step: Switch to Edit tab')
710
+ fillInTheGapsTextPage.steps.switchToEditTab();
711
+ fillInTheGapsTextPage.widthInputField()
712
+ .clear()
713
+ .type('250')
714
+ .should('have.value', '250');
715
+ fillInTheGapsTextPage.heightInputField()
716
+ .clear()
717
+ .type('180')
718
+ .should('have.value', '180');
719
+ fillInTheGapsTextPage.steps.setWidthInResponseAccordion(0, '175');
720
+ fillInTheGapsTextPage.steps.setHeightInResponseAccordion(0, '120');
721
+ fillInTheGapsTextPage.steps.switchToPreviewTab();
722
+ fillInTheGapsTextPage.previewTabResponseField()
723
+ .eq(0)
724
+ .parents('.response-input-field')
725
+ .should('have.attr', 'width', '175px')
726
+ .and('have.attr', 'height', '120px');
727
+ fillInTheGapsTextPage.previewTabResponseField()
728
+ .eq(1)
729
+ .parents('.response-input-field')
730
+ .should('have.attr', 'width', '250px')
731
+ .and('have.attr', 'height', '180px')
732
+ });
733
+ });
734
+ });