itemengine-cypress-automation 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. package/.build_wna +4 -0
  2. package/README.md +3 -0
  3. package/currents.config.js +6 -0
  4. package/cypress/API/createItem/toggleItemMode.js +15 -0
  5. package/cypress/config-files/ildev.json +15 -0
  6. package/cypress/config-files/ilprod.json +15 -0
  7. package/cypress/config-files/ilqa.json +15 -0
  8. package/cypress/config-files/ilstage.json +15 -0
  9. package/cypress/e2e/ILC/sorry-cypress-test/spec1.js +18 -0
  10. package/cypress/e2e/ILC/sorry-cypress-test/spec2.js +18 -0
  11. package/cypress/e2e/ILC/sorry-cypress-test/spec3.js +18 -0
  12. package/cypress/fixtures/accessibilityConfig.json +6 -0
  13. package/cypress/fixtures/constants.js +18 -0
  14. package/cypress/fixtures/equationEditorCategoriesAndSymbols .js +2271 -0
  15. package/cypress/fixtures/specialAndMathCharacters.js +118 -0
  16. package/cypress/fixtures/theme/ilc.json +150 -0
  17. package/cypress/fixtures/theme/ngie.json +26 -0
  18. package/cypress/fixtures/uploads/20mbFile.png +0 -0
  19. package/cypress/fixtures/uploads/80mbFile.pdf +0 -0
  20. package/cypress/fixtures/uploads/highlightImage.jpg +0 -0
  21. package/cypress/fixtures/uploads/image.png +0 -0
  22. package/cypress/fixtures/uploads/sample.aac +0 -0
  23. package/cypress/fixtures/uploads/sample.accdb +0 -0
  24. package/cypress/fixtures/uploads/sample.csv +100 -0
  25. package/cypress/fixtures/uploads/sample.doc +0 -0
  26. package/cypress/fixtures/uploads/sample.gif +0 -0
  27. package/cypress/fixtures/uploads/sample.heic +0 -0
  28. package/cypress/fixtures/uploads/sample.heif +0 -0
  29. package/cypress/fixtures/uploads/sample.hevc +0 -0
  30. package/cypress/fixtures/uploads/sample.jpeg +0 -0
  31. package/cypress/fixtures/uploads/sample.jpg +0 -0
  32. package/cypress/fixtures/uploads/sample.mp3 +0 -0
  33. package/cypress/fixtures/uploads/sample.mp4 +0 -0
  34. package/cypress/fixtures/uploads/sample.pdf +0 -0
  35. package/cypress/fixtures/uploads/sample.ppt +0 -0
  36. package/cypress/fixtures/uploads/sample.pub +0 -0
  37. package/cypress/fixtures/uploads/sample.rtf +7902 -0
  38. package/cypress/fixtures/uploads/sample.svg +10 -0
  39. package/cypress/fixtures/uploads/sample.txt +1 -0
  40. package/cypress/fixtures/uploads/sample.wav +0 -0
  41. package/cypress/fixtures/uploads/sample.xlsx +0 -0
  42. package/cypress/fixtures/uploads/sample.xps +0 -0
  43. package/cypress/fixtures/uploads/sample.zip +0 -0
  44. package/cypress/fixtures/uploads/sample1.jpg +0 -0
  45. package/cypress/fixtures/uploads/sample1.mp3 +0 -0
  46. package/cypress/fixtures/uploads/sample1.zip +0 -0
  47. package/cypress/fixtures/uploads/sample10Sec.mp3 +0 -0
  48. package/cypress/fixtures/uploads/sample2.jpg +0 -0
  49. package/cypress/fixtures/uploads/sample2.mp3 +0 -0
  50. package/cypress/fixtures/uploads/sampleVirus.zip +0 -0
  51. package/cypress/pages/audioPlayerPage.js +628 -0
  52. package/cypress/pages/audioResponsePage.js +264 -0
  53. package/cypress/pages/components/additionalSettingsPanel.js +174 -0
  54. package/cypress/pages/components/answerNumerationComponent.js +109 -0
  55. package/cypress/pages/components/autoScoredAdditionalSettings.js +183 -0
  56. package/cypress/pages/components/autoScoredPreviewBase.js +94 -0
  57. package/cypress/pages/components/autoScoredScoringSection.js +195 -0
  58. package/cypress/pages/components/autoScoredScoringSectionMultipleResponsesType.js +268 -0
  59. package/cypress/pages/components/autoScoredSetCorrectAnswerSection.js +291 -0
  60. package/cypress/pages/components/ckEditorToolbar.js +64 -0
  61. package/cypress/pages/components/colorPopupComponent.js +293 -0
  62. package/cypress/pages/components/commonComponents.js +93 -0
  63. package/cypress/pages/components/componentsFlowChart/figFlowChart.png +0 -0
  64. package/cypress/pages/components/createCustomCategoryFlyout.js +138 -0
  65. package/cypress/pages/components/createQuestionBasePage.js +225 -0
  66. package/cypress/pages/components/customizeHighlightPropertiesComponent.js +318 -0
  67. package/cypress/pages/components/dragAndDropResponseOptions.js +738 -0
  68. package/cypress/pages/components/dragAndDropSetCorrectAnswerCheckboxComponents.js +124 -0
  69. package/cypress/pages/components/draggableOptionsContainer.js +857 -0
  70. package/cypress/pages/components/editCategoryFlyout.js +40 -0
  71. package/cypress/pages/components/equationEditorFlyout.js +158 -0
  72. package/cypress/pages/components/essayResponseCommonComponents.js +86 -0
  73. package/cypress/pages/components/figOverImageCommonComponent.js +924 -0
  74. package/cypress/pages/components/fillInTheGapsCommonComponents.js +687 -0
  75. package/cypress/pages/components/fillInTheGapsDropdownCommonComponent.js +442 -0
  76. package/cypress/pages/components/fillInTheGapsTextCommonComponent.js +884 -0
  77. package/cypress/pages/components/gridCommonComponents.js +951 -0
  78. package/cypress/pages/components/index.js +38 -0
  79. package/cypress/pages/components/listSortingAndOrderingBase.js +401 -0
  80. package/cypress/pages/components/maximumRecorderLengthComponent.js +116 -0
  81. package/cypress/pages/components/mcqAdditionalSettingsBase.js +390 -0
  82. package/cypress/pages/components/mcqOptionsComponent.js +263 -0
  83. package/cypress/pages/components/mcqPreviewComponents.js +78 -0
  84. package/cypress/pages/components/mcqQuestionCommonComponents.js +265 -0
  85. package/cypress/pages/components/mcqScoringComponent.js +120 -0
  86. package/cypress/pages/components/mcqSetCorrectAnswerSection.js +143 -0
  87. package/cypress/pages/components/optionsWrapperComponent.js +221 -0
  88. package/cypress/pages/components/playbackControlsBaseComponent.js +163 -0
  89. package/cypress/pages/components/previewScoringAndShowCorrectAnswerComponent.js +90 -0
  90. package/cypress/pages/components/questionInstructionsComponent.js +112 -0
  91. package/cypress/pages/components/scoringSectionBase.js +308 -0
  92. package/cypress/pages/components/setPointsPopupBase.js +79 -0
  93. package/cypress/pages/components/specialAndCustomSpecialCharactersComponent.js +79 -0
  94. package/cypress/pages/components/specialCharactersFlyoutComponent.js +58 -0
  95. package/cypress/pages/components/studentResponseAreaAndLayoutComponent.js +28 -0
  96. package/cypress/pages/components/uploadImageSectionComponent.js +594 -0
  97. package/cypress/pages/createItemPage.js +28 -0
  98. package/cypress/pages/dialogBoxBase.js +111 -0
  99. package/cypress/pages/dragAndDropIntoCategoriesAllOrNothingScoring.js +1161 -0
  100. package/cypress/pages/dragAndDropIntoCategoriesCellsScoring.js +1559 -0
  101. package/cypress/pages/dragAndDropIntoCategoriesPage.js +1556 -0
  102. package/cypress/pages/dragAndDropIntoCategoriesResponseScoring.js +1396 -0
  103. package/cypress/pages/essayResponseBasicPage.js +57 -0
  104. package/cypress/pages/essayResponseMathPage.js +47 -0
  105. package/cypress/pages/essayResponsePage.js +385 -0
  106. package/cypress/pages/feedbackScalePage.js +698 -0
  107. package/cypress/pages/fillInTheGapsDragAndDropPage.js +742 -0
  108. package/cypress/pages/fillInTheGapsDropdownPage.js +99 -0
  109. package/cypress/pages/fillInTheGapsOverImageDropdownPage.js +232 -0
  110. package/cypress/pages/fillInTheGapsOverImageTextPage.js +135 -0
  111. package/cypress/pages/fillInTheGapsScoring.js +5974 -0
  112. package/cypress/pages/fillInTheGapsSetCorrectAnswerSection.js +260 -0
  113. package/cypress/pages/fillInTheGapsTextPage.js +225 -0
  114. package/cypress/pages/highlightImagePage.js +1316 -0
  115. package/cypress/pages/highlightPage.js +870 -0
  116. package/cypress/pages/index.js +30 -0
  117. package/cypress/pages/listMatchingPage.js +1330 -0
  118. package/cypress/pages/listMatchingScoring.js +2635 -0
  119. package/cypress/pages/listOrderingPage.js +751 -0
  120. package/cypress/pages/listSortingPage.js +1201 -0
  121. package/cypress/pages/multipleSelectionGridPage.js +359 -0
  122. package/cypress/pages/multipleSelectionPage.js +88 -0
  123. package/cypress/pages/passagePage.js +426 -0
  124. package/cypress/pages/readingRulerPage.js +302 -0
  125. package/cypress/pages/selectQuestionResourceToolPage.js +64 -0
  126. package/cypress/pages/shortTextResponsePage.js +197 -0
  127. package/cypress/pages/singleSelectionGridPage.js +370 -0
  128. package/cypress/pages/singleSelectionPage.js +65 -0
  129. package/cypress/pages/uploadResponsePage.js +110 -0
  130. package/cypress/pages/videoResponsePage.js +375 -0
  131. package/cypress/support/commands.js +140 -0
  132. package/cypress/support/e2e.js +14 -0
  133. package/cypress/support/helpers/abortEarly.js +19 -0
  134. package/cypress/support/helpers/accessibility.js +34 -0
  135. package/cypress/support/helpers/cypressUtilities.js +64 -0
  136. package/cypress/support/helpers/localStorage.js +13 -0
  137. package/cypress/support/helpers/selectText.js +77 -0
  138. package/cypress/support/helpers/utilities.js +126 -0
  139. package/cypress.config.js +76 -0
  140. package/il.yaml +14 -0
  141. package/language +1 -0
  142. package/package.json +26 -0
@@ -0,0 +1,751 @@
1
+ import constants from "../fixtures/constants";
2
+ import utilities from "../support/helpers/utilities";
3
+ import { additionalSettingsPanel, autoScoredAdditionalSettings, autoScoredPreviewBase, autoScoredScoringSection, autoScoredScoringSectionMultipleResponsesType, autoScoredSetCorrectAnswerSection, ckEditorToolbar, commonComponents, createQuestionBasePage, equationEditorFlyout, mcqOptionsComponent, optionsWrapperComponent, previewScoringAndShowCorrectAnswerComponent, questionInstructionsComponent, scoringSectionBase } from "./components"
4
+ import { answerNumerationComponent } from "./components/answerNumerationComponent";
5
+ import { listSortingAndOrderingBase } from "./components/listSortingAndOrderingBase";
6
+ import { setPointsPopupBase } from "./components/setPointsPopupBase";
7
+ import { studentResponseAndLayoutComponent } from "./components/studentResponseAreaAndLayoutComponent";
8
+ const css = Cypress.env('css');
9
+
10
+ const selectors = {
11
+ ...commonComponents,
12
+ ...optionsWrapperComponent,
13
+ ...scoringSectionBase,
14
+ ...autoScoredScoringSectionMultipleResponsesType,
15
+ ...autoScoredSetCorrectAnswerSection,
16
+ ...autoScoredAdditionalSettings,
17
+ ...previewScoringAndShowCorrectAnswerComponent,
18
+ ...autoScoredPreviewBase,
19
+ ...additionalSettingsPanel,
20
+ ...questionInstructionsComponent,
21
+ ...answerNumerationComponent,
22
+ ...setPointsPopupBase,
23
+ ...listSortingAndOrderingBase,
24
+ //Set correct answer section
25
+ setCorrectAnswerSectionOption: () => cy.get('.list-ordering-set-correct-answer .draggable-item-wrapper[role="button"]'),
26
+ setCorrectAnswerSectionOptionsWrapper: () => cy.get('[class*="ListOrderingResponsestyles__DroppableWrapper"]'),
27
+ //Preview Tab
28
+ pointsPerResponseLabel: () => cy.get('.list-ordering-points-text'),
29
+ previewTabOption: () => cy.get('.edit-question-preview-wrapper .draggable-item-wrapper[role="button"]'),
30
+ previewTabOptionsWrapper: () => cy.get('.edit-question-preview-wrapper [class*="ListOrderingResponsestyles__DroppableWrapper"]'),
31
+ partialEqualWeightsPointsPerResponseScore: () => cy.get('.orderlist-points-wrapper'),
32
+ partialDifferentWeightsPointsInputField: () => cy.get('.orderlist-points-wrapper input'),
33
+ partialDifferentWeightsPointsPerResponseLabel: () => cy.get('.list-ordering-points-wrapper'),
34
+ //Additional Settings
35
+ optionNumeration: () => cy.get('[class*="__IndexWrapper"]'),
36
+ setCorrectAnswerSectionTopLabel: () => cy.get('[class*="TopLabelWrapper"].top-bottom-label'),
37
+ setCorrectAnswerSectionBottomLabel: () => cy.get('[class*="BottomLabelWrapper"].top-bottom-label'),
38
+ previewTabTopLabel: () => cy.get('.edit-question-preview-wrapper [class*="TopLabelWrapper"].top-bottom-label'),
39
+ previewTabBottomLabel: () => cy.get('.edit-question-preview-wrapper [class*="BottomLabelWrapper"].top-bottom-label'),
40
+ pointsPerResponseLabelForInlineOption: () => cy.get('[class*="ListOrderingstyles__EqualPointsWrapper"]'),
41
+ pointsPerResponseScoreForInlineOption: () => cy.get('[class*="ListOrderingstyles__EqualPointsWrapper"] span'),
42
+ //Set points popup
43
+ buttonSetPoints: () => cy.get('[class*="SetPointsstyle__Button"]'),
44
+ setPointsIcon: () => cy.get('[class*="SetPointsstyle__Button"] svg'),
45
+ //Remove after https://redmine.zeuslearning.com/issues/518498 is fixed
46
+ dragHandleButton: () => cy.get('[class*="DragIcon"]')
47
+ }
48
+
49
+ const steps = {
50
+ ...createQuestionBasePage.steps,
51
+ ...questionInstructionsComponent.steps,
52
+ ...scoringSectionBase.steps,
53
+ ...autoScoredSetCorrectAnswerSection.steps,
54
+ ...commonComponents.steps,
55
+ ...mcqOptionsComponent.steps,
56
+ ...optionsWrapperComponent.steps,
57
+ ...ckEditorToolbar.steps,
58
+ ...equationEditorFlyout.steps,
59
+ ...autoScoredScoringSectionMultipleResponsesType.steps,
60
+ ...additionalSettingsPanel.steps,
61
+ ...previewScoringAndShowCorrectAnswerComponent.steps,
62
+ ...autoScoredPreviewBase.steps,
63
+ ...autoScoredAdditionalSettings.steps,
64
+ ...autoScoredScoringSection.steps,
65
+ ...answerNumerationComponent.steps,
66
+ ...setPointsPopupBase.steps,
67
+ ...listSortingAndOrderingBase.steps,
68
+ /**
69
+ * @param {number} index set correct answer option index
70
+ * @description this function verfies contents of options
71
+ */
72
+ verifyDragHandleButtonOfOptionInSetCorrectAnswerSection: (index) => {
73
+ listOrderingPage.setCorrectAnswerSectionOption()
74
+ .eq(index)
75
+ .within(() => {
76
+ listOrderingPage.dragHandleButton()
77
+ .should('exist');
78
+ });
79
+ },
80
+
81
+ /**
82
+ * @param {string[]} optionsTextArray options array for set correct answer option
83
+ * @description this function verifies options text content
84
+ */
85
+ verifyOptionsTextContentInSetCorrectAnswerSection: (optionsTextArray) => {
86
+ optionsTextArray.forEach((optionsText, index) => {
87
+ listOrderingPage.setCorrectAnswerSectionOption()
88
+ .eq(index)
89
+ .should('have.text', optionsText);
90
+ });
91
+ },
92
+
93
+ /**
94
+ * @param {number} index of option
95
+ * @description this function verifies image in set correct answer option input field
96
+ */
97
+ verifyImageAddedToOptionInSetCorrectAnswerSection: (index) => {
98
+ listOrderingPage.setCorrectAnswerSectionOption()
99
+ .eq(index)
100
+ .find('img')
101
+ .should('have.attr', 'src', constants.foxImageLink)
102
+ .and('have.attr', 'alt', constants.foxImageAltText);
103
+ },
104
+
105
+ /**
106
+ * @param {number} index of option
107
+ * @description this function verifies equation in set correct answer option input field
108
+ */
109
+ verifyEquationAddedToOptionInSetCorrectAnswerSection: (index) => {
110
+ listOrderingPage.setCorrectAnswerSectionOption()
111
+ .eq(index)
112
+ .contains(constants.CKEditorInputFieldEnteredEquationText)
113
+ listOrderingPage.setCorrectAnswerSectionOption()
114
+ .find('[role="math"]')
115
+ .should('have.attr', 'aria-label', constants.CKEditorInputFieldEnteredEquationAriaLabel)
116
+ },
117
+
118
+ /**
119
+ * @param {number} index of option
120
+ * @description this function link in set correct answer option input field
121
+ */
122
+ verifyLinkAddedToOptionInSetCorrectAnswerSection: (index) => {
123
+ listOrderingPage.setCorrectAnswerSectionOption()
124
+ .eq(index)
125
+ .should('have.text', 'lorem')
126
+ .find('a')
127
+ .should('have.attr', 'href', `${Cypress.config().baseUrl}`)
128
+ },
129
+
130
+ /**
131
+ * @param {number} index of option
132
+ * @description this function bold text in set correct answer option input field
133
+ */
134
+ verifyBoldTextAddedToOptionInSetCorrectAnswerSection: (index) => {
135
+ listOrderingPage.setCorrectAnswerSectionOption()
136
+ .eq(index)
137
+ .find('strong')
138
+ .eq(0)
139
+ .should('have.text', 'This is a bold option');
140
+ },
141
+
142
+ verifyDefaultAndActiveStateOfOptionInSetCorrectAnswerSection: () => {
143
+ listOrderingPage.setCorrectAnswerSectionOption()
144
+ .eq(0)
145
+ .realHover()
146
+ .should('have.css', 'border', `2px solid ${css.color.activeButtons}`)
147
+ .find('.question-text-wrapper')
148
+ .and('have.css', 'color', css.color.activeButtons);
149
+ listOrderingPage.setCorrectAnswerSectionOption()
150
+ .eq(0)
151
+ .realHover({ position: 'topLeft' })
152
+ .should('have.css', 'border', `1px solid ${css.color.figDefaultComponentBorder}`)
153
+ .find('.question-text-wrapper')
154
+ .and('have.css', 'color', css.color.text)
155
+ },
156
+
157
+ /**
158
+ *
159
+ * @param {string} optionsText text content of the option
160
+ * @param {number} index the position at which the options is being dropped
161
+ * @description click and drop a option into a position in the set correct answer section
162
+ */
163
+ clickAndReorderOptionInSetCorrectAnswerSection: (optionsText, index) => {
164
+ listOrderingPage.setCorrectAnswerSectionOption()
165
+ .contains(optionsText)
166
+ .click();
167
+ listOrderingPage.setCorrectAnswerSectionOption()
168
+ .eq(index)
169
+ .click();
170
+ },
171
+
172
+ verifyPointsInputFieldErrorMessage: () => {
173
+ commonComponents.errorMessage()
174
+ .eq(0)
175
+ .should('have.text', 'Error: Please enter points.');
176
+ },
177
+
178
+ //Preview tab
179
+ /**
180
+ * @param {number} index set correct answer option index
181
+ * @description this function verfies contents of options
182
+ */
183
+ verifyDragHandleButtonOfOptionInPreviewTab: (index) => {
184
+ listOrderingPage.previewTabOption()
185
+ .eq(index)
186
+ .within(() => {
187
+ listOrderingPage.dragHandleButton()
188
+ .should('exist');
189
+ });
190
+ },
191
+
192
+ /**
193
+ * @param {string[]} optionsTextArray options array for set correct answer option
194
+ * @description this function verifies options text content
195
+ */
196
+ verifyTextContentOfOptionsInPreviewTab: (optionsTextArray) => {
197
+ optionsTextArray.forEach((optionsText, index) => {
198
+ listOrderingPage.previewTabOption()
199
+ .eq(index)
200
+ .should('have.text', optionsText);
201
+ });
202
+ },
203
+
204
+ /**
205
+ * @param {number} index of option
206
+ * @description this function verifies image text in preview tab options
207
+ */
208
+ verifyImageAddedToOptionInPreviewTab: (index) => {
209
+ listOrderingPage.previewTabOption()
210
+ .eq(index)
211
+ .find('img')
212
+ .should('have.attr', 'src', constants.foxImageLink)
213
+ .and('have.attr', 'alt', constants.foxImageAltText);
214
+ },
215
+
216
+ /**
217
+ * @param {number} index of option
218
+ * @description this function verifies equation text in preview tab options
219
+ */
220
+ verifyEquationAddedToOptionInPreviewTab: (index) => {
221
+ listOrderingPage.previewTabOption()
222
+ .eq(index)
223
+ .contains(constants.CKEditorInputFieldEnteredEquationText)
224
+ listOrderingPage.previewTabOption()
225
+ .find('[role="math"]')
226
+ .should('have.attr', 'aria-label', constants.CKEditorInputFieldEnteredEquationAriaLabel)
227
+ },
228
+
229
+ /**
230
+ * @param {number} index of option
231
+ * @description this function verifies link in preview tab options
232
+ */
233
+ verifyLinkAddedToOptionInPreviewTab: (index) => {
234
+ listOrderingPage.previewTabOption()
235
+ .eq(index)
236
+ .should('have.text', 'lorem')
237
+ .find('a')
238
+ .should('have.attr', 'href', `${Cypress.config().baseUrl}`)
239
+ },
240
+
241
+ /**
242
+ * @param {number} index of option
243
+ * @description this function verifies bold text in preview tab options
244
+ */
245
+ verifyBoldTextAddedToOptionInPreviewTab: (index) => {
246
+ listOrderingPage.previewTabOption()
247
+ .eq(index)
248
+ .find('strong')
249
+ .should('exist')
250
+ .should('have.text', 'This is a bold option')
251
+ },
252
+
253
+ verifyDefaultAndActiveStateOfOptionInPreviewTab: () => {
254
+ listOrderingPage.previewTabOption()
255
+ .eq(0)
256
+ .realHover()
257
+ .should('have.css', 'border', `2px solid ${css.color.activeButtons}`)
258
+ .find('.question-text-wrapper')
259
+ .and('have.css', 'color', css.color.activeButtons);
260
+ listOrderingPage.previewTabOption()
261
+ .eq(0)
262
+ .realHover({ position: 'topLeft' })
263
+ .should('have.css', 'border', `1px solid ${css.color.figDefaultComponentBorder}`)
264
+ .find('.question-text-wrapper')
265
+ .and('have.css', 'color', css.color.text)
266
+ },
267
+
268
+ //Scoring
269
+ /**
270
+ * @param {number} points the points to be displayed in the partial equal weights points field
271
+ * @description this function checks the points per response in partial equal weights
272
+ */
273
+ verifyPartialEqualWeightsPointsPerResponseScore: (points) => {
274
+ listOrderingPage.partialEqualWeightsPointsPerResponseScore()
275
+ .each(($element) => {
276
+ cy.wrap($element)
277
+ .verifyInnerText(points);
278
+ });
279
+ },
280
+
281
+ /**
282
+ * @description this function checks if the partial different weights points field is empty and visible
283
+ */
284
+ verifyPartialDifferentWeightsPointsInputFieldIsEmptyAndEnabled: () => {
285
+ listOrderingPage.partialDifferentWeightsPointsInputField()
286
+ .each(($element) => {
287
+ cy.wrap($element)
288
+ .should('have.value', '')
289
+ .and('be.visible')
290
+ .and('be.enabled');
291
+ });
292
+ },
293
+
294
+ /**
295
+ * @param {number[]} pointsArray the array of points to be alloted to each option
296
+ * @description this function allots points to all the options
297
+ */
298
+ allotPartialDifferentWeightsToAllPointsFields: (pointsArray) => {
299
+ pointsArray.forEach((points, columnIndex) => {
300
+ listOrderingPage.partialDifferentWeightsPointsInputField()
301
+ .eq(columnIndex)
302
+ .clear()
303
+ .type(points, { delay: 0 })
304
+ .should('have.value', points);
305
+ });
306
+ },
307
+
308
+ verifyPartialDifferentWeightsPointsPerResponseLabel: () => {
309
+ listOrderingPage.partialDifferentWeightsPointsPerResponseLabel()
310
+ .verifyInnerText('Points per response')
311
+ .should('be.visible');
312
+ },
313
+
314
+ verifyPointsPerResponseLabel: () => {
315
+ listOrderingPage.pointsPerResponseLabel()
316
+ .verifyInnerText('Points per response')
317
+ .should('be.visible');
318
+ },
319
+
320
+ /**
321
+ *
322
+ * @param {string} optionsText text content of the option
323
+ * @param {number} index the position at which the options is being dropped
324
+ * @description click and drop a option into a position in the set correct answer section
325
+ */
326
+ clickAndReorderOptionInPrevewTab: (optionsText, index) => {
327
+ listOrderingPage.previewTabOption()
328
+ .contains(optionsText)
329
+ .click();
330
+ listOrderingPage.previewTabOption()
331
+ .eq(index)
332
+ .click();
333
+ },
334
+
335
+ /**
336
+ *
337
+ * @param {string[]} optionsArray array of options set in options section
338
+ * @description this function resets the question preview
339
+ */
340
+ resetQuestionPreview: (optionsArray) => {
341
+ createQuestionBasePage.steps.switchToEditTab();
342
+ createQuestionBasePage.steps.switchToPreviewTab();
343
+ listOrderingPage.steps.verifyTextContentOfOptionsInPreviewTab(optionsArray);
344
+ },
345
+
346
+ /**
347
+ * @param {string[]} numerationArray array of numeration numbers, lowercase, uppercase
348
+ * @description this function verifies the numeration of options
349
+ */
350
+ verifyOptionsNumeration: (numerationArray) => {
351
+ numerationArray.forEach((optionNumeration, index) => {
352
+ listOrderingPage.previewTabOption()
353
+ .eq(index)
354
+ .within(() => {
355
+ listOrderingPage.optionNumeration()
356
+ .should('have.text', optionNumeration);
357
+ });
358
+ });
359
+ },
360
+
361
+ /**
362
+ * @param {string} optionsText option to be checked for the correct icon
363
+ * @description This function verifies the correct icon in the preview tab
364
+ */
365
+ verifyCorrectOptionsCheckmarkIcon: (optionsText) => {
366
+ listOrderingPage.previewTabOption()
367
+ .contains(optionsText)
368
+ .parents('.orderlist-option-wrapper')
369
+ .within(() => {
370
+ autoScoredPreviewBase.correctIcon()
371
+ .and('be.visible');
372
+ });
373
+ },
374
+
375
+ /**
376
+ * @param {string} optionsText option to be checked for the correct icon
377
+ * @description This function verifies the correct icon in the preview tab
378
+ */
379
+ verifyIncorrectOptionsCrossmarkIcon: (optionsText) => {
380
+ listOrderingPage.previewTabOption()
381
+ .contains(optionsText)
382
+ .parents('.orderlist-option-wrapper')
383
+ .within(() => {
384
+ autoScoredPreviewBase.incorrectIcon()
385
+ .and('be.visible');
386
+ });
387
+ },
388
+
389
+ verifyQuestionPreviewStateWhenShowCorrectAnswerIsUnchecked: () => {
390
+ cy.log('After deselecting Show correct answer checkbox, the question preview should return to the previous state');
391
+ previewScoringAndShowCorrectAnswerComponent.showCorrectAnswerCheckbox()
392
+ .click()
393
+ .should('not.be.checked');
394
+ autoScoredPreviewBase.correctIcon()
395
+ .should('not.exist');
396
+ autoScoredPreviewBase.incorrectIcon()
397
+ .should('not.exist');
398
+ autoScoredPreviewBase.correctIncorectAnswerLabel()
399
+ .should('not.exist');
400
+ autoScoredPreviewBase.steps.verifyCorrectIncorrectBorderNotVisible()
401
+ },
402
+
403
+ getOptionsArray: () => {
404
+ const optionsArray = []
405
+ listOrderingPage.previewTabOption()
406
+ .each(($el) => {
407
+ cy.wrap($el)
408
+ .invoke('text')
409
+ .then((text) => {
410
+ optionsArray.push(text);
411
+ });
412
+ });
413
+ return optionsArray;
414
+ },
415
+
416
+ /**
417
+ * @param {string[]} optionsArray array of options set in the options section
418
+ * @description this function verifies if the options are Randomized in the preview tab
419
+ */
420
+ verifyRandomizeOptionOrder: (optionsArray) => {
421
+ let currentOptionsArray = [...optionsArray]
422
+ for (let index = 0; index < currentOptionsArray.length; index++) {
423
+ listOrderingPage.previewTabOption()
424
+ .eq(index)
425
+ .then(($element) => {
426
+ expect($element.text()).to.be.oneOf(currentOptionsArray);
427
+ currentOptionsArray = currentOptionsArray.filter((value) => value !== $element.text())
428
+ });
429
+ };
430
+ listOrderingPage.steps.verifyOptionsAreRerandomized(optionsArray)
431
+ },
432
+
433
+ /**
434
+ * @param {string[]} previousOrderOfOptionsArray array of previous order of options
435
+ * @description this function verifies that the order of the options is different from the previous order
436
+ */
437
+ verifyOptionsAreRerandomized: (previousOrderOfOptionsArray) => {
438
+ listOrderingPage.previewTabOption()
439
+ .should('not.have.text', '')
440
+ .and('not.have.text', previousOrderOfOptionsArray.join(''));
441
+ },
442
+
443
+ /**
444
+ * @param {number} index set correct answer option index
445
+ * @description this function verfies drag handle of options does not exist
446
+ */
447
+ verifyDragHandleButtonDoesNotExistInSetCorrectAnswerSection: (index) => {
448
+ listOrderingPage.setCorrectAnswerSectionOption()
449
+ .eq(index)
450
+ .within(() => {
451
+ listOrderingPage.dragHandleButton()
452
+ .should('not.exist');
453
+ });
454
+ },
455
+
456
+ /**
457
+ * @param {number} index set correct answer option index
458
+ * @description this function verfies drag handle of options does not exist
459
+ */
460
+ verifyDragHandleButtonDoesNotExistInPreviewTab: (index) => {
461
+ listOrderingPage.previewTabOption()
462
+ .eq(index)
463
+ .within(() => {
464
+ listOrderingPage.dragHandleButton()
465
+ .should('not.exist');
466
+ });
467
+ },
468
+
469
+ //Additional settings
470
+
471
+ verifyNoBorderForSetCorrectAnswerOption: () => {
472
+ listOrderingPage.setCorrectAnswerSectionOption()
473
+ .eq(0)
474
+ .should('have.css', 'border')
475
+ .and('match', /0px none/);
476
+ },
477
+
478
+ verifyNoBorderForPreviewTabOption: () => {
479
+ listOrderingPage.previewTabOption()
480
+ .eq(0)
481
+ .should('have.css', 'border')
482
+ .and('match', /0px none/);
483
+ },
484
+
485
+ clickOnSetPointsButton: () => {
486
+ listOrderingPage.buttonSetPoints()
487
+ .click();
488
+ },
489
+
490
+ verifySetPointsButton: () => {
491
+ utilities.verifyInnerText(listOrderingPage.buttonSetPoints(), 'Set points');
492
+ utilities.verifyElementVisibilityState(listOrderingPage.setPointsIcon(), 'visible');
493
+ },
494
+
495
+ /**
496
+ * @param {number} index of option
497
+ * @description this function verifies image in set points popup
498
+ */
499
+ verifyImageAddedToOptionInSetPointsPopup: (index) => {
500
+ setPointsPopupBase.setPointsPopupOptions()
501
+ .eq(index)
502
+ .find('img')
503
+ .should('have.attr', 'src', constants.foxImageLink)
504
+ .and('have.attr', 'alt', constants.foxImageAltText);
505
+ },
506
+
507
+ /**
508
+ * @param {number} index of option
509
+ * @description this function verifies equation text in set points popup
510
+ */
511
+ verifyEquationAddedToOptionInSetPointsPopup: (index) => {
512
+ setPointsPopupBase.setPointsPopupOptions()
513
+ .eq(index)
514
+ .contains(constants.CKEditorInputFieldEnteredEquationText)
515
+ setPointsPopupBase.setPointsPopupOptions()
516
+ .find('[role="math"]')
517
+ .should('have.attr', 'aria-label', constants.CKEditorInputFieldEnteredEquationAriaLabel)
518
+ },
519
+
520
+ /**
521
+ * @param {number} index of option
522
+ * @description this function link in set points popup
523
+ */
524
+ verifyLinkAddedToOptionInSetPointsPopup: (index) => {
525
+ setPointsPopupBase.setPointsPopupOptions()
526
+ .eq(index)
527
+ .should('have.text', 'lorem')
528
+ .find('a')
529
+ .should('have.attr', 'href', `${Cypress.config().baseUrl}`)
530
+ },
531
+
532
+ /**
533
+ * @param {number} index of option
534
+ * @description this function bold text in in set points popup
535
+ */
536
+ verifyBoldTextAddedToOptionInSetPointsPopup: (index) => {
537
+ setPointsPopupBase.setPointsPopupOptions()
538
+ .eq(index)
539
+ .find('strong')
540
+ .eq(0)
541
+ .should('have.text', 'This is a bold option');
542
+ },
543
+
544
+ /**
545
+ * @param {number[]} numerationArray numeration array for the option
546
+ * @description this function checks the numeration of options in set points popup
547
+ */
548
+ verifySetPointsPopupOptionNumeration: (numerationArray) => {
549
+ numerationArray.forEach((optionNumeration, index) => {
550
+ setPointsPopupBase.dialogBox()
551
+ .within(() => {
552
+ listOrderingPage.optionNumeration()
553
+ .eq(index)
554
+ .should('have.text', optionNumeration);
555
+ });
556
+ });
557
+ },
558
+
559
+ verifyCorrectIncorrectAnswerLabel: (labelText) => {
560
+ autoScoredPreviewBase.correctIncorectAnswerLabel()
561
+ .should('be.visible')
562
+ .verifyInnerText(`${labelText} answer`)
563
+ .parents('[class*="__AnswerStatusWrapper"]')
564
+ .find('[class*="__AnswerStatusIcon"]')
565
+ .should('be.visible')
566
+ .should('have.text', `${labelText}-Icon`)
567
+ }
568
+ }
569
+
570
+ const tests = {
571
+ ...createQuestionBasePage.tests,
572
+ ...commonComponents.tests,
573
+ ...questionInstructionsComponent.tests,
574
+ ...autoScoredScoringSection.tests,
575
+ ...scoringSectionBase.tests,
576
+ ...autoScoredSetCorrectAnswerSection.tests,
577
+ ...previewScoringAndShowCorrectAnswerComponent.tests,
578
+ ...additionalSettingsPanel.tests,
579
+ ...autoScoredAdditionalSettings.tests,
580
+ ...answerNumerationComponent.tests,
581
+ ...studentResponseAndLayoutComponent.tests,
582
+ ...listSortingAndOrderingBase.tests,
583
+ verifyAllContentsOfSetCorrectAnswerSectionForScoringType: (scoringType, optionsArray) => {
584
+ it(`When user has selected ${scoringType} scoring type then added options should be displayed in the set correct answer section`, () => {
585
+ listOrderingPage.steps.verifyOptionsTextContentInSetCorrectAnswerSection(optionsArray);
586
+ for (let index = 0; index < 4; index++) {
587
+ listOrderingPage.steps.verifyDragHandleButtonOfOptionInSetCorrectAnswerSection(index);
588
+ }
589
+ });
590
+ },
591
+
592
+ /**
593
+ * @param {number} totalPoints the maximum points that can be scored by the user
594
+ * @description this function verifies the functionality of minimum points when penalty points are not set and user attempts incorrect answer
595
+ */
596
+ verifyMinimumScoreAwardedIfAttemptedFunctionalityForIncorrectAnswer: (totalPoints) => {
597
+ it('When user has provided minimum score awarded (if attempted) points, then in Preview tab on entering incorrect answer, minimum score should be provided for the question', () => {
598
+ cy.log('Switch to edit tab and set minimum score if attempted points')
599
+ createQuestionBasePage.steps.switchToEditTab();
600
+ scoringSectionBase.steps.allotMinimumScoreAwardedIfAttempted('1')
601
+ createQuestionBasePage.steps.switchToPreviewTab()
602
+ listOrderingPage.steps.clickAndReorderOptionInPrevewTab('plant', 1);
603
+ listOrderingPage.steps.verifyTextContentOfOptionsInPreviewTab(['sprout', 'plant', 'flower', 'seed']);
604
+ listOrderingPage.previewScoreText()
605
+ .verifyInnerText(`1/${totalPoints}`);
606
+ });
607
+
608
+ it('When user removes minimum score awarded (if attempted) points, then in Preview tab on selecting any options other than correct answers, points should not be provided', () => {
609
+ cy.log('Switch to edit tab and remove minimum score if attempted points')
610
+ createQuestionBasePage.steps.switchToEditTab();
611
+ scoringSectionBase.steps.clearMinimumScoreIfAttemptedPointsField();
612
+ createQuestionBasePage.steps.switchToPreviewTab()
613
+ listOrderingPage.steps.clickAndReorderOptionInPrevewTab('plant', 1);
614
+ listOrderingPage.steps.verifyTextContentOfOptionsInPreviewTab(['sprout', 'plant', 'flower', 'seed']);
615
+ listOrderingPage.previewScoreText()
616
+ .verifyInnerText(`0/${totalPoints}`);
617
+ });
618
+ },
619
+
620
+ /**
621
+ *
622
+ * @param {number} scoredPoints the points scored by the user when penalty points are reduced
623
+ * @param {number} totalPoints the maximum points that can be scored by the user
624
+ * @description this function verifies the functionality of Penalty points when minimum points are not set and user attempts incorrect answer
625
+ */
626
+ verifyPenaltyPointsFunctionalityForIncorrectAnswer: (scoredPoints, totalPoints) => {
627
+ it('When user has defined penalty points', () => {
628
+ cy.log('Pre-step: Switch to edit tab and set penalty points');
629
+ createQuestionBasePage.steps.switchToEditTab();
630
+ autoScoredScoringSectionMultipleResponsesType.steps.allotPenaltyPoints(3)
631
+
632
+ cy.log('After switching to preview tab, when user adds an incorrect answer input, then 0 points should be awarded(no negative points)');
633
+ createQuestionBasePage.steps.switchToPreviewTab();
634
+ listOrderingPage.steps.clickAndReorderOptionInPrevewTab('plant', 1);
635
+ listOrderingPage.steps.verifyTextContentOfOptionsInPreviewTab(['sprout', 'plant', 'flower', 'seed']);
636
+ listOrderingPage.previewScoreText()
637
+ .verifyInnerText(`0/${totalPoints}`);
638
+
639
+ cy.log('When user adds a partially correct answer input, the points should be updated accordingly with deducted penalty points');
640
+ listOrderingPage.steps.resetQuestionPreview(['plant', 'sprout', 'flower', 'seed'])
641
+ listOrderingPage.steps.clickAndReorderOptionInPrevewTab('seed', 0);
642
+ listOrderingPage.steps.verifyTextContentOfOptionsInPreviewTab(['seed', 'plant', 'sprout', 'flower']);
643
+ listOrderingPage.previewScoreText()
644
+ .verifyInnerText(`${scoredPoints}/${totalPoints}`);
645
+
646
+ cy.log('Post step: Clearing the Penalty points field')
647
+ createQuestionBasePage.steps.switchToEditTab();
648
+ autoScoredScoringSectionMultipleResponsesType.penaltyPointsInputField()
649
+ .clear();
650
+ });
651
+ },
652
+
653
+ /**
654
+ * @param {*} totalPointsScored the maximum points that can be achieved by the user
655
+ * @description this function verifies the functionality of penalty points when penalty points are set and user attempts alternate tab answers
656
+ */
657
+ verifyPenaltyPointsFunctionalityForAlternateTabAnswers: (totalPointsScored) => {
658
+ it('When the user has alloted penalty points and attempts the question according to the alternate tab then user should be awarded with full points of the alternate tab and penalty points should not be deducted', () => {
659
+ listOrderingPage.steps.switchToEditTab()
660
+ listOrderingPage.steps.allotPenaltyPoints(3);
661
+ listOrderingPage.steps.switchToPreviewTab();
662
+ listOrderingPage.steps.clickAndReorderOptionInPrevewTab('seed', 0);
663
+ listOrderingPage.steps.clickAndReorderOptionInPrevewTab('plant', 3);
664
+ listOrderingPage.steps.clickAndReorderOptionInPrevewTab('flower', 1);
665
+ listOrderingPage.steps.verifyTextContentOfOptionsInPreviewTab(['seed', 'flower', 'sprout', 'plant']);
666
+ listOrderingPage.steps.verifyPreviewTabScoreText(`${totalPointsScored}`, `${totalPointsScored}`);
667
+ cy.log('Post step: Clearing the Penalty points field')
668
+ createQuestionBasePage.steps.switchToEditTab();
669
+ autoScoredScoringSectionMultipleResponsesType.penaltyPointsInputField()
670
+ .clear();
671
+ });
672
+ },
673
+
674
+ /**
675
+ * @param {number[]} scoredPointsArray An array of numbers representing points scored in different cases.
676
+ * - The first element represents points scored for incorrect answers.
677
+ * - The second element represents points scored for partially correct answers.
678
+ * - The third element represents points scored when minimum score awarded (if attempted) points is greater than the points achieved by attempting the question partially correct
679
+ * @param {number} minimumPointsForPartialCorrectAnswers minimum score awarded (if attempted) points on attempting the question partially correct
680
+ * @param {number} totalPoints the maximum points that can be achieved by the user
681
+ * @description this function verifies the functionality of Minimum score if attempted points when penalty points are set and user attempts incorrect answer
682
+ * - For all incorrect responses
683
+ * - For partially correct responses, when points scored > minimum score awarded(if attempted) points
684
+ * - For partially correct responses, when minimum score awarded(if attempted) points > points scored
685
+ */
686
+ verifyMinimumScoreIfAttemptedAndPenaltyPointsFunctionalityForIncorrectAnswer: (scoredPointsArray, minimumPointsForPartialCorrectAnswers, totalPoints) => {
687
+ it('When user has defined both penalty points and minimum score awarded (if attempted) points', () => {
688
+ cy.log('Pre-step: Switch to edit tab and set minimum score awarded (if attempted) points and Penalty points');
689
+ createQuestionBasePage.steps.switchToEditTab();
690
+ scoringSectionBase.steps.allotMinimumScoreAwardedIfAttempted(1);
691
+ autoScoredScoringSectionMultipleResponsesType.steps.allotPenaltyPoints(3);
692
+
693
+ cy.log('Switch to preview tab and give incorrect answer input to check that minimum points are displayed');
694
+ createQuestionBasePage.steps.switchToPreviewTab();
695
+ listOrderingPage.steps.clickAndReorderOptionInPrevewTab('plant', 1);
696
+ listOrderingPage.steps.verifyTextContentOfOptionsInPreviewTab(['sprout', 'plant', 'flower', 'seed']);
697
+ listOrderingPage.previewScoreText()
698
+ .verifyInnerText(`${scoredPointsArray[0]}/${totalPoints}`);
699
+
700
+ cy.log('When user adds a partially correct answer such that the points of the attempt(with penalty points deducted) is more than the minimum score awarded(if attempted) points');
701
+ listOrderingPage.steps.resetQuestionPreview(['plant', 'sprout', 'flower', 'seed']);
702
+ listOrderingPage.steps.clickAndReorderOptionInPrevewTab('seed', 0);
703
+ listOrderingPage.steps.verifyTextContentOfOptionsInPreviewTab(['seed', 'plant', 'sprout', 'flower']);
704
+ listOrderingPage.previewScoreText()
705
+ .verifyInnerText(`${scoredPointsArray[1]}/${totalPoints}`);
706
+
707
+ cy.log('When user switches to edit tab and increases the minimum score awarded (if attempted) points to check the case for an attempt in which points of the attempt is less than minimum score awarded (if attempted) points, then the minimum score awarded (if attempted) points should be displayed to the user');
708
+ createQuestionBasePage.steps.switchToEditTab();
709
+ scoringSectionBase.steps.clearMinimumScoreIfAttemptedPointsField()
710
+ scoringSectionBase.steps.allotMinimumScoreAwardedIfAttempted(minimumPointsForPartialCorrectAnswers)
711
+ cy.log('Switching to preview tab');
712
+ createQuestionBasePage.steps.switchToPreviewTab();
713
+ listOrderingPage.steps.clickAndReorderOptionInPrevewTab('seed', 0);
714
+ listOrderingPage.steps.verifyTextContentOfOptionsInPreviewTab(['seed', 'plant', 'sprout', 'flower']);
715
+ listOrderingPage.previewScoreText()
716
+ .verifyInnerText(`${scoredPointsArray[2]}/${totalPoints}`);
717
+ });
718
+ },
719
+
720
+ //Additional settings
721
+ /**
722
+ * @param {string[]} numerationArray array of the numeration displayed with options numbers| lowercase| uppercase
723
+ * @description this function checks the numeration displayed for the options and correct answer container options when Show correct answer is checked
724
+ */
725
+ verifyOptionsAndCorrectAnswerContainerNumerationWhenShowCorrectAnswerCheckboxIsChecked: (numerationArray) => {
726
+ it('When user clicks on \'Show correct answer\' checkbox then the numeration should be displayed on the options as well as \'Correct answers:\' section', () => {
727
+ listOrderingPage.steps.checkShowCorrectAnswerCheckbox()
728
+ steps.verifyOptionsNumeration(numerationArray)
729
+ steps.verifyCorrectAnswerContainerNumeration(numerationArray)
730
+ cy.log('Post step: Uncheck \'Show correct answer\' checkbox')
731
+ listOrderingPage.steps.uncheckShowCorrectAnswerCheckbox()
732
+ });
733
+ },
734
+
735
+ /**
736
+ * @param {string[]} numerationArray array of the numeration displayed with options numbers| lowercase| uppercase
737
+ * @description this function checks the numeration displayed for the options and correct answer container options when check answer is selected
738
+ */
739
+ verifyOptionsNumerationWhenCheckAnswerIsSelected: (numerationArray) => {
740
+ it('When user clicks on \'Check answer\' button then the numeration should be displayed in the options', () => {
741
+ listOrderingPage.steps.checkAnswer()
742
+ steps.verifyOptionsNumeration(numerationArray)
743
+ });
744
+ }
745
+ }
746
+
747
+ export const listOrderingPage = {
748
+ ...selectors,
749
+ steps,
750
+ tests
751
+ }