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,183 @@
1
+ import { autoScoredPreviewBase } from "./autoScoredPreviewBase";
2
+ import { createQuestionBasePage } from "./createQuestionBasePage";
3
+
4
+ const css = Cypress.env('css');
5
+
6
+ const selectors = {
7
+ allowStudentsToCheckAnswerLabel: () => cy.get('.allow-student-check-answer-checkbox-wrapper .MuiFormControlLabel-label'),
8
+ allowStudentsToCheckAnswerCheckbox: () => cy.get('.ngie-checkbox [aria-label="Allow students to check answer"]'),
9
+ checkAnswerLabel: () => cy.get('.edit-check-answer-label'),
10
+ maximumCheckAnswerAttemptsLabel: () => cy.get('[class*="CheckAnswerstyles__OptionWrapper"] label[class*="MuiFormLabel-root MuiInputLabel-root"]'),
11
+ maximumCheckAnswerAttemptsInputField: () => cy.get('[class*="CheckAnswerstyles__OptionWrapper"] input[type="text"]'),
12
+ }
13
+
14
+ const steps = {
15
+ //V3 - This function should be updated in all files
16
+ clearMaximumCheckAnswerAttemptsInputField: () => {
17
+ autoScoredAdditionalSettings.maximumCheckAnswerAttemptsInputField()
18
+ .clear()
19
+ .should('have.value', '');
20
+ },
21
+
22
+ //V3 - This function should be updated in all files
23
+ addInputToMaximumCheckAnswerAttemptsInputField: (maxCheckAnswerAttempts) => {
24
+ autoScoredAdditionalSettings.maximumCheckAnswerAttemptsInputField()
25
+ .type(maxCheckAnswerAttempts)
26
+ .should('have.value', maxCheckAnswerAttempts);
27
+ },
28
+
29
+ setMaximumCheckAnswerAttempts: (maxCheckAnswerAttempts) => {
30
+ autoScoredAdditionalSettings.steps.checkAllowStudentsToCheckAnswerCheckbox()
31
+ autoScoredAdditionalSettings.steps.addInputToMaximumCheckAnswerAttemptsInputField(maxCheckAnswerAttempts)
32
+ },
33
+
34
+ //V3 - This function should be updated in all files
35
+ checkAllowStudentsToCheckAnswerCheckbox: () => {
36
+ autoScoredAdditionalSettings.allowStudentsToCheckAnswerCheckbox()
37
+ .click()
38
+ .should('be.checked');
39
+ }
40
+ }
41
+
42
+ const tests = {
43
+ verifyCheckAnswerSectionAndPreviewTabCheckAnswerButton: (questionType) => {
44
+ it('CSS of \'Check Answer\' section', { tags: 'css' }, () => {
45
+ autoScoredAdditionalSettings.checkAnswerLabel()
46
+ .verifyCSS(css.color.labels, css.fontSize.default, css.fontWeight.semibold);
47
+ autoScoredAdditionalSettings.allowStudentsToCheckAnswerLabel()
48
+ .verifyCSS(css.color.labelText, css.fontSize.normal, css.fontWeight.regular);
49
+ });
50
+
51
+ it('\'Check Answer\' label, \'Allow students to check answer\' checkbox label and checkbox should be displayed and by default it should be unchecked', () => {
52
+ autoScoredAdditionalSettings.checkAnswerLabel()
53
+ .verifyInnerText('Check answer');
54
+ autoScoredAdditionalSettings.allowStudentsToCheckAnswerLabel()
55
+ .verifyInnerText('Allow students to check answer');
56
+ autoScoredAdditionalSettings.allowStudentsToCheckAnswerCheckbox()
57
+ .should('not.be.checked');
58
+ if (questionType === 'multiple selection' || questionType === 'single selection') {
59
+ autoScoredAdditionalSettings.maximumCheckAnswerAttemptsInputField()
60
+ .should('not.exist');
61
+ } else {
62
+ autoScoredAdditionalSettings.maximumCheckAnswerAttemptsInputField()
63
+ .should('be.disabled');
64
+ }
65
+ });
66
+
67
+ it('When the user checks the \'Allow students to check answer\' checkbox, \'Maximum check answer attempts\' label and input field should be displayed', () => {
68
+ autoScoredAdditionalSettings.allowStudentsToCheckAnswerCheckbox()
69
+ .click()
70
+ .should('be.checked');
71
+ if (questionType === 'multipleSelection') {
72
+ autoScoredAdditionalSettings.maximumCheckAnswerAttemptsInputField()
73
+ .should('be.visible');
74
+ } else {
75
+ autoScoredAdditionalSettings.maximumCheckAnswerAttemptsInputField()
76
+ .should('be.enabled');
77
+ }
78
+
79
+ autoScoredAdditionalSettings.maximumCheckAnswerAttemptsLabel()
80
+ .verifyInnerText('Maximum check answer attempts');
81
+ });
82
+
83
+ it('CSS of \'Maximum check answer attempts\' input field', { tags: 'css' }, () => {
84
+ autoScoredAdditionalSettings.maximumCheckAnswerAttemptsLabel()
85
+ .verifyCSS(css.color.labels, css.fontSize.normal, css.fontWeight.semibold);
86
+ autoScoredAdditionalSettings.maximumCheckAnswerAttemptsInputField()
87
+ .should('have.css', 'background-color', css.color.transparent)
88
+ });
89
+
90
+ it('When the \'Maximum check answer attempts\' input field is empty and user switches to Preview tab, then the \'Check Answer\' button should be displayed and it should be enabled', () => {
91
+ //TODO: Need to discuss if we need add script to verify maximum input upto 999 and no decimal can be added
92
+ autoScoredAdditionalSettings.maximumCheckAnswerAttemptsInputField()
93
+ .should('have.value', '');
94
+ cy.log('Switching to Preview tab')
95
+ createQuestionBasePage.steps.switchToPreviewTab();
96
+ autoScoredPreviewBase.checkAnswerButton()
97
+ .should('be.enabled')
98
+ .and('be.visible');
99
+ });
100
+
101
+ it('CSS of Check Answer button', { tags: 'css' }, () => {
102
+ autoScoredPreviewBase.checkAnswerButton()
103
+ .verifyCSS(css.color.primaryBtn, css.fontSize.default, css.fontWeight.semibold)
104
+ .should('have.css', 'background-color', css.color.primaryBtnBg);
105
+ });
106
+
107
+ it('Accessibility of enabled Check Answer button', { tags: 'a11y' }, () => {
108
+ cy.checkAccessibility(autoScoredPreviewBase.checkAnswerButton());
109
+ });
110
+
111
+ it('When the user adds some value more than 0 in the \'Maximum check answer attempts\' input field, then the \'Check Answer\' button should become enabled in the Preview tab', () => {
112
+ cy.log('Pre step: Switching to Edit tab')
113
+ createQuestionBasePage.steps.switchToEditTab();
114
+ autoScoredAdditionalSettings.maximumCheckAnswerAttemptsInputField()
115
+ .clear()
116
+ .type('2')
117
+ .should('have.value', '2');
118
+ cy.log('Switching to Preview tab')
119
+ createQuestionBasePage.steps.switchToPreviewTab();
120
+ autoScoredPreviewBase.checkAnswerButton()
121
+ .should('not.have.class', 'Mui-disabled');
122
+ });
123
+
124
+ it('When the user unchecks the \'Allow students to check answer\' checkbox, then the \'Maximum check answer attempts\' input field should not be displayed and in Preview tab the \'Check Answer\' button should not be displayed', () => {
125
+ cy.log('Pre step: Switching to Edit tab')
126
+ createQuestionBasePage.steps.switchToEditTab();
127
+ autoScoredAdditionalSettings.allowStudentsToCheckAnswerCheckbox()
128
+ .click()
129
+ .should('not.be.checked');
130
+ if (questionType === 'multiple selection' || questionType === 'single selection') {
131
+ autoScoredAdditionalSettings.maximumCheckAnswerAttemptsInputField()
132
+ .should('not.exist');
133
+ } else {
134
+ autoScoredAdditionalSettings.maximumCheckAnswerAttemptsInputField()
135
+ .should('be.disabled');
136
+ }
137
+ cy.log('Switching to Preview tab')
138
+ createQuestionBasePage.steps.switchToPreviewTab();
139
+ autoScoredPreviewBase.checkAnswerButton()
140
+ .should('not.exist');
141
+ });
142
+ },
143
+
144
+ verifyDisabledCheckAnswerButtonWithCSSAnda11y: () => {
145
+ it('When the user reaches maximum check answer attempts, then the \'Check Answer\' button should become disabled', () => {
146
+ autoScoredPreviewBase.checkAnswerButton()
147
+ .should('be.disabled');
148
+ });
149
+
150
+ it('CSS of disabled \'Check Answer\' button', { tags: 'css' }, () => {
151
+ autoScoredPreviewBase.checkAnswerButton()
152
+ .verifyCSS(css.color.primaryBtnDisabled, css.fontSize.default, css.fontWeight.semibold);
153
+ });
154
+
155
+ it('Accessibility of disabled Check Answer button', { tags: 'a11y' }, () => {
156
+ cy.checkAccessibility(autoScoredPreviewBase.checkAnswerButton());
157
+ });
158
+ },
159
+
160
+ verifyCheckAnswerButtonFunctionalityWhenQuestionIsUnattempted: () => {
161
+ it('When the user has not attempted the question and clicks on the \'Check Answer\' button, then no changes should be displayed and the \'Check answer\' button should not get disabled', () => {
162
+ //comment: clicking on check answer button twice to verify if it stays in enabled state
163
+ autoScoredPreviewBase.checkAnswerButton()
164
+ .click();
165
+ autoScoredPreviewBase.checkAnswerButton()
166
+ .click();
167
+ autoScoredPreviewBase.correctIncorectAnswerLabel()
168
+ .should('not.exist');
169
+ autoScoredPreviewBase.correctIcon()
170
+ .should('not.exist');
171
+ autoScoredPreviewBase.incorrectIcon()
172
+ .should('not.exist');
173
+ autoScoredPreviewBase.checkAnswerButton()
174
+ .should('be.enabled');
175
+ });
176
+ }
177
+ }
178
+
179
+ export const autoScoredAdditionalSettings = {
180
+ ...selectors,
181
+ steps,
182
+ tests
183
+ }
@@ -0,0 +1,94 @@
1
+ import { previewScoringAndShowCorrectAnswerComponent } from "./previewScoringAndShowCorrectAnswerComponent";
2
+
3
+ const css = Cypress.env('css');
4
+ const selectors = {
5
+ correctIcon: () => cy.get('.icon-correct'),
6
+ incorrectIcon: () => cy.get('.icon-incorrect'),
7
+ correctIncorectAnswerLabel: () => cy.get('.answer-label-text'),
8
+ checkAnswerButton: () => cy.get('.check-answer-and-status-wrapper button'),
9
+ correctIncorrectAnswerBorder: () => cy.get('.edit-question-preview-wrapper [class*="correct-answer-border"]')
10
+ }
11
+
12
+ const steps = {
13
+ //V3 - This function should be updated in all files
14
+ checkAnswer: () => {
15
+ autoScoredPreviewBase.checkAnswerButton()
16
+ .click();
17
+ },
18
+
19
+ //V3 - This function should be updated in all files
20
+ verifyCheckAnswerButtonEnabled: () => {
21
+ autoScoredPreviewBase.checkAnswerButton()
22
+ .should('be.enabled');
23
+ },
24
+
25
+ //V3 - This function should be updated in all files
26
+ verifyCheckAnswerButtonDisabled: () => {
27
+ autoScoredPreviewBase.checkAnswerButton()
28
+ .should('be.disabled');
29
+ },
30
+
31
+ verifyCorrectIncorrectAnswerLabel: (labelText) => {
32
+ autoScoredPreviewBase.correctIncorectAnswerLabel()
33
+ .should('be.visible')
34
+ .verifyInnerText(`${labelText} answer`)
35
+ .parents('[class*="CorrectIncorrectAnswerstyles__AnswerLabelWrapper"]')
36
+ .find('.answer-label-icon')
37
+ .should('be.visible')
38
+ .should('have.text', `${labelText}-Icon`)
39
+ },
40
+
41
+ verifyCorrectAttemptBorder: () => {
42
+ autoScoredPreviewBase.correctIncorrectAnswerBorder()
43
+ .should('have.css', 'border', `1px solid ${css.color.correctAnswer}`);
44
+ },
45
+
46
+ verifyIncorrectAttemptBorder: () => {
47
+ autoScoredPreviewBase.correctIncorrectAnswerBorder()
48
+ .should('have.css', 'border', `1px solid ${css.color.incorrectAnswer}`);
49
+ },
50
+
51
+ verifyCorrectIncorrectBorderNotVisible: () => {
52
+ autoScoredPreviewBase.correctIncorrectAnswerBorder()
53
+ .should('have.css', 'border')
54
+ .and('match', /0px none/);
55
+ },
56
+
57
+ verifyCorrectIncorrectBorderNotExists: () => {
58
+ autoScoredPreviewBase.correctIncorrectAnswerBorder()
59
+ .should('not.exist');
60
+ },
61
+
62
+ verifyCorrectIncorrectAnswerLabelNotExists: () => {
63
+ autoScoredPreviewBase.correctIncorectAnswerLabel()
64
+ .should('not.exist');
65
+ },
66
+
67
+ verifyQuestionPreviewStateWhenShowCorrectAnswerIsUnchecked: () => {
68
+ cy.log('After deselecting Show correct answer checkbox, the question preview should return to the previous state');
69
+ previewScoringAndShowCorrectAnswerComponent.showCorrectAnswerCheckbox()
70
+ .click()
71
+ .should('not.be.checked');
72
+ autoScoredPreviewBase.correctIcon()
73
+ .should('not.exist');
74
+ autoScoredPreviewBase.incorrectIcon()
75
+ .should('not.exist');
76
+ autoScoredPreviewBase.correctIncorectAnswerLabel()
77
+ .should('not.exist');
78
+ autoScoredPreviewBase.correctIncorrectAnswerBorder()
79
+ .should('not.exist');
80
+ },
81
+
82
+ //V3 - This function should be updated in all files
83
+ verifyCorrectIncorrectIconsDoesNotExist: () => {
84
+ autoScoredPreviewBase.correctIcon()
85
+ .should('not.exist');
86
+ autoScoredPreviewBase.incorrectIcon()
87
+ .should('not.exist');
88
+ }
89
+ }
90
+
91
+ export const autoScoredPreviewBase = {
92
+ ...selectors,
93
+ steps
94
+ }
@@ -0,0 +1,195 @@
1
+ import { autoScoredPreviewBase } from "./autoScoredPreviewBase";
2
+ import { autoScoredSetCorrectAnswerSection } from "./autoScoredSetCorrectAnswerSection";
3
+ import { createQuestionBasePage } from "./createQuestionBasePage";
4
+ import { scoringSectionBase } from "./scoringSectionBase";
5
+ import { commonComponents } from "./commonComponents";
6
+ import { previewScoringAndShowCorrectAnswerComponent } from "./previewScoringAndShowCorrectAnswerComponent";
7
+ const css = Cypress.env('css');
8
+
9
+ const steps = {
10
+ correctIncorrectLabelAndBorderExists: (questionType) => {
11
+ switch (questionType) {
12
+ case 'multiple selection':
13
+ return true;
14
+ case 'single selection':
15
+ return false;
16
+ case 'fill in the gaps - text':
17
+ return true;
18
+ case 'fill in the gaps - dropdown':
19
+ return true;
20
+ case 'fill in the gaps - drag and drop':
21
+ return true;
22
+ case 'short text response':
23
+ return false;
24
+ case 'fill in the gaps - drag and drop':
25
+ return true;
26
+ case 'list matching':
27
+ return true;
28
+ case 'list ordering':
29
+ return true;
30
+ case 'list sorting':
31
+ return true;
32
+ case 'highlight':
33
+ return true;
34
+ case 'fill in the gaps over image - text':
35
+ return true;
36
+ case 'fill in the gaps over image - dropdown':
37
+ return true;
38
+ default:
39
+ throw new Error('Invalid question type');
40
+ }
41
+ },
42
+
43
+ verifyPreviewTabPointsBackgroundForIncorrectOrPartiallyCorrectAnswer: () => {
44
+ previewScoringAndShowCorrectAnswerComponent.previewScoreText()
45
+ .should('have.css', 'color', css.color.labels)
46
+ .and('not.have.css', 'background-color', css.color.correctAnswer);
47
+ },
48
+
49
+ verifyPreviewTabPointsBackgroundForCorrectAnswer: () => {
50
+ previewScoringAndShowCorrectAnswerComponent.previewScoreText()
51
+ .should('have.css', 'color', css.color.whiteText)
52
+ .and('have.css', 'background-color', css.color.correctAnswer);
53
+ }
54
+ }
55
+
56
+ const tests = {
57
+ verifyAutoScoredAllOrNothingPointsAndMinimumScoreAwardedLabelAndInputField: () => {
58
+ it('When the user selects \'Auto Scored\' option from the Scoring Type dropdown, then \'Points\' and \'Minimum score awarded (if attempted)\' labels and input fields should be displayed', () => {
59
+ scoringSectionBase.pointsLabel()
60
+ .verifyInnerText('Points')
61
+ .and('be.visible');
62
+ scoringSectionBase.pointsInputField()
63
+ .should('have.value', '')
64
+ .and('be.visible');
65
+ scoringSectionBase.minimumScoreIfAttemptedLabel()
66
+ .verifyInnerText('Minimum score awarded (if attempted)')
67
+ .and('be.visible');
68
+ scoringSectionBase.minimumScoreIfAttemptedInputField()
69
+ .should('have.value', '')
70
+ .and('be.visible');
71
+ });
72
+
73
+ it('CSS of \'Points\' and \'Minimum score awarded (if attempted)\' labels', { tags: 'css' }, () => {
74
+ scoringSectionBase.minimumScoreIfAttemptedLabel()
75
+ .verifyCSS(css.color.labels, css.fontSize.normal, css.fontWeight.semibold);
76
+ scoringSectionBase.pointsLabel()
77
+ .verifyCSS(css.color.labels, css.fontSize.normal, css.fontWeight.semibold);
78
+ });
79
+
80
+ it('Accessibility of \'Points\' and \'Minimum score awarded (if attempted)\' labels and input fields', { tags: 'a11y' }, () => {
81
+ cy.checkAccessibility(scoringSectionBase.minimumScoreIfAttemptedInputField());
82
+ cy.checkAccessibility(scoringSectionBase.pointsInputField());
83
+ });
84
+ },
85
+
86
+ verifyEditTabNonScoredScoringSectionContents: () => {
87
+ it('When the user selects \'Non Scored\' option from the Scoring Type dropdown, then the \'Set Correct Answer\' section should be displayed and \'Points\' input field should be displayed in disabled state with prefilled \'0\' points and \'Minimum score awarded (if attempted)\' input field should not be displayed', () => {
88
+ scoringSectionBase.steps.selectAScoringTypeFromScoringTypeDropdown('Non scored');
89
+ autoScoredSetCorrectAnswerSection.setCorrectAnswerLabel()
90
+ .should('be.visible');
91
+ autoScoredSetCorrectAnswerSection.correctTab()
92
+ .should('be.visible');
93
+ scoringSectionBase.pointsLabel()
94
+ .should('be.visible')
95
+ .verifyInnerText('Points');
96
+ scoringSectionBase.pointsInputField()
97
+ .should('have.value', '0')
98
+ .should('be.disabled');
99
+ scoringSectionBase.minimumScoreIfAttemptedInputField()
100
+ .should('not.exist');
101
+ });
102
+
103
+ it('Accessibility of disabled Points field', { tags: 'a11y' }, () => {
104
+ cy.checkAccessibility(scoringSectionBase.pointsLabel().parents('.set-correct-answer-points-wrapper'));
105
+ });
106
+ },
107
+
108
+ verifyShowCorrectAnswerAndPointsInPreviewTabWhenNoCorrectAnswerIsSet: () => {
109
+ it('When the user has not set correct answer option(s) and alloted points, \'Show correct answer\' and points should not be displayed in the preview tab', () => {
110
+ createQuestionBasePage.steps.switchToPreviewTab();
111
+ previewScoringAndShowCorrectAnswerComponent.showCorrectAnswerCheckbox()
112
+ .should('not.exist');
113
+ previewScoringAndShowCorrectAnswerComponent.previewScoreText()
114
+ .should('not.exist');
115
+ });
116
+ },
117
+
118
+ verifyCSSAndA11yOfCorrectAnswerIcon: () => {
119
+ it('Check CSS of correct answer icon', { tags: 'css' }, () => {
120
+ for (let index = 0; index < 2; index++) {
121
+ autoScoredPreviewBase.correctIcon()
122
+ .verifyPseudoClassBeforeProperty('color', css.color.correctAnswer);
123
+ };
124
+ });
125
+
126
+ it('Accessibility of correct answer icon', { tags: 'a11y' }, () => {
127
+ cy.checkAccessibility(autoScoredPreviewBase.correctIcon());
128
+ });
129
+ },
130
+
131
+ verifyCSSAndA11yOfFullScoreTextAndCorrectAnswerLabel: (questionType) => {
132
+ it('CSS of check score text full score state and Correct Answer label', { tags: 'css' }, () => {
133
+ previewScoringAndShowCorrectAnswerComponent.previewScoreText()
134
+ .should('have.css', 'color', css.color.primaryBtn)
135
+ .and('have.css', 'background-color', css.color.correctAnswer)
136
+ if (steps.correctIncorrectLabelAndBorderExists(questionType)) {
137
+ autoScoredPreviewBase.correctIncorectAnswerLabel()
138
+ .verifyCSS(css.color.correctAnswer, css.fontSize.normal, css.fontWeight.bold)
139
+ .parent()
140
+ .find('.answer-label-icon')
141
+ .verifyPseudoClassBeforeProperty('color', css.color.correctAnswer);
142
+ autoScoredPreviewBase.steps.verifyCorrectAttemptBorder();
143
+ } else {
144
+ autoScoredPreviewBase.correctIncorectAnswerLabel()
145
+ .should('not.exist');
146
+ autoScoredPreviewBase.correctIncorrectAnswerBorder()
147
+ .should('not.exist');
148
+ }
149
+ });
150
+
151
+ it('Accessibility of check score text full score state and Correct Answer label', { tags: 'a11y' }, () => {
152
+ cy.checkAccessibility(commonComponents.previewTabQuestionWrapper());
153
+ });
154
+ },
155
+
156
+ verifyCSSAndA11yOfIncorrectAnswerLabel: (questionType) => {
157
+ it('CSS of incorrect answer state', { tags: 'css' }, () => {
158
+ cy.log('Pre requisite: The user has attempted the question incorrectly')
159
+ cy.log('Pre step: Select show answer checkbox')
160
+ previewScoringAndShowCorrectAnswerComponent.showCorrectAnswerCheckbox()
161
+ .click()
162
+ .should('be.checked');
163
+ cy.log('Verifying CSS of incorrect crossmark icon')
164
+ autoScoredPreviewBase.incorrectIcon()
165
+ .eq(0)
166
+ .verifyPseudoClassBeforeProperty('color', css.color.incorrectAnswer);
167
+ if (steps.correctIncorrectLabelAndBorderExists(questionType)) {
168
+ autoScoredPreviewBase.correctIncorectAnswerLabel()
169
+ .verifyCSS(css.color.incorrectAnswer, css.fontSize.normal, css.fontWeight.bold)
170
+ .parent()
171
+ .find('.answer-label-icon')
172
+ .verifyPseudoClassBeforeProperty('color', css.color.incorrectAnswer);
173
+ autoScoredPreviewBase.steps.verifyIncorrectAttemptBorder();
174
+ } else {
175
+ autoScoredPreviewBase.correctIncorectAnswerLabel()
176
+ .should('not.exist');
177
+ autoScoredPreviewBase.correctIncorrectAnswerBorder()
178
+ .should('not.exist');
179
+ }
180
+ });
181
+
182
+ it('Accessibility of incorrect answer state', { tags: 'a11y' }, () => {
183
+ cy.checkAccessibility(commonComponents.previewTabQuestionWrapper());
184
+ cy.log('Post step: Deselect show answer checkbox')
185
+ previewScoringAndShowCorrectAnswerComponent.showCorrectAnswerCheckbox()
186
+ .click()
187
+ .should('not.be.checked');
188
+ });
189
+ }
190
+ }
191
+
192
+ export const autoScoredScoringSection = {
193
+ tests,
194
+ steps
195
+ }