itemengine-cypress-automation 1.0.27 → 1.0.28

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,591 @@
1
+ import { fillInTheGapsDropdownPage } from "../../../pages/fillInTheGapsDropdownPage";
2
+ import abortEarlySetup from "../../../support/helpers/abortEarly";
3
+ const css = Cypress.env('css');
4
+
5
+ let optionsForResponse1 = ['changing', 'progressively', 'healthy', 'new'];
6
+
7
+ describe('Create Item page - Fill in the gaps - text: Question Insructions, Question , Set Correct Answer, Alternate Correct Answer', () => {
8
+ before(() => {
9
+ cy.loginAs('admin');
10
+ });
11
+
12
+ describe('Question Instructions input field - Edit tab', () => {
13
+ abortEarlySetup();
14
+ before(() => {
15
+ cy.log('Navigating to fill in the gaps - dropdown question type');
16
+ fillInTheGapsDropdownPage.steps.navigateToCreateQuestion('fill in the gaps with dropdown');
17
+ });
18
+
19
+ fillInTheGapsDropdownPage.tests.verifyQuestionInstructionsInputFieldEditTab();
20
+ });
21
+
22
+ describe('Question Instructions input field - Preview tab', () => {
23
+ abortEarlySetup();
24
+ before(() => {
25
+ cy.log('Navigating to fill in the gaps - dropdown question type');
26
+ fillInTheGapsDropdownPage.steps.navigateToCreateQuestion('fill in the gaps with dropdown');
27
+ });
28
+
29
+ fillInTheGapsDropdownPage.tests.verifyQuestionInstructionsInputFieldPreviewTab();
30
+ });
31
+
32
+ describe('Question input field', () => {
33
+ abortEarlySetup();
34
+ before(() => {
35
+ fillInTheGapsDropdownPage.steps.navigateToCreateQuestion('fill in the gaps with dropdown');
36
+ cy.barsPreLoaderWait();
37
+ });
38
+
39
+ it('\'Question\' label and input field should be displayed and should be prefilled with the text- \"Sample \'Lorem Ipsum\' text along with a response token with text \'Response\'"', () => {
40
+ fillInTheGapsDropdownPage.questionLabel()
41
+ .verifyInnerText('Question');
42
+ fillInTheGapsDropdownPage.questionInputField()
43
+ .should('have.text', 'Lorem ipsum dolor sit amet, 1Responsecloseonsectetur adipiscing elit. Ut pellentesque tinciduntornare. Integer porttitor est quis urna porttitor, eget tempus tellus dapibus.');
44
+ fillInTheGapsDropdownPage.responseToken()
45
+ .should('have.length', 1);
46
+ fillInTheGapsDropdownPage.responseToken()
47
+ .find('content')
48
+ .should('have.text', 'Response');
49
+ });
50
+
51
+ it('The response token should be displayed with a numeric count along with a close button in the question input field', () => {
52
+ fillInTheGapsDropdownPage.steps.verifyResponseTokenIndexAndCloseButton(0)
53
+ });
54
+
55
+ it('CSS of Question input field contents', { tags: 'css' }, () => {
56
+ fillInTheGapsDropdownPage.questionInputField()
57
+ .verifyCSS(css.color.text, css.fontSize.default, css.fontWeight.regular);
58
+ fillInTheGapsDropdownPage.responseToken()
59
+ .verifyCSS(css.color.text, css.fontSize.default, css.fontWeight.regular)
60
+ fillInTheGapsDropdownPage.responseTokenCloseButton()
61
+ .should('have.css', 'border', `1px solid ${css.color.activeButtons}`);
62
+ });
63
+
64
+ it('When the user switches to the Preview tab, the sample \'Lorem Ipsum\' text along with a response dropdown should be displayed', () => {
65
+ fillInTheGapsDropdownPage.steps.switchToPreviewTab()
66
+ fillInTheGapsDropdownPage.previewTabQuestionContainer()
67
+ .verifyInnerText('Lorem ipsum dolor sit amet, \n​\n​\nonsectetur adipiscing elit. Ut pellentesque tinciduntornare. Integer porttitor est quis urna porttitor, eget tempus tellus dapibus.');
68
+ fillInTheGapsDropdownPage.previewTabResponseDropdown()
69
+ .should('have.length', 1)
70
+ .and('be.visible');
71
+ });
72
+
73
+ it('When the user edits text in the question input field then the updated question should be displayed in the preview tab', () => {
74
+ fillInTheGapsDropdownPage.steps.switchToEditTab();
75
+ fillInTheGapsDropdownPage.questionInputField()
76
+ .click()
77
+ .type(' Lorem Ipsum')
78
+ .should('have.text', 'Lorem ipsum dolor sit amet, 1Responsecloseonsectetur adipiscing elit. Ut pellentesque tinciduntornare. Integer porttitor est quis urna porttitor, eget tempus tellus dapibus. Lorem Ipsum')
79
+ fillInTheGapsDropdownPage.steps.switchToPreviewTab();
80
+ fillInTheGapsDropdownPage.previewTabQuestionContainer()
81
+ .verifyInnerText('Lorem ipsum dolor sit amet, \n​\n​\nonsectetur adipiscing elit. Ut pellentesque tinciduntornare. Integer porttitor est quis urna porttitor, eget tempus tellus dapibus. Lorem Ipsum');
82
+ });
83
+
84
+ it('When the user focuses in the question input field, the CKEditor toolbar should be displayed with a \'+Response\' button and when the user clicks on \'+Response\' button, a response token in the question input field, a response dropdown along with \'Response #\' label in the \'Set correct answer\' section, a \'Response #\' accordion in the additional settings accordion and a new response dropdown the \'Preview tab\' should get added', () => {
85
+ fillInTheGapsDropdownPage.steps.switchToEditTab();
86
+ fillInTheGapsDropdownPage.questionInputField()
87
+ .click();
88
+ fillInTheGapsDropdownPage.ckEditorAddResponseButton()
89
+ .should('be.visible');
90
+ fillInTheGapsDropdownPage.ckEditorAddResponseButton()
91
+ .click();
92
+ cy.log('Checking if 2nd response token gets added in the question input field with \'2\' count and a close icon')
93
+ fillInTheGapsDropdownPage.steps.verifyResponseTokenIndexAndCloseButton(1)
94
+ cy.log('Checking if Options for response 2 is added below the question instructions')
95
+ fillInTheGapsDropdownPage.optionsLabel()
96
+ .eq(1)
97
+ .verifyInnerText('Options for response 2');
98
+ fillInTheGapsDropdownPage.steps.verifyOptionsForResponseContents(1)
99
+ cy.log('Checking if 2nd dropdown gets added in the set correct answer section with \'Response 2\' label')
100
+ fillInTheGapsDropdownPage.responseDropdownSetCorrectAnswerSection()
101
+ .eq(1)
102
+ .should('have.class', 'Mui-disabled')
103
+ .should('be.visible');
104
+ fillInTheGapsDropdownPage.setCorrectAnswerResponseFieldLabel()
105
+ .eq(1)
106
+ .verifyInnerText('Response 2')
107
+ .and('be.visible');
108
+ cy.log('Checking if 2nd response accordion gets added in the additional settings panel with \'Response 2\' label')
109
+ fillInTheGapsDropdownPage.steps.expandAdditonalSettings();
110
+ fillInTheGapsDropdownPage.additionalSettingsResponseAccordion()
111
+ .eq(1)
112
+ .verifyInnerText('Response 2')
113
+ .and('be.visible');
114
+ fillInTheGapsDropdownPage.steps.switchToPreviewTab()
115
+ fillInTheGapsDropdownPage.previewTabResponseDropdown()
116
+ .should('have.length', 2)
117
+ .and('be.visible');
118
+ fillInTheGapsDropdownPage.previewTabQuestionContainer()
119
+ .verifyInnerText('Lorem ipsum dolor sit amet, \n​\n​\nonsectetur adipiscing elit. Ut pellentesque tinciduntornare. Integer porttitor est quis urna porttitor, eget tempus tellus dapibus. Lorem Ipsum\n​\n​');
120
+ });
121
+
122
+ it('When the user clicks on the \'close\' button present on a response token, the response token in the question input field should get removed and the count of the response tokens present in the question input field should get updated accordingly, Options for \'Response #\', response dropdown along with \'Response #\' label in the \'Set correct answer\' section, \'Response #\' accordion in the additional settings accordion and the respective response dropdown in the \'Preview tab\' should also get removed', () => {
123
+ fillInTheGapsDropdownPage.steps.switchToEditTab();
124
+ fillInTheGapsDropdownPage.steps.deleteAResponseToken(1);
125
+ cy.log('Checking if 2nd response token gets removed from the question input field and the numeric counts get updated')
126
+ fillInTheGapsDropdownPage.responseToken()
127
+ .eq(1)
128
+ .should('not.exist');
129
+ fillInTheGapsDropdownPage.steps.verifyResponseTokenIndexAndCloseButton(0)
130
+ cy.log('Checking the Options for response 2 container and it\'s label does not exist')
131
+ fillInTheGapsDropdownPage.optionsSectionWrapper()
132
+ .eq(1)
133
+ .should('not.exist');
134
+ fillInTheGapsDropdownPage.optionsLabel()
135
+ .contains('Options for response 2')
136
+ .should('not.exist');
137
+ cy.log('Checking the Options for response 2 dropdown and it\'s label does not exist')
138
+ fillInTheGapsDropdownPage.responseDropdownSetCorrectAnswerSection()
139
+ .eq(1)
140
+ .should('not.exist');
141
+ fillInTheGapsDropdownPage.setCorrectAnswerResponseFieldLabel()
142
+ .contains('Response 2')
143
+ .should('not.exist');
144
+ cy.log('Checking the Options for response 2 accordion does not exist')
145
+ fillInTheGapsDropdownPage.additionalSettingsResponseAccordion()
146
+ .contains('Response 2')
147
+ .should('not.exist');
148
+ cy.log('Switching to Preview tab and checking only 1 dropdown should exist')
149
+ fillInTheGapsDropdownPage.steps.switchToPreviewTab()
150
+ fillInTheGapsDropdownPage.previewTabResponseDropdown()
151
+ .should('have.length', 1)
152
+ .and('be.visible');
153
+ fillInTheGapsDropdownPage.previewTabQuestionContainer()
154
+ .verifyInnerText('Lorem ipsum dolor sit amet, \n​\n​\nonsectetur adipiscing elit. Ut pellentesque tinciduntornare. Integer porttitor est quis urna porttitor, eget tempus tellus dapibus. Lorem Ipsum');
155
+ });
156
+
157
+ it('When the user removes all response tokens from the question input field, an error message \'Error: Minimum one response token is required.\' should be displayed', () => {
158
+ fillInTheGapsDropdownPage.steps.switchToEditTab();
159
+ fillInTheGapsDropdownPage.steps.deleteAResponseToken(0);
160
+ fillInTheGapsDropdownPage.errorMessage()
161
+ .verifyInnerText('Error: Minimum one response token is required.')
162
+ });
163
+
164
+ fillInTheGapsDropdownPage.tests.verifyCSSAnda11yOfErrorMessage()
165
+
166
+ fillInTheGapsDropdownPage.tests.addTokenAndVerifyMinimumOneTokenRequiredErrorMessageNotExist()
167
+
168
+ fillInTheGapsDropdownPage.tests.verifyQuestionInputFieldPlaceholderText();
169
+ });
170
+
171
+ describe('Options for response', () => {
172
+ abortEarlySetup();
173
+ before(() => {
174
+ fillInTheGapsDropdownPage.steps.navigateToCreateQuestion('fill in the gaps with dropdown');
175
+ cy.barsPreLoaderWait();
176
+ });
177
+
178
+ it('\'Options for response 1\' label should be displayed', () => {
179
+ fillInTheGapsDropdownPage.optionsLabel()
180
+ .should('have.text', 'Options for response 1');
181
+ });
182
+
183
+ it('By default, 4 \'Options\' input fields should be displayed with placeholder text and Drag handle and Delete option icon buttons should be displayed besides each input field', () => {
184
+ fillInTheGapsDropdownPage.steps.verifyOptionsForResponseContents(0)
185
+ });
186
+
187
+ it('When user hovers over the drag handle of the options then \'Drag to reorder\' message should be displayed on a tooltip and the tooltip should disappear if focus is removed from the drag handle', () => {
188
+ fillInTheGapsDropdownPage.optionWrapper()
189
+ .eq(0)
190
+ .within(() => {
191
+ fillInTheGapsDropdownPage.dragHandleButton()
192
+ .trigger('mouseover');
193
+ });
194
+ fillInTheGapsDropdownPage.tooltipText()
195
+ .should('have.text', 'Drag to reorder');
196
+ fillInTheGapsDropdownPage.optionWrapper()
197
+ .eq(0)
198
+ .within(() => {
199
+ fillInTheGapsDropdownPage.dragHandleButton()
200
+ .trigger('mouseout');
201
+ });
202
+ fillInTheGapsDropdownPage.tooltipText()
203
+ .should('not.exist');
204
+ });
205
+
206
+ it('When user hovers over the enabled delete icon of the options then \'Delete option\' message should be displayed on a tooltip and the tooltip should disappear if focus is removed from the delete icon', () => {
207
+ fillInTheGapsDropdownPage.optionWrapper()
208
+ .eq(0)
209
+ .within(() => {
210
+ fillInTheGapsDropdownPage.deleteButton()
211
+ .trigger('mouseover');
212
+ });
213
+ fillInTheGapsDropdownPage.tooltipText()
214
+ .verifyInnerText('Delete option');
215
+ fillInTheGapsDropdownPage.optionWrapper()
216
+ .eq(0)
217
+ .within(() => {
218
+ fillInTheGapsDropdownPage.deleteButton()
219
+ .trigger('mouseout');
220
+ });
221
+ fillInTheGapsDropdownPage.tooltipText()
222
+ .should('not.exist');
223
+ });
224
+
225
+ it('\'Add Option\' button should be present', () => {
226
+ fillInTheGapsDropdownPage.addOptionButton()
227
+ .should('have.text', 'Add option')
228
+ .and('be.visible');
229
+ });
230
+
231
+ it('CSS of Options section', { tags: 'css' }, () => {
232
+ fillInTheGapsDropdownPage.optionsLabel()
233
+ .verifyCSS(css.color.sectionHeading, css.fontSize.normal, css.fontWeight.semibold);
234
+ fillInTheGapsDropdownPage.optionWrapper()
235
+ .eq(0)
236
+ .within(() => {
237
+ fillInTheGapsDropdownPage.dragHandleButton()
238
+ .verifyCSS(css.color.secondaryBtnActive, css.fontSize.normal, css.fontWeight.regular);
239
+ fillInTheGapsDropdownPage.deleteButton()
240
+ .verifyPseudoClassBeforeProperty('color', css.color.deleteIcon);
241
+ fillInTheGapsDropdownPage.optionsForResponseInputField()
242
+ .verifyCSS(css.color.text, css.fontSize.default, css.fontWeight.regular);
243
+ });
244
+ fillInTheGapsDropdownPage.addOptionButton()
245
+ .verifyCSS(css.color.secondaryBtnActive, css.fontSize.default, css.fontWeight.medium);
246
+ });
247
+
248
+ it('When user adds an option using \'Add Option\' button then the added option input field should be displayed and option numeration should increment', () => {
249
+ fillInTheGapsDropdownPage.addOptionButton()
250
+ .click();
251
+ fillInTheGapsDropdownPage.optionWrapper()
252
+ .eq(4)
253
+ .within(() => {
254
+ fillInTheGapsDropdownPage.optionsForResponseInputField()
255
+ .should('have.attr', 'placeholder', 'Enter option');
256
+ fillInTheGapsDropdownPage.dragHandleButton()
257
+ .should('exist');
258
+ fillInTheGapsDropdownPage.deleteButton()
259
+ .should('be.visible');
260
+ fillInTheGapsDropdownPage.optionNumeration()
261
+ .should('have.text', 5)
262
+ });
263
+ });
264
+
265
+ it('When user clicks on the \'Delete\' option button then the respective options input field should get deleted and option numeration should change accordingly', () => {
266
+ fillInTheGapsDropdownPage.optionWrapper()
267
+ .eq(2)
268
+ .within(() => {
269
+ fillInTheGapsDropdownPage.deleteButton()
270
+ .click();
271
+ });
272
+ fillInTheGapsDropdownPage.steps.verifyOptionsForResponseContents(0)
273
+ });
274
+
275
+ it('When number of options are less than 3, the Delete option icon buttons should be displayed in disabled state', () => {
276
+ for (let index = 0; index < 2; index++) {
277
+ fillInTheGapsDropdownPage.optionWrapper()
278
+ .eq(index)
279
+ .within(() => {
280
+ fillInTheGapsDropdownPage.deleteButton()
281
+ .click();
282
+ });
283
+ }
284
+ fillInTheGapsDropdownPage.deleteButton()
285
+ .should('be.disabled')
286
+ });
287
+
288
+ it('When user hovers over the disabled \'Delete\' icon buttons of the options then \'Minimum two options are required\' message should be displayed on a tooltip and the tooltip should disappear if focus is removed from the \'Delete\' icon button', () => {
289
+ fillInTheGapsDropdownPage.optionWrapper()
290
+ .eq(0)
291
+ .within(() => {
292
+ fillInTheGapsDropdownPage.deleteButton()
293
+ .trigger('mouseover', { force: true });
294
+ });
295
+ fillInTheGapsDropdownPage.tooltipText()
296
+ .verifyInnerText('Minimum two options are required');
297
+ fillInTheGapsDropdownPage.optionWrapper()
298
+ .eq(0)
299
+ .within(() => {
300
+ fillInTheGapsDropdownPage.deleteButton()
301
+ .trigger('mouseout', { force: true });
302
+ });
303
+ fillInTheGapsDropdownPage.tooltipText()
304
+ .should('not.exist');
305
+ });
306
+ it('CSS of disabled delete icon', { tags: 'css' }, () => {
307
+ fillInTheGapsDropdownPage.deleteButton()
308
+ .eq(0)
309
+ .should('have.css', 'opacity', '0.5')
310
+ .verifyPseudoClassBeforeProperty('color', css.color.deleteIcon)
311
+ });
312
+
313
+ it('Accessibility of disabled delete icon', { tags: 'a11y' }, () => {
314
+ cy.checkAccessibility(fillInTheGapsDropdownPage.deleteButton());
315
+ });
316
+
317
+ //Note: a11y covered in header section
318
+
319
+ it('When user focus in and out of any of the \'Options\' input field without typing anything, an error message should be thrown', () => {
320
+ fillInTheGapsDropdownPage.optionWrapper()
321
+ .eq(0)
322
+ .within(() => {
323
+ fillInTheGapsDropdownPage.optionsForResponseInputField()
324
+ .click()
325
+ .blur();
326
+ fillInTheGapsDropdownPage.optionIsRequiredErrorMessage()
327
+ .should('have.text', 'Error: Option is required.');
328
+ });
329
+ });
330
+
331
+ it('CSS of error message', { tags: 'css' }, () => {
332
+ fillInTheGapsDropdownPage.optionWrapper()
333
+ .eq(0)
334
+ .within(() => {
335
+ fillInTheGapsDropdownPage.optionIsRequiredErrorMessage()
336
+ .verifyCSS(css.color.errorText, css.fontSize.small, css.fontWeight.regular);
337
+ });
338
+ });
339
+
340
+ it('Accessibility of error message', { tags: 'a11y' }, () => {
341
+ cy.checkAccessibility(fillInTheGapsDropdownPage.optionIsRequiredErrorMessage())
342
+ });
343
+
344
+ it('When user enters text in options input field then the error message \'Error: Option is required.\' should disappear', () => {
345
+ fillInTheGapsDropdownPage.steps.addInputToResponseOptionFields(0, ['changing']);
346
+ fillInTheGapsDropdownPage.optionWrapper()
347
+ .eq(0)
348
+ .within(() => {
349
+ fillInTheGapsDropdownPage.optionIsRequiredErrorMessage()
350
+ .should('not.exist');
351
+ });
352
+ cy.log('Post step: Clear the added text in the input field')
353
+ fillInTheGapsDropdownPage.optionsForResponseInputField()
354
+ .eq(0)
355
+ .clear();
356
+ });
357
+ });
358
+
359
+ describe('Options cases in Set correct answer section', () => {
360
+ abortEarlySetup();
361
+ before(() => {
362
+ fillInTheGapsDropdownPage.steps.navigateToCreateQuestion('fill in the gaps with dropdown');
363
+ cy.barsPreLoaderWait();
364
+ });
365
+
366
+ it('When user has not entered text in the options input field then the response dropdowns should be disabled and the user should not be able to expand the dropdown in the \'Set Correct Answer\'', () => {
367
+ fillInTheGapsDropdownPage.responseDropdownSetCorrectAnswerSection()
368
+ .should('have.class', 'Mui-disabled');
369
+ fillInTheGapsDropdownPage.responseDropdownSetCorrectAnswerSection()
370
+ .click();
371
+ fillInTheGapsDropdownPage.dropdownList()
372
+ .should('not.exist');
373
+ });
374
+
375
+ it('When the user has not added any options, on hovering over the dropdown, a tooltip \'Please add options\' should be displayed and on focusing away from the dropdown, the tooltip should disappear', () => {
376
+ fillInTheGapsDropdownPage.responseDropdownSetCorrectAnswerSection()
377
+ .verifyTooltip('Please add options');
378
+ });
379
+
380
+ it('CSS of set correct answer section disabled response dropdown', { tags: 'css' }, () => {
381
+ fillInTheGapsDropdownPage.responseDropdownSetCorrectAnswerSection()
382
+ .should('have.css', 'border', `1px solid ${css.color.figDefaultComponentBorder}`)
383
+ .should('have.css', 'opacity', '1')
384
+ .verifyPseudoClassBeforeProperty('color', css.color.secondaryBtn);
385
+ });
386
+
387
+ it('Accessibility of set correct answer section disabled response dropdown', { tags: 'a11y' }, () => {
388
+ cy.checkAccessibility(fillInTheGapsDropdownPage.responseDropdownSetCorrectAnswerSection());
389
+ });
390
+
391
+ it('When user enters a text in options input field then the entered options should be displayed in response dropdown of \'Set Correct Answer\' section', () => {
392
+ fillInTheGapsDropdownPage.steps.addInputToResponseOptionFields(0, optionsForResponse1);
393
+ fillInTheGapsDropdownPage.responseDropdownSetCorrectAnswerSection()
394
+ .click();
395
+ fillInTheGapsDropdownPage.steps.verifyResponseDropdownOptions(optionsForResponse1);
396
+ });
397
+
398
+ //https://redmine.zeuslearning.com/issues/541369
399
+ it('CSS of set correct answer section response dropdown in active state', { tags: 'css' }, () => {
400
+ fillInTheGapsDropdownPage.responseDropdownOptions()
401
+ .eq(0)
402
+ .verifyCSS(css.color.liText, css.fontSize.default, css.fontWeight.regular)
403
+ .should('have.css', 'background-color', css.color.transparent);
404
+ });
405
+
406
+ it('Accessibility of set correct answer section response dropdown in active state', { tags: 'a11y' }, () => {
407
+ cy.checkAccessibility(fillInTheGapsDropdownPage.dropdownList())
408
+ cy.log('Post step: Collapsing the response dropdown')
409
+ });
410
+
411
+ it('When user deletes an option then the deleted option input field and response dropdown in \'Set Correct Answer\' section should not be displayed', () => {
412
+ fillInTheGapsDropdownPage.optionWrapper()
413
+ .eq(3)
414
+ .within(() => {
415
+ fillInTheGapsDropdownPage.deleteButton()
416
+ .click();
417
+ });
418
+ cy.log('Checking the deleted input field should not exist in the dropdown')
419
+ fillInTheGapsDropdownPage.responseDropdownSetCorrectAnswerSection()
420
+ .click();
421
+ fillInTheGapsDropdownPage.responseDropdownOptions()
422
+ .contains(`${optionsForResponse1[3]}`)
423
+ .should('not.exist');
424
+ fillInTheGapsDropdownPage.steps.verifyResponseDropdownOptions(optionsForResponse1.slice(0, 3));
425
+ cy.log('Post step: Collapsing the response dropdown')
426
+ cy.get('body')
427
+ .click();
428
+ });
429
+
430
+ it('When user adds an option using \'Add Option\' button then the added option input field should be displayed along with the added option in the \'Set Correct Answer\' section response dropdown', () => {
431
+ fillInTheGapsDropdownPage.addOptionButton()
432
+ .click();
433
+ cy.log('Checking the added input field should be displayed')
434
+ fillInTheGapsDropdownPage.optionsForResponseInputField()
435
+ .eq(3)
436
+ .should('exist')
437
+ .type(`${optionsForResponse1[3]}`)
438
+ cy.log('Checking the added option should be displayed in the dropdown')
439
+ fillInTheGapsDropdownPage.responseDropdownSetCorrectAnswerSection()
440
+ .click();
441
+ fillInTheGapsDropdownPage.steps.verifyResponseDropdownOptions(optionsForResponse1);
442
+ cy.log('Closing the dropdown')
443
+ cy.get('body')
444
+ .click();
445
+ });
446
+
447
+ it('When the user has added two same options in the options section, only one occurrence of that option should be listed in the dropdown', () => {
448
+ fillInTheGapsDropdownPage.optionsForResponseInputField()
449
+ .eq(3)
450
+ .clear()
451
+ .type(`${optionsForResponse1[1]}`);
452
+ fillInTheGapsDropdownPage.responseDropdownSetCorrectAnswerSection()
453
+ .click();
454
+ fillInTheGapsDropdownPage.steps.verifyResponseDropdownOptions(optionsForResponse1.slice(0, 3))
455
+ fillInTheGapsDropdownPage.responseDropdownOptions()
456
+ .should('have.length', 3);
457
+ cy.log('Post step: Collapsing the response dropdown')
458
+ cy.get('body')
459
+ .click();
460
+ });
461
+ });
462
+
463
+ describe('Options cases in Preview tab', () => {
464
+ abortEarlySetup();
465
+ before(() => {
466
+ fillInTheGapsDropdownPage.steps.navigateToCreateQuestion('fill in the gaps with dropdown');
467
+ cy.barsPreLoaderWait();
468
+ });
469
+
470
+ it('When user has not entered text in the options input field then the response dropdowns should be disabled in the \'Preview\' tab', () => {
471
+ cy.log('Switching to preview tab to check disabled dropdown option')
472
+ fillInTheGapsDropdownPage.steps.switchToPreviewTab();
473
+ fillInTheGapsDropdownPage.previewTabResponseDropdown()
474
+ .should('have.class', 'Mui-disabled');
475
+ cy.log('Post step: Switching back to edit tab')
476
+ fillInTheGapsDropdownPage.steps.switchToEditTab();
477
+ });
478
+
479
+ it('CSS of disabled preview tab response dropdown', { tags: 'css' }, () => {
480
+ cy.log('Switching to preview tab to check disabled dropdown css')
481
+ fillInTheGapsDropdownPage.steps.switchToPreviewTab();
482
+ fillInTheGapsDropdownPage.previewTabResponseDropdown()
483
+ .should('have.css', 'border', `1px solid ${css.color.figDefaultComponentBorder}`)
484
+ .should('have.css', 'opacity', '1')
485
+ .verifyPseudoClassBeforeProperty('color', css.color.secondaryBtn);
486
+ cy.log('Post step: Switching back to edit tab')
487
+ fillInTheGapsDropdownPage.steps.switchToEditTab();
488
+ });
489
+
490
+ it('Accessibility of preview tab disabled response dropdown', { tags: 'a11y' }, () => {
491
+ cy.log('Switching to preview tab to check disabled dropdown a11y')
492
+ fillInTheGapsDropdownPage.steps.switchToPreviewTab();
493
+ cy.checkAccessibility(fillInTheGapsDropdownPage.previewTabResponseDropdown());
494
+ cy.log('Post step: Switching back to edit tab')
495
+ fillInTheGapsDropdownPage.steps.switchToEditTab();
496
+ });
497
+
498
+ it('When user enters a text in options input field then the entered options should be displayed in response dropdown of \'Preview\' tab', () => {
499
+ fillInTheGapsDropdownPage.steps.addInputToResponseOptionFields(0, optionsForResponse1);
500
+ cy.log('Switching to preview tab to check Preview tab response dropdown options')
501
+ fillInTheGapsDropdownPage.steps.switchToPreviewTab()
502
+ fillInTheGapsDropdownPage.previewTabResponseDropdown()
503
+ .click();
504
+ fillInTheGapsDropdownPage.steps.verifyResponseDropdownOptions(optionsForResponse1);
505
+ cy.log('selecting an option to collapse the response dropdown')
506
+ fillInTheGapsDropdownPage.steps.selectOptionFromResponseDropdown('new');
507
+ cy.log('Post step: Switching back to edit tab')
508
+ fillInTheGapsDropdownPage.steps.switchToEditTab();
509
+ });
510
+
511
+ //https://redmine.zeuslearning.com/issues/541369
512
+ it('CSS of preview tab response dropdown in active state', { tags: 'css' }, () => {
513
+ cy.log('Switching to preview tab to check Preview tab response dropdown options css')
514
+ fillInTheGapsDropdownPage.steps.switchToPreviewTab()
515
+ fillInTheGapsDropdownPage.previewTabResponseDropdown()
516
+ .click();
517
+ fillInTheGapsDropdownPage.responseDropdownOptions()
518
+ .eq(0)
519
+ .verifyCSS(css.color.liText, css.fontSize.default, css.fontWeight.regular)
520
+ .should('have.css', 'background-color', css.color.transparent);
521
+ cy.log('selecting an option to collapse the response dropdown')
522
+ fillInTheGapsDropdownPage.steps.selectOptionFromResponseDropdown('new');
523
+ cy.log('Post step: Switching back to edit tab')
524
+ fillInTheGapsDropdownPage.steps.switchToEditTab();
525
+ });
526
+
527
+ it('Accessibility of preview tab response dropdown in active state', { tags: 'a11y' }, () => {
528
+ cy.log('Switching to preview tab to check Preview tab response dropdown options a11y')
529
+ fillInTheGapsDropdownPage.steps.switchToPreviewTab()
530
+ fillInTheGapsDropdownPage.previewTabResponseDropdown()
531
+ .click();
532
+ cy.checkAccessibility(fillInTheGapsDropdownPage.dropdownList())
533
+ cy.log('selecting an option to collapse the response dropdown')
534
+ fillInTheGapsDropdownPage.steps.selectOptionFromResponseDropdown('new');
535
+ cy.log('Post step: Switching back to edit tab')
536
+ fillInTheGapsDropdownPage.steps.switchToEditTab();
537
+ });
538
+
539
+ it('When user deletes an option then the deleted option input field and response dropdown in \'Preview\' tab section should not be displayed', () => {
540
+ fillInTheGapsDropdownPage.optionWrapper()
541
+ .eq(3)
542
+ .within(() => {
543
+ fillInTheGapsDropdownPage.deleteButton()
544
+ .click();
545
+ });
546
+ cy.log('Checking the deleted input field should not exist in the dropdown')
547
+ fillInTheGapsDropdownPage.steps.switchToPreviewTab()
548
+ fillInTheGapsDropdownPage.previewTabResponseDropdown()
549
+ .click();
550
+ fillInTheGapsDropdownPage.responseDropdownOptions()
551
+ .contains(`${optionsForResponse1[3]}`)
552
+ .should('not.exist');
553
+ fillInTheGapsDropdownPage.steps.verifyResponseDropdownOptions(optionsForResponse1.slice(0, 3));
554
+ cy.log('selecting an option to collapse the response dropdown')
555
+ fillInTheGapsDropdownPage.steps.selectOptionFromResponseDropdown('changing');
556
+ cy.log('Post step: Switching back to edit tab')
557
+ fillInTheGapsDropdownPage.steps.switchToEditTab();
558
+ });
559
+
560
+ it('When user adds an option using \'Add Option\' button then the added option should be displayed in the \'Preview\' tab response dropdown', () => {
561
+ fillInTheGapsDropdownPage.addOptionButton()
562
+ .click();
563
+ fillInTheGapsDropdownPage.optionsForResponseInputField()
564
+ .eq(3)
565
+ .type(`${optionsForResponse1[3]}`);
566
+ cy.log('Checking the added option should be displayed in the dropdown')
567
+ fillInTheGapsDropdownPage.steps.switchToPreviewTab();
568
+ fillInTheGapsDropdownPage.previewTabResponseDropdown()
569
+ .click();
570
+ fillInTheGapsDropdownPage.steps.verifyResponseDropdownOptions(optionsForResponse1);
571
+ cy.log('selecting an option to collapse the response dropdown')
572
+ fillInTheGapsDropdownPage.steps.selectOptionFromResponseDropdown('changing');
573
+ cy.log('Post step: Switching back to edit tab')
574
+ fillInTheGapsDropdownPage.steps.switchToEditTab();
575
+ });
576
+
577
+ it('When the user has added two same options in the options section, only one occurence of that option should be listed in the dropdown', () => {
578
+ fillInTheGapsDropdownPage.optionsForResponseInputField()
579
+ .eq(3)
580
+ .clear()
581
+ .type(`${optionsForResponse1[1]}`);
582
+ cy.log('Switching to preview tab to check Preview tab response dropdown options')
583
+ fillInTheGapsDropdownPage.steps.switchToPreviewTab()
584
+ fillInTheGapsDropdownPage.previewTabResponseDropdown()
585
+ .click();
586
+ fillInTheGapsDropdownPage.steps.verifyResponseDropdownOptions(optionsForResponse1.slice(0, 3))
587
+ fillInTheGapsDropdownPage.responseDropdownOptions()
588
+ .should('have.length', 3);
589
+ });
590
+ });
591
+ });