itemengine-cypress-automation 1.0.10 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,861 @@
1
+ import { dialogBoxBase, shortTextResponsePage } from "../../../pages";
2
+ import { commonComponents } from "../../../pages/components";
3
+ import abortEarlySetup from "../../../support/helpers/abortEarly";
4
+ import { specialOrMathCharacters } from "../../../fixtures/specialAndMathCharacters";
5
+ const css = Cypress.env('css');
6
+ let customSpecialCharacters = [':', ')', '`']
7
+
8
+ describe('Short text response - Additional settings', () => {
9
+ before(() => {
10
+ cy.loginAs('admin');
11
+ });
12
+
13
+ describe('Additional Settings accordion', () => {
14
+ abortEarlySetup();
15
+ before(() => {
16
+ shortTextResponsePage.steps.navigateToCreateQuestion('short text response');
17
+ });
18
+
19
+ shortTextResponsePage.tests.verifyAdditonalSettingsAccordionProperties();
20
+ });
21
+
22
+ describe('Additional Settings: Student response area and layout', () => {
23
+ abortEarlySetup();
24
+ before(() => {
25
+ shortTextResponsePage.steps.navigateToCreateQuestion('short text response');
26
+ shortTextResponsePage.steps.expandAdditonalSettings();
27
+ });
28
+
29
+ shortTextResponsePage.tests.verifyStudentResponseAreaAndLayoutLabelAndCSS();
30
+ });
31
+
32
+ describe('Response Accordions: ARIA label', () => {
33
+ abortEarlySetup();
34
+ before(() => {
35
+ shortTextResponsePage.steps.navigateToCreateQuestion('short text response');
36
+ shortTextResponsePage.steps.expandAdditonalSettings();
37
+ });
38
+
39
+ it('CSS of \'ARIA label\' section', { tags: 'css' }, () => {
40
+ shortTextResponsePage.ariaLabelLabel()
41
+ .verifyCSS(css.color.labels, css.fontSize.normal, css.fontWeight.semibold);
42
+ shortTextResponsePage.ariaLabelInputField()
43
+ .verifyCSS(css.color.text, css.fontSize.default, css.fontWeight.regular);
44
+ });
45
+
46
+ //Note: a11y covered in Additional settings accordion, verifyAdditonalSettingsAccordionProperties
47
+
48
+ it('By default, \'ARIA label\' label and empty \'ARIA label\' input field should be displayed', () => {
49
+ shortTextResponsePage.ariaLabelLabel()
50
+ .verifyInnerText('ARIA label');
51
+ shortTextResponsePage.ariaLabelInputField()
52
+ .should('have.value', '');
53
+ });
54
+
55
+ //ARIA label test cases for set correct answer section
56
+ it('When user has not set \'ARIA label\' input field then the default \'ARIA label\' should be displayed in the set correct answer section response field', () => {
57
+ shortTextResponsePage.setCorrectAnswerResponseField()
58
+ .should('have.attr', 'aria-label', 'Enter your response to the question here');
59
+ });
60
+
61
+ it('When the user has set \'ARIA label\' then it should be displayed in the response field in the set correct answer section.', () => {
62
+ shortTextResponsePage.ariaLabelInputField()
63
+ .type('Custom Aria Label')
64
+ .should('have.value', 'Custom Aria Label');
65
+ shortTextResponsePage.setCorrectAnswerResponseField()
66
+ .should('have.attr', 'aria-label', 'Custom Aria Label');
67
+ });
68
+
69
+ it('Accessibility of input field in set correct answer section when custom \'ARIA label\' is set and Custom label', { tags: 'a11y' }, () => {
70
+ cy.checkAccessibility(shortTextResponsePage.setCorrectAnswerResponseField().parents('.short-text-response-input-field'))
71
+ });
72
+
73
+ it('When the user clears the set value in the ARIA label input field, then the default ARIA label should appear again in the set correct answer section', () => {
74
+ shortTextResponsePage.ariaLabelInputField()
75
+ .clear()
76
+ .should('have.value', '');
77
+ shortTextResponsePage.setCorrectAnswerResponseField()
78
+ .should('have.attr', 'aria-label', 'Enter your response to the question here');
79
+ });
80
+
81
+ //ARIA label test cases for preview tab
82
+ it('When user has not set \'ARIA label\' input field then in the preview tab default \'ARIA label\' should be displayed in the response field', () => {
83
+ cy.log('Pre step: Switch to Preview tab')
84
+ shortTextResponsePage.steps.switchToPreviewTab();
85
+ shortTextResponsePage.previewTabResponseField()
86
+ .should('have.attr', 'aria-label', 'Enter your response to the question here');
87
+ });
88
+
89
+ it('When the user has set \'ARIA label\' in the response accordion then it should be displayed in the preview tab response field', () => {
90
+ cy.log('Pre step: Switch to Edit tab')
91
+ shortTextResponsePage.steps.switchToEditTab();
92
+ shortTextResponsePage.ariaLabelInputField()
93
+ .type('Custom Aria Label')
94
+ .should('have.value', 'Custom Aria Label');
95
+ shortTextResponsePage.steps.switchToPreviewTab();
96
+ shortTextResponsePage.previewTabResponseField()
97
+ .should('have.attr', 'aria-label', 'Custom Aria Label');
98
+ });
99
+
100
+ it('Accessibility of input field in preview tab when custom \'ARIA label\' is set', { tags: 'a11y' }, () => {
101
+ cy.checkAccessibility(shortTextResponsePage.previewTabResponseField().parents('.short-text-preview-response-input-field'))
102
+ });
103
+
104
+ it('When the user clears the set value in the ARIA label input field, then the default ARIA label should appear again in the preview tab response field', () => {
105
+ cy.log('Pre step: Switch to Edit tab')
106
+ shortTextResponsePage.steps.switchToEditTab();
107
+ shortTextResponsePage.ariaLabelInputField()
108
+ .clear()
109
+ .should('have.value', '');
110
+ shortTextResponsePage.steps.switchToPreviewTab();
111
+ shortTextResponsePage.previewTabResponseField()
112
+ .should('have.attr', 'aria-label', 'Enter your response to the question here');
113
+ });
114
+ });
115
+
116
+ describe('Additional Settings: Placeholder text', () => {
117
+ abortEarlySetup();
118
+ before(() => {
119
+ shortTextResponsePage.steps.navigateToCreateQuestion('short text response');
120
+ shortTextResponsePage.steps.expandAdditonalSettings();
121
+ });
122
+
123
+ it('\'Placeholder text\' label and input field should be displayed and by default, the input field should be empty', () => {
124
+ shortTextResponsePage.placeholderTextLabel()
125
+ .verifyInnerText('Placeholder text');
126
+ shortTextResponsePage.placeholderTextInputField()
127
+ .should('have.value', '');
128
+ });
129
+
130
+ it('CSS of \'Placeholder text\' section', { tags: 'css' }, () => {
131
+ shortTextResponsePage.placeholderTextLabel()
132
+ .verifyCSS(css.color.labels, css.fontSize.normal, css.fontWeight.semibold);
133
+ shortTextResponsePage.placeholderTextInputField()
134
+ .verifyCSS(css.color.text, css.fontSize.default, css.fontWeight.regular);
135
+ });
136
+
137
+ //Note: a11y covered in Additional settings accordion, verifyAdditonalSettingsAccordionProperties
138
+
139
+ //Placeholder test cases for Set correct answer section response field
140
+ it('When \'Placeholder text\' input field is empty then no \'Placeholder text\' should be displayed in the set correct answer response field', () => {
141
+ shortTextResponsePage.placeholderTextInputField()
142
+ .should('have.value', '');
143
+ shortTextResponsePage.setCorrectAnswerResponseField()
144
+ .should('have.attr', 'placeholder', '');
145
+ });
146
+
147
+ it('When the user adds a text in the Placeholder input field, the added placeholder should be displayed in the set correct answer response field', () => {
148
+ shortTextResponsePage.placeholderTextInputField()
149
+ .type('Lorem Ipsum')
150
+ .should('have.value', 'Lorem Ipsum');
151
+ shortTextResponsePage.setCorrectAnswerResponseField()
152
+ .should('have.attr', 'placeholder', 'Lorem Ipsum');
153
+ });
154
+
155
+ //Comment: not possible to check css of placeholder since it is added as an attribute, properties of placeholder is not visible in dev tools
156
+
157
+ it('Accessibility of \'Placeholder text\'', { tags: 'a11y' }, () => {
158
+ cy.checkAccessibility(shortTextResponsePage.setCorrectAnswerResponseField().parents('.short-text-response-input-field'));
159
+ });
160
+
161
+ it('When the user starts typing 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 response field', () => {
162
+ //TODO: Need to update script after https://redmine.zeuslearning.com/issues/527580 is resolved
163
+ shortTextResponsePage.setCorrectAnswerResponseField()
164
+ .type('Response')
165
+ .should('have.value', 'Response')
166
+ .should('not.have.attr', 'placeholder');
167
+ shortTextResponsePage.setCorrectAnswerResponseField()
168
+ .clear()
169
+ .blur();
170
+ shortTextResponsePage.setCorrectAnswerResponseField()
171
+ .should('have.attr', 'placeholder', 'Lorem Ipsum');
172
+ });
173
+
174
+ //Placeholder test cases for Preview tab response field
175
+ it('When \'Placeholder text\' input field is empty then no \'Placeholder text\' should be displayed in the preview tab response field', () => {
176
+ cy.log('Pre step: Clearing the placeholder text and switching to Preview tab')
177
+ shortTextResponsePage.placeholderTextInputField()
178
+ .clear()
179
+ .should('have.value', '');
180
+ shortTextResponsePage.steps.switchToPreviewTab();
181
+ shortTextResponsePage.previewTabResponseField()
182
+ .should('have.attr', 'placeholder', '');
183
+ });
184
+
185
+ it('When the user adds a text in the Placeholder input field, the added placeholder should be displayed in the preview tab response field', () => {
186
+ cy.log('Pre step: Switch to Edit tab')
187
+ shortTextResponsePage.steps.switchToEditTab();
188
+ shortTextResponsePage.placeholderTextInputField()
189
+ .type('Lorem Ipsum')
190
+ .should('have.value', 'Lorem Ipsum');
191
+ shortTextResponsePage.steps.switchToPreviewTab();
192
+ shortTextResponsePage.previewTabResponseField()
193
+ .should('have.attr', 'placeholder', 'Lorem Ipsum');
194
+ });
195
+
196
+ //Comment: not possible to check css of placeholder since it is added as an attribute, properties of placeholder is not visible in dev tools
197
+
198
+ it('Accessibility of \'Placeholder text\'', { tags: 'a11y' }, () => {
199
+ cy.checkAccessibility(shortTextResponsePage.previewTabResponseField().parents('.short-text-preview-response-input-field'))
200
+ });
201
+
202
+ it('When the user starts typing in the response field, then the placeholder text should disappear and on clearing the input field the placeholder text should re-appear for the preview tab response field', () => {
203
+ shortTextResponsePage.previewTabResponseField()
204
+ .type('Response')
205
+ .should('have.value', 'Response')
206
+ .should('not.have.attr', 'placeholder');
207
+ shortTextResponsePage.previewTabResponseField()
208
+ .clear()
209
+ .blur();
210
+ shortTextResponsePage.previewTabResponseField()
211
+ .should('have.attr', 'placeholder', 'Lorem Ipsum');
212
+ });
213
+ });
214
+
215
+ describe('Additional Settings: Type of answer input', () => {
216
+ const typeOfAnswers = ['Text', 'Number'];
217
+ abortEarlySetup();
218
+ before(() => {
219
+ shortTextResponsePage.steps.navigateToCreateQuestion('short text response');
220
+ shortTextResponsePage.steps.expandAdditonalSettings();
221
+ });
222
+
223
+ it('\'Type of answer\' label and dropdown should be displayed and in \'Type of answer\' dropdown \'Text\' option should be selected by default', () => {
224
+ shortTextResponsePage.typeOfAnswerInputLabel()
225
+ .verifyInnerText('Type of answer input');
226
+ shortTextResponsePage.typeOfAnswerInputDropdown()
227
+ .verifyInnerText('Text');
228
+ });
229
+
230
+ it('CSS of \'Type of answer\' dropdown', { tags: 'css' }, () => {
231
+ shortTextResponsePage.typeOfAnswerInputLabel()
232
+ .verifyCSS(css.color.labels, css.fontSize.normal, css.fontWeight.semibold);
233
+ shortTextResponsePage.typeOfAnswerInputDropdown()
234
+ .verifyCSS(css.color.liText, css.fontSize.default, css.fontWeight.regular);
235
+ });
236
+
237
+ //Note: a11y covered in Additional settings accordion, verifyAdditonalSettingsAccordionProperties
238
+
239
+ it(`Clicking on Type of answer dropdown should open a list of 2 options - ${typeOfAnswers}`, () => {
240
+ shortTextResponsePage.typeOfAnswerInputDropdown()
241
+ .click();
242
+ shortTextResponsePage.typeOfAnswerInputDropdownListOptions(0)
243
+ .should('be.visible');
244
+ typeOfAnswers.forEach((index, count) => {
245
+ shortTextResponsePage.typeOfAnswerInputDropdownListOptions(count)
246
+ .verifyInnerText(index);
247
+ });
248
+ });
249
+
250
+ it('CSS of Type of answer dropdown in Active state', { tags: 'css' }, () => {
251
+ shortTextResponsePage.typeOfAnswerInputDropdownListOptions(0)
252
+ .verifyCSS(css.color.liText, css.fontSize.default, css.fontWeight.regular)
253
+ .should('have.css', 'background-color', css.color.liTextSelectedBg);
254
+ shortTextResponsePage.typeOfAnswerInputDropdownListOptions(1)
255
+ .should('have.css', 'background-color', css.color.transparent);
256
+ });
257
+
258
+ it('Accessibility of Type of answer dropdown in active state', { tags: 'a11y' }, () => {
259
+ cy.checkAccessibility(commonComponents.dropdownList());
260
+ });
261
+
262
+ //Type of answer input test cases for set correct answer section response field
263
+ it('When \'Text\' option is set in the dropdown, then user should be able to add alpha-numeric characters in the Set correct answer section', () => {
264
+ shortTextResponsePage.typeOfAnswerInputDropdown()
265
+ .verifyInnerText('Text');
266
+ shortTextResponsePage.setCorrectAnswerResponseField()
267
+ .type('Response 1')
268
+ .should('have.value', 'Response 1');
269
+ });
270
+
271
+ it('When user selects \'Number\' option from the dropdown the the user should be able to add only numeric characters in the set correct answer response field', () => {
272
+ shortTextResponsePage.typeOfAnswerInputDropdown()
273
+ .click();
274
+ shortTextResponsePage.typeOfAnswerInputDropdownListOptions(1)
275
+ .click();
276
+ shortTextResponsePage.setCorrectAnswerResponseField()
277
+ .type('Response 1')
278
+ .should('have.value', 'ee 1');
279
+ });
280
+
281
+ //Type of answer input test cases for preview tab response field
282
+ it('When \'Text\' option is set in the dropdown, then user should be able to add alpha-numeric characters in preview tab response field', () => {
283
+ shortTextResponsePage.typeOfAnswerInputDropdown()
284
+ .click();
285
+ shortTextResponsePage.typeOfAnswerInputDropdownListOptions(0)
286
+ .click();
287
+ shortTextResponsePage.steps.switchToPreviewTab()
288
+ shortTextResponsePage.previewTabResponseField()
289
+ .type('Response 1')
290
+ .should('have.value', 'Response 1');
291
+ });
292
+
293
+ it('When user selects \'Number\' option from the dropdown then the user should be able to add only numeric characters in the preview tab input field', () => {
294
+ shortTextResponsePage.steps.switchToEditTab()
295
+ shortTextResponsePage.typeOfAnswerInputDropdown()
296
+ .click();
297
+ shortTextResponsePage.typeOfAnswerInputDropdownListOptions(1)
298
+ .click();
299
+ shortTextResponsePage.steps.switchToPreviewTab()
300
+ shortTextResponsePage.previewTabResponseField()
301
+ .type('Response 1')
302
+ .should('have.value', 'ee 1');
303
+ })
304
+ });
305
+
306
+ describe('Additional Settings: Set character limit', () => {
307
+ abortEarlySetup();
308
+ before(() => {
309
+ shortTextResponsePage.steps.navigateToCreateQuestion('short text response');
310
+ shortTextResponsePage.steps.expandAdditonalSettings();
311
+ });
312
+
313
+ it('\'Set character limit\' label and input field should be displayed and in \'Set character limit\' input field the default value should be \'50\'', () => {
314
+ shortTextResponsePage.setCharacterLimitLabel()
315
+ .verifyInnerText('Set character limit')
316
+ .should('be.visible');
317
+ shortTextResponsePage.setCharacterLimitInputField()
318
+ .should('have.value', '50')
319
+ .and('be.visible');
320
+ });
321
+
322
+ it('When user tries to remove the default set characters limit then it should set to the default value \'50\'', () => {
323
+ shortTextResponsePage.steps.switchToEditTab()
324
+ shortTextResponsePage.setCharacterLimitInputField()
325
+ .clear()
326
+ .blur();
327
+ shortTextResponsePage.setCorrectAnswerResponseField()
328
+ .type('euismod quis viverra nibh cras pulvinar mattiseuises')
329
+ .should('have.value', 'euismod quis viverra nibh cras pulvinar mattiseuis');
330
+ cy.log('Post step: Clearing the input field and setting value to 50')
331
+ shortTextResponsePage.setCorrectAnswerResponseField()
332
+ .clear();
333
+ shortTextResponsePage.setCharacterLimitInputField()
334
+ .type('50')
335
+ .should('have.value', '50');
336
+ });
337
+
338
+ //Set character limit test cases for set correct answer section response field
339
+ it('User should not be able to add characters more than the default Set character limit value in the Set correct answer response field', () => {
340
+ shortTextResponsePage.setCorrectAnswerResponseField()
341
+ .type('mi proin sed libero enim sed faucibus turpis in eum')
342
+ .should('have.value', 'mi proin sed libero enim sed faucibus turpis in eu');
343
+ });
344
+
345
+ it('User should be able to edit the \'Set character limit\' input field', () => {
346
+ shortTextResponsePage.steps.switchToEditTab()
347
+ shortTextResponsePage.setCharacterLimitInputField()
348
+ .clear()
349
+ .type('45')
350
+ .should('have.value', '45');
351
+ });
352
+
353
+ it('User should not be able to add characters more than the Set character limit value in the Set correct answer response field', () => {
354
+ shortTextResponsePage.setCorrectAnswerResponseField()
355
+ .clear()
356
+ .type('ut placerat orci nulla pellentesque dignissim e')
357
+ .should('have.value', 'ut placerat orci nulla pellentesque dignissim');
358
+ });
359
+
360
+ //Type of answer input test cases for preview tab response field
361
+ it('User should not be able to add characters more than the default Set character limit value in the preview tab response field', () => {
362
+ shortTextResponsePage.setCharacterLimitInputField()
363
+ .clear()
364
+ .type('20')
365
+ .should('have.value', '20');
366
+ shortTextResponsePage.steps.switchToPreviewTab()
367
+ shortTextResponsePage.previewTabResponseField()
368
+ .type('ut placerat orci nulla')
369
+ .should('have.value', 'ut placerat orci nul');
370
+ });
371
+
372
+ it('User should be able to edit the \'Set character limit\' input field', () => {
373
+ shortTextResponsePage.steps.switchToEditTab()
374
+ shortTextResponsePage.setCharacterLimitInputField()
375
+ .clear()
376
+ .type('45')
377
+ .should('have.value', '45');
378
+ });
379
+
380
+ it('User should not be able to add characters more than the Set character limit value in the preview tab response field', () => {
381
+ shortTextResponsePage.steps.switchToPreviewTab()
382
+ shortTextResponsePage.previewTabResponseField()
383
+ .type('ut placerat orci nulla pellentesque dignissim e')
384
+ .should('have.value', 'ut placerat orci nulla pellentesque dignissim');
385
+ });
386
+ });
387
+
388
+ describe('Additional Settings: Spell check section', () => {
389
+ abortEarlySetup();
390
+ before(() => {
391
+ shortTextResponsePage.steps.navigateToCreateQuestion('short text response');
392
+ shortTextResponsePage.steps.expandAdditonalSettings();
393
+ });
394
+
395
+ it('\'Spell check\' functionality label and checkbox should be displayed and by default it should be unchecked', () => {
396
+ shortTextResponsePage.spellCheckLabel()
397
+ .verifyInnerText('Spell check');
398
+ shortTextResponsePage.spellCheckCheckbox()
399
+ .should('not.be.checked');
400
+ });
401
+
402
+ it('CSS of \'Spell check\' section - unchecked state', { tags: 'css' }, () => {
403
+ shortTextResponsePage.spellCheckCheckbox()
404
+ .parent()
405
+ .find('svg')
406
+ .should('have.css', 'fill', css.color.uncheckedCheckbox);
407
+ });
408
+
409
+ //Note: a11y covered in Additional settings accordion, verifyAdditonalSettingsAccordionProperties
410
+
411
+ //Spell check test cases for set correct answer section response field
412
+ it('When the \'Spell check\' functionality is disabled, the response field should have \'spellcheck\' attribute set as \'false\' in set correct answer section', () => {
413
+ shortTextResponsePage.setCorrectAnswerResponseFieldWrapper()
414
+ .should('have.attr', 'spellcheck', 'false');
415
+ });
416
+
417
+ it('When the \'Spell check\' functionality is enabled, the response field should have \'spellcheck\' attribute set as \'true\' in set correct answer section', () => {
418
+ shortTextResponsePage.spellCheckCheckbox()
419
+ .click()
420
+ .should('be.checked');
421
+ shortTextResponsePage.setCorrectAnswerResponseFieldWrapper()
422
+ .should('have.attr', 'spellcheck', 'true');
423
+ });
424
+
425
+ it('CSS of \'Spell check\' section - checked state', { tags: 'css' }, () => {
426
+ shortTextResponsePage.spellCheckLabel()
427
+ .verifyCSS(css.color.labelText, css.fontSize.normal, css.fontWeight.regular);
428
+ shortTextResponsePage.spellCheckCheckbox()
429
+ .parent('.icon-checkbox-selected')
430
+ .find('.checkbox-icon-border-rect')
431
+ .should('have.css', 'fill', css.color.activeButtons);
432
+ });
433
+
434
+ it('Accessibility of \'Spell check\' section - checked state', { tags: 'a11y' }, () => {
435
+ cy.checkAccessibility(shortTextResponsePage.spellCheckLabel().parents('.spell-check-checkbox-wrapper'))
436
+ });
437
+
438
+ //Spell check test cases for preview tab response field
439
+ it('When the \'Spell check\' functionality is disabled, the response field should have \'spellcheck\' attribute set as \'false\' in preview tab', () => {
440
+ shortTextResponsePage.spellCheckCheckbox()
441
+ .click()
442
+ .should('not.be.checked');
443
+ shortTextResponsePage.steps.switchToPreviewTab();
444
+ shortTextResponsePage.previewTabResponseFieldWrapper()
445
+ .should('have.attr', 'spellcheck', 'false');
446
+ });
447
+
448
+ it('When the \'Spell check\' functionality is enabled, the response field should have \'spellcheck\' attribute set as \'true\' in the preview tab', () => {
449
+ cy.log('Pre step: Switching to Edit tab')
450
+ shortTextResponsePage.steps.switchToEditTab();
451
+ shortTextResponsePage.spellCheckCheckbox()
452
+ .click()
453
+ .should('be.checked');
454
+ shortTextResponsePage.steps.switchToPreviewTab();
455
+ shortTextResponsePage.previewTabResponseFieldWrapper()
456
+ .should('have.attr', 'spellcheck', 'true');
457
+ });
458
+ });
459
+
460
+ describe('Additional Settings: Custom special characters section', () => {
461
+ abortEarlySetup();
462
+ before(() => {
463
+ shortTextResponsePage.steps.navigateToCreateQuestion('short text response');
464
+ shortTextResponsePage.steps.expandAdditonalSettings();
465
+ });
466
+
467
+ shortTextResponsePage.tests.verifyAdditionalSettingsCustomSpecialCharactersSection();
468
+
469
+ it('When the user checks the \'Display special characters\' checkbox then the \'Special characters\' button should be displayed when user focuses in the response field in set correct answer section ', () => {
470
+ cy.log('Checking Custom characters button is not visible before focusing any option')
471
+ shortTextResponsePage.setCorrectAnsResponseFieldSpecialCharactersButton()
472
+ .should('not.have.class', 'active-special-character-button')
473
+ .should('not.be.visible');
474
+ shortTextResponsePage.setCorrectAnswerResponseField()
475
+ .click();
476
+ shortTextResponsePage.setCorrectAnsResponseFieldSpecialCharactersButton()
477
+ .should('have.class', 'active-special-character-button')
478
+ .should('be.visible');
479
+ });
480
+
481
+ it('When the user has added no input to the \'Custom special characters\' input field then the default Special characters flyout should be displayed on clicking the \'Special characters\' button in the response field', () => {
482
+ shortTextResponsePage.setCorrectAnsResponseFieldSpecialCharactersButton()
483
+ .should('be.visible')
484
+ .click();
485
+ shortTextResponsePage.steps.verifySpecialCharactersFlyoutHeaderContents();
486
+ });
487
+
488
+ shortTextResponsePage.tests.verifySpecialCharactersFlyoutSymbols()
489
+
490
+ it(`When user clicks on a symbol in the ${specialOrMathCharacters['specialCharacters'].popupTitle} popup, then that symbol should be inserted in the response field`, () => {
491
+ cy.log('Clicking on all symbols.');
492
+ let symbolsString = specialOrMathCharacters['specialCharacters'].characters.map((icon) => icon.symbol);
493
+ symbolsString = symbolsString.join('');
494
+ shortTextResponsePage.steps.clickingOnSpecialCharactersSymbolsFromFlyout();
495
+ dialogBoxBase.steps.closeWarningPopup();
496
+ shortTextResponsePage.setCorrectAnswerResponseField()
497
+ .should('have.value', symbolsString);
498
+ cy.log('Post step: Clearing the set correct answer input field')
499
+ shortTextResponsePage.setCorrectAnswerResponseField()
500
+ .clear();
501
+ });
502
+
503
+ it('When the \'Display special characters\' checkbox is checked then user should be able to enter value in the \'Custom special characters\' input field', () => {
504
+ shortTextResponsePage.customSpecialCharactersInputField()
505
+ .type(':)`')
506
+ .should('have.value', ':)`');
507
+ });
508
+
509
+ it('When the user clicks on the \'Special characters\' button in the response field then a flyout with the title \'Special characters\' and close button should be displayed', () => {
510
+ shortTextResponsePage.setCorrectAnswerResponseField()
511
+ .click();
512
+ shortTextResponsePage.setCorrectAnsResponseFieldSpecialCharactersButton()
513
+ .should('be.visible')
514
+ .click();
515
+ shortTextResponsePage.steps.verifySpecialCharactersFlyoutHeaderContents();
516
+ });
517
+
518
+ it('The flyout should contain all the added Special characters entered in the \'Custom special characters\' input field', () => {
519
+ shortTextResponsePage.specialCharactersFlyoutIcon()
520
+ .each(($el, index) => {
521
+ cy.wrap($el)
522
+ .should('have.text', `${customSpecialCharacters[index]}`)
523
+ });
524
+ });
525
+
526
+ it('When user clicks on the characters then they should be added to the set correct answer response field', () => {
527
+ shortTextResponsePage.steps.clickingOnSpecialCharactersSymbolsFromFlyout();
528
+ dialogBoxBase.steps.closeWarningPopup();
529
+ shortTextResponsePage.setCorrectAnswerResponseField()
530
+ .should('have.value', ':)`');
531
+ });
532
+
533
+ //Special custom characters test cases for preview tab response field
534
+ it('When the \'Custom special characters\' functionality is disabled then the \'Special characters\' button should not be displayed in the preview tab response field', () => {
535
+ shortTextResponsePage.customSpecialCharactersInputField()
536
+ .clear();
537
+ shortTextResponsePage.displaySpecialCharactersCheckbox()
538
+ .click()
539
+ .should('not.be.checked');
540
+ shortTextResponsePage.steps.switchToPreviewTab();
541
+ shortTextResponsePage.previewTabResponseFieldSpecialCharactersButton()
542
+ .should('not.exist');
543
+ });
544
+
545
+ it('When the user has enabled the \'Custom special characters\' functionality then the \'Special characters\' button should be displayed when user focuses in any response field in the preview tab', () => {
546
+ cy.log('Pre step: Enable the Custom special characters')
547
+ shortTextResponsePage.steps.switchToEditTab();
548
+ shortTextResponsePage.displaySpecialCharactersCheckbox()
549
+ .click()
550
+ .should('be.checked');
551
+ shortTextResponsePage.steps.switchToPreviewTab();
552
+ shortTextResponsePage.previewTabResponseFieldSpecialCharactersButton()
553
+ .should('not.have.class', 'active-special-character-button')
554
+ .and('not.be.visible');
555
+ shortTextResponsePage.previewTabResponseField()
556
+ .click();
557
+ shortTextResponsePage.previewTabResponseFieldSpecialCharactersButton()
558
+ .should('have.class', 'active-special-character-button')
559
+ .and('be.visible');
560
+ });
561
+
562
+ it('When the user has added no input to the \'Custom special characters\' input field then the default Special characters flyout should be displayed on clicking the \'Special characters\' button in the response field', () => {
563
+ shortTextResponsePage.previewTabResponseFieldSpecialCharactersButton()
564
+ .should('be.visible')
565
+ .click();
566
+ shortTextResponsePage.steps.verifySpecialCharactersFlyoutHeaderContents();
567
+ });
568
+
569
+ shortTextResponsePage.tests.verifySpecialCharactersFlyoutSymbols()
570
+
571
+ it(`When user clicks on a symbol in the ${specialOrMathCharacters['specialCharacters'].popupTitle} popup, then that symbol should be inserted in the response field`, () => {
572
+ cy.log('Clicking on all symbols.');
573
+ let symbolsString = specialOrMathCharacters['specialCharacters'].characters.map((icon) => icon.symbol);
574
+ symbolsString = symbolsString.join('');
575
+ shortTextResponsePage.steps.clickingOnSpecialCharactersSymbolsFromFlyout();
576
+ dialogBoxBase.steps.closeWarningPopup();
577
+ shortTextResponsePage.previewTabResponseField()
578
+ .should('have.value', symbolsString);
579
+ });
580
+
581
+ it('When the \'Display special characters\' checkbox is checked then user should be able to enter value in the \'Custom special characters\' input field', () => {
582
+ cy.log('Pre step: Swicth to Edit tab')
583
+ shortTextResponsePage.steps.switchToEditTab()
584
+ shortTextResponsePage.customSpecialCharactersInputField()
585
+ .type(':)`')
586
+ .should('have.value', ':)`');
587
+ cy.log('Post step: Switch to Preview tab')
588
+ shortTextResponsePage.steps.switchToPreviewTab()
589
+ });
590
+
591
+ it('When the user clicks on the \'Special characters\' button then a flyout with the title \'Special characters\' and close button should be displayed in the preview tab', () => {
592
+ shortTextResponsePage.previewTabResponseField()
593
+ .click();
594
+ shortTextResponsePage.previewTabResponseFieldSpecialCharactersButton()
595
+ .should('be.visible')
596
+ .click();
597
+ shortTextResponsePage.steps.verifySpecialCharactersFlyoutHeaderContents();
598
+ });
599
+
600
+ it('The flyout should contain all the added Special characters entered in the \'Custom special characters\' input field', () => {
601
+ shortTextResponsePage.specialCharactersFlyoutIcon()
602
+ .each(($el, index) => {
603
+ cy.wrap($el)
604
+ .should('have.text', `${customSpecialCharacters[index]}`)
605
+ });
606
+ });
607
+
608
+ it('When user clicks on the characters then they should be added to the preview tab input field', () => {
609
+ shortTextResponsePage.steps.clickingOnSpecialCharactersSymbolsFromFlyout();
610
+ dialogBoxBase.steps.closeWarningPopup();
611
+ shortTextResponsePage.previewTabResponseField()
612
+ .should('have.value', ':)`');
613
+ });
614
+ });
615
+
616
+ describe('Additional Settings: Font Size dropdown', () => {
617
+ abortEarlySetup();
618
+ before(() => {
619
+ cy.log('Navigating to multiple selection quetion type, adding question instructions and options, alloting points and expanding additional settings accordion')
620
+ shortTextResponsePage.steps.navigateToCreateQuestion('short text response');
621
+ shortTextResponsePage.questionInstructionsInputField()
622
+ .type('Question Instructions');
623
+ shortTextResponsePage.pointsInputField()
624
+ .type('4');
625
+ shortTextResponsePage.setCorrectAnswerResponseField()
626
+ .type('Answer input');
627
+ shortTextResponsePage.steps.expandAdditonalSettings();
628
+ });
629
+
630
+ shortTextResponsePage.tests.verifyFontSizeSectionContents();
631
+
632
+ //Failing due to https://redmine.zeuslearning.com/issues/526873
633
+ const fontsizes = ['Default', 'Small', 'Normal', 'Large', 'Extra large', 'Huge'];
634
+ const font = ['16px', '12px', '14px', '17px', '20px', '24px'];
635
+ fontsizes.forEach((option, count) => {
636
+ it(`When the user selects \'${option}\' option from the Font Size dropdown, then font size of the preview tab contents should be changed to ${option} in the \'Set Correct Answer\' section as well as in the \'Preview\' tab`, () => {
637
+ shortTextResponsePage.fontSizeDropdown()
638
+ .click();
639
+ shortTextResponsePage.fontSizeListOptions(count)
640
+ .click();
641
+ shortTextResponsePage.fontSizeDropdown()
642
+ .verifyInnerText(`${option}`);
643
+ cy.log('Checking correct answer section font size')
644
+ shortTextResponsePage.setCorrectAnswerResponseField()
645
+ .should('have.css', 'font-size', font[count]);
646
+ cy.log('Switching to Preview tab')
647
+ shortTextResponsePage.steps.switchToPreviewTab();
648
+ cy.log('Checking Preview section font size')
649
+ shortTextResponsePage.questionInstructionsText()
650
+ .should('have.css', 'font-size', font[count]);
651
+ shortTextResponsePage.previewTabResponseField()
652
+ .should('have.css', 'font-size', font[count]);
653
+ shortTextResponsePage.steps.switchToEditTab();
654
+ });
655
+ });
656
+ });
657
+
658
+ describe('Additional Settings: Check Answer', () => {
659
+ abortEarlySetup();
660
+ before(() => {
661
+ shortTextResponsePage.steps.navigateToCreateQuestion('short text response');
662
+ shortTextResponsePage.questionInstructionsInputField()
663
+ .type('Question Instructions');
664
+ shortTextResponsePage.pointsInputField()
665
+ .type('4');
666
+ shortTextResponsePage.setCorrectAnswerResponseField()
667
+ .type('Answer input');
668
+ shortTextResponsePage.steps.expandAdditonalSettings();
669
+ });
670
+
671
+ shortTextResponsePage.tests.verifyCheckAnswerSectionAndPreviewTabCheckAnswerButton();
672
+ });
673
+
674
+ describe('Additional Settings: Check Answer - Functionality', () => {
675
+ abortEarlySetup();
676
+ before(() => {
677
+ shortTextResponsePage.steps.navigateToCreateQuestion('short text response');
678
+ shortTextResponsePage.questionInstructionsInputField()
679
+ .type('Question Instructions');
680
+ shortTextResponsePage.pointsInputField()
681
+ .type('4');
682
+ shortTextResponsePage.setCorrectAnswerResponseField()
683
+ .type('Response')
684
+ .should('have.value', 'Response');
685
+ shortTextResponsePage.steps.expandAdditonalSettings();
686
+ shortTextResponsePage.steps.setMaximumCheckAnswerAttempts(2);
687
+ shortTextResponsePage.steps.switchToPreviewTab();
688
+ });
689
+
690
+ it('When the user has not set any response then on clicking on the Check Answer button, icons should not be displayed beside both empty response, Correct/Incorrect label or border should not be displayed and \'Correct answer\' container should not be displayed below the question', () => {
691
+ shortTextResponsePage.previewTabResponseField()
692
+ .should('have.value', '');
693
+ shortTextResponsePage.checkAnswerButton()
694
+ .click();
695
+ shortTextResponsePage.correctIcon()
696
+ .should('not.exist');
697
+ shortTextResponsePage.incorrectIcon()
698
+ .should('not.exist');
699
+ shortTextResponsePage.correctIncorectAnswerLabel()
700
+ .should('not.exist');
701
+ shortTextResponsePage.correctIncorrectAnswerBorder()
702
+ .should('not.exist');
703
+ shortTextResponsePage.previewTabCorrectAnswerContainer()
704
+ .should('not.exist');
705
+ });
706
+
707
+ it('When the user has added correct response then on clicking on the Check Answer button, green checkmark icon should be displayed, Correct/Incorrect label or border should not be displayed and \'Correct answer\' container should not be displayed below the question', () => {
708
+ shortTextResponsePage.previewTabResponseField()
709
+ .clear()
710
+ .type('Response')
711
+ .should('have.value', 'Response');
712
+ shortTextResponsePage.checkAnswerButton()
713
+ .click();
714
+ shortTextResponsePage.steps.verifyCorrectOptionCheckmarkIcon()
715
+ shortTextResponsePage.correctIncorectAnswerLabel()
716
+ .should('not.exist');
717
+ shortTextResponsePage.correctIncorrectAnswerBorder()
718
+ .should('not.exist');
719
+ shortTextResponsePage.previewTabCorrectAnswerContainer()
720
+ .should('not.exist');
721
+ });
722
+
723
+ it('When the user has added incorrect response then on clicking on the Check Answer button, red crossmark icon should be displayed, Incorrect label or border should not be displayed and \'Correct answer\' container should not be displayed below the question', () => {
724
+ shortTextResponsePage.previewTabResponseField()
725
+ .clear()
726
+ .type('Incorrect Response')
727
+ .should('have.value', 'Incorrect Response');
728
+ shortTextResponsePage.checkAnswerButton()
729
+ .click();
730
+ shortTextResponsePage.steps.verifyIncorrectOptionCrossmarkIcon()
731
+ shortTextResponsePage.correctIncorectAnswerLabel()
732
+ .should('not.exist');
733
+ shortTextResponsePage.correctIncorrectAnswerBorder()
734
+ .should('not.exist');
735
+ shortTextResponsePage.previewTabCorrectAnswerContainer()
736
+ .should('not.exist');
737
+ });
738
+
739
+ it('The \'Check Answer\' button should become disabled once user has reached maximum check answer attempts', () => {
740
+ shortTextResponsePage.checkAnswerButton()
741
+ .should('be.disabled');
742
+ });
743
+
744
+ it('CSS of disabled \'Check Answer\' button', { tags: 'css' }, () => {
745
+ shortTextResponsePage.checkAnswerButton()
746
+ .verifyCSS(css.color.primaryBtnDisabled, css.fontSize.default, css.fontWeight.regular);
747
+ });
748
+
749
+ it('Accessibility of disabled Check Answer button', { tags: 'a11y' }, () => {
750
+ cy.checkAccessibility(shortTextResponsePage.checkAnswerButton());
751
+ });
752
+
753
+ it('When the user updates the value of Maximum check answer attempts input field, it should get reflected on the Preview tab', () => {
754
+ cy.log('Pre step: Switching to Edit tab')
755
+ shortTextResponsePage.steps.switchToEditTab();
756
+ shortTextResponsePage.maximumCheckAnswerAttemptsInputField()
757
+ .clear()
758
+ .type(1)
759
+ .should('have.value', '1');
760
+ cy.log('Switching to Preview tab');
761
+ shortTextResponsePage.steps.switchToPreviewTab();
762
+ shortTextResponsePage.checkAnswerButton()
763
+ .should('be.enabled');
764
+ shortTextResponsePage.previewTabResponseField()
765
+ .type('Response');
766
+ shortTextResponsePage.checkAnswerButton()
767
+ .click()
768
+ .should('be.disabled');
769
+ });
770
+
771
+ it('When the \'Maximum check answer attempts\' input field has value \'0\' and user switches to Preview tab, then the \'Check Answer\' button should be enabled and user should be able to check answer multiple times', () => {
772
+ shortTextResponsePage.steps.switchToEditTab();
773
+ shortTextResponsePage.steps.clearMaximumCheckAnswerAttemptsInputField();
774
+ shortTextResponsePage.steps.addInputToMaximumCheckAnswerAttemptsInputField(0);
775
+ cy.log('Switching to Preview tab');
776
+ shortTextResponsePage.steps.switchToPreviewTab();
777
+ shortTextResponsePage.checkAnswerButton()
778
+ .should('be.enabled');
779
+ shortTextResponsePage.previewTabResponseField()
780
+ .type('Incorrect Response');
781
+ cy.log('Clicking on \'Check Answer\' to check state of \'Check Answer\' to be enabled')
782
+ shortTextResponsePage.checkAnswerButton()
783
+ .click();
784
+ shortTextResponsePage.checkAnswerButton()
785
+ .should('be.enabled');
786
+ shortTextResponsePage.steps.verifyIncorrectOptionCrossmarkIcon();
787
+ shortTextResponsePage.correctIncorectAnswerLabel()
788
+ .should('not.exist');
789
+ shortTextResponsePage.correctIncorrectAnswerBorder()
790
+ .should('not.exist');
791
+ shortTextResponsePage.previewTabCorrectAnswerContainer()
792
+ .should('not.exist');
793
+ cy.log('As the user is able to check answer multiple times, verifying state of \'Check Answer\' to be enabled by adding different response and checking answer again')
794
+ shortTextResponsePage.previewTabResponseField()
795
+ .clear()
796
+ .type('Response');
797
+ shortTextResponsePage.checkAnswerButton()
798
+ .click();
799
+ shortTextResponsePage.steps.verifyCorrectOptionCheckmarkIcon();
800
+ shortTextResponsePage.correctIncorectAnswerLabel()
801
+ .should('not.exist');
802
+ shortTextResponsePage.correctIncorrectAnswerBorder()
803
+ .should('not.exist');
804
+ shortTextResponsePage.previewTabCorrectAnswerContainer()
805
+ .should('not.exist');
806
+ shortTextResponsePage.checkAnswerButton()
807
+ .should('be.enabled');
808
+ });
809
+
810
+ it('When the \'Maximum check answer attempts\' input field is empty and user switches to Preview tab, then the \'Check Answer\' button should be enabled and user should be able to check answer multiple times', () => {
811
+ cy.log('Pre step: Switching to Edit tab')
812
+ shortTextResponsePage.steps.switchToEditTab();
813
+ shortTextResponsePage.maximumCheckAnswerAttemptsInputField()
814
+ .clear()
815
+ .should('have.value', '');
816
+ cy.log('Switching to Preview tab');
817
+ shortTextResponsePage.steps.switchToPreviewTab();
818
+ shortTextResponsePage.checkAnswerButton()
819
+ .should('be.enabled');
820
+ shortTextResponsePage.previewTabResponseField()
821
+ .type('Incorrect Response');
822
+ cy.log('Clicking on \'Check Answer\' to check state of \'Check Answer\' to be enabled')
823
+ shortTextResponsePage.checkAnswerButton()
824
+ .click();
825
+ shortTextResponsePage.checkAnswerButton()
826
+ .should('be.enabled');
827
+ shortTextResponsePage.steps.verifyIncorrectOptionCrossmarkIcon();
828
+ shortTextResponsePage.correctIncorectAnswerLabel()
829
+ .should('not.exist');
830
+ shortTextResponsePage.correctIncorrectAnswerBorder()
831
+ .should('not.exist');
832
+ shortTextResponsePage.previewTabCorrectAnswerContainer()
833
+ .should('not.exist');
834
+ cy.log('As the user is able to check answer multiple times, verifying state of \'Check Answer\' to be enabled by adding different response and checking answer again')
835
+ shortTextResponsePage.previewTabResponseField()
836
+ .clear()
837
+ .type('Response');
838
+ shortTextResponsePage.checkAnswerButton()
839
+ .click();
840
+ shortTextResponsePage.steps.verifyCorrectOptionCheckmarkIcon();
841
+ shortTextResponsePage.correctIncorectAnswerLabel()
842
+ .should('not.exist');
843
+ shortTextResponsePage.correctIncorrectAnswerBorder()
844
+ .should('not.exist');
845
+ shortTextResponsePage.previewTabCorrectAnswerContainer()
846
+ .should('not.exist');
847
+ shortTextResponsePage.checkAnswerButton()
848
+ .should('be.enabled');
849
+ });
850
+ });
851
+
852
+ describe('Additional Settings: Details section', () => {
853
+ abortEarlySetup();
854
+ before(() => {
855
+ shortTextResponsePage.steps.navigateToCreateQuestion('short text response');
856
+ shortTextResponsePage.steps.expandAdditonalSettings();
857
+ });
858
+
859
+ shortTextResponsePage.tests.verifyDetailsSection();
860
+ });
861
+ });