itemengine-cypress-automation 1.0.119 → 1.0.120

Sign up to get free protection for your applications and to get access to all the features.
@@ -34,14 +34,14 @@ Cypress.Commands.add('lazyLoadPreviewQuestions', (count, retries = 5) => {
34
34
  cy.learnosityLoaderWait();
35
35
  })
36
36
 
37
- const migrationQuestionTypes = Cypress.env('migrationQuestionTypes');//["textEntryMath"]
37
+ const migrationQuestionTypes = Cypress.env('migrationQuestionTypes');//["textEntryMathImage"]
38
38
  const migrationQuestionTypesLrn = migrationQuestionTypes.map((questionType) => lrnQuestionTypesENUM[questionType]);
39
39
  let lrnMcqTypesRegex = /Multiple choice – standard|Multiple choice – multiple response|True or false|Multiple choice – block layout/;
40
40
 
41
41
  let lrnQuestionDataArr = [];
42
42
  let lrnGradingDataArr = [];
43
43
 
44
- let referenceIds = JSON.parse(Cypress.env('referenceIds')).slice(0, 100);//["eae30254-8637-4b59-a124-1b0caa68bc6e", "5acb0056-3d16-46d7-abbb-7a1ce08686ef", "6bd0f709-86c5-4e52-9510-9af3cd73e224"]
44
+ let referenceIds = JSON.parse(Cypress.env('referenceIds')).slice(0, 100);//["d526a378-de9e-4086-90ba-405057c48c3d", "9ee38abc-9c1c-4c10-9467-85f5823b7b17", "6521f6a7-4a9f-441f-8fc6-314ba7bf2386"]
45
45
 
46
46
  if (referenceIds.length > 0) {
47
47
  describe('Migration item check for MCQ questions', () => {
@@ -76,13 +76,11 @@ if (referenceIds.length > 0) {
76
76
  if (lrnMcqTypesRegex.test(currQuestionType)) {
77
77
  currQuestionType = lrnQuestionTypesENUM.mcq
78
78
  }
79
- if (currQuestionType.includes(lrnQuestionTypesENUM.textEntryMath)) {
80
- currQuestionType = lrnQuestionTypesENUM.textEntryMath
81
- }
82
79
  if (migrationQuestionTypesLrn.includes(currQuestionType)) {
83
80
  switch (currQuestionType) {
84
81
  case lrnQuestionTypesENUM.mcq: return extractLrnQuestionData.mcq(lrnQuestionDataArr, index);
85
82
  case lrnQuestionTypesENUM.textEntryMath: return extractLrnQuestionData.textEntryMath(lrnQuestionDataArr, index);
83
+ case lrnQuestionTypesENUM.textEntryMathImage: return extractLrnQuestionData.textEntryMathImage(lrnQuestionDataArr, index);
86
84
  default: throw new Error('Invalid lrn question type');
87
85
  }
88
86
  }
@@ -98,6 +96,7 @@ if (referenceIds.length > 0) {
98
96
  switch (questionType) {
99
97
  case 'mcq': return verifyIeQuestionData.mcq(questionData, index);
100
98
  case 'textEntryMath': return verifyIeQuestionData.textEntryMath(questionData, index);
99
+ case 'textEntryMathImage': return verifyIeQuestionData.textEntryMathImage(questionData, index);
101
100
  default: throw new Error('Invalid ngie question type');
102
101
  }
103
102
  });
@@ -116,6 +115,7 @@ if (referenceIds.length > 0) {
116
115
  switch (currQuestionType) {
117
116
  case lrnQuestionTypesENUM.mcq: return extractLrnQuestionData.mcqGrading(lrnGradingDataArr, index);
118
117
  case lrnQuestionTypesENUM.textEntryMath: return extractLrnQuestionData.textEntryMathGrading(lrnGradingDataArr, index);
118
+ case lrnQuestionTypesENUM.textEntryMathImage: return extractLrnQuestionData.textEntryMathImageGrading(lrnGradingDataArr, index);
119
119
  default: throw new Error('Invalid lrn question type');
120
120
  }
121
121
  }
@@ -133,6 +133,7 @@ if (referenceIds.length > 0) {
133
133
  switch (questionType) {
134
134
  case 'mcq': return verifyIeQuestionData.mcqGrading(questionData, index);
135
135
  case 'textEntryMath': return verifyIeQuestionData.textEntryMathGrading(questionData, index);
136
+ case 'textEntryMathImage': return verifyIeQuestionData.textEntryMathImageGrading(questionData, index);
136
137
  default: throw new Error('Invalid ngie question type');
137
138
  }
138
139
  });
@@ -76,13 +76,11 @@ if (referenceIds.length > 0) {
76
76
  if (lrnMcqTypesRegex.test(currQuestionType)) {
77
77
  currQuestionType = lrnQuestionTypesENUM.mcq
78
78
  }
79
- if (currQuestionType.includes(lrnQuestionTypesENUM.textEntryMath)) {
80
- currQuestionType = lrnQuestionTypesENUM.textEntryMath
81
- }
82
79
  if (migrationQuestionTypesLrn.includes(currQuestionType)) {
83
80
  switch (currQuestionType) {
84
81
  case lrnQuestionTypesENUM.mcq: return extractLrnQuestionData.mcq(lrnQuestionDataArr, index);
85
82
  case lrnQuestionTypesENUM.textEntryMath: return extractLrnQuestionData.textEntryMath(lrnQuestionDataArr, index);
83
+ case lrnQuestionTypesENUM.textEntryMathImage: return extractLrnQuestionData.textEntryMathImage(lrnQuestionDataArr, index);
86
84
  default: throw new Error('Invalid lrn question type');
87
85
  }
88
86
  }
@@ -98,6 +96,7 @@ if (referenceIds.length > 0) {
98
96
  switch (questionType) {
99
97
  case 'mcq': return verifyIeQuestionData.mcq(questionData, index);
100
98
  case 'textEntryMath': return verifyIeQuestionData.textEntryMath(questionData, index);
99
+ case 'textEntryMathImage': return verifyIeQuestionData.textEntryMathImage(questionData, index);
101
100
  default: throw new Error('Invalid ngie question type');
102
101
  }
103
102
  });
@@ -116,6 +115,7 @@ if (referenceIds.length > 0) {
116
115
  switch (currQuestionType) {
117
116
  case lrnQuestionTypesENUM.mcq: return extractLrnQuestionData.mcqGrading(lrnGradingDataArr, index);
118
117
  case lrnQuestionTypesENUM.textEntryMath: return extractLrnQuestionData.textEntryMathGrading(lrnGradingDataArr, index);
118
+ case lrnQuestionTypesENUM.textEntryMathImage: return extractLrnQuestionData.textEntryMathImageGrading(lrnGradingDataArr, index);
119
119
  default: throw new Error('Invalid lrn question type');
120
120
  }
121
121
  }
@@ -133,6 +133,7 @@ if (referenceIds.length > 0) {
133
133
  switch (questionType) {
134
134
  case 'mcq': return verifyIeQuestionData.mcqGrading(questionData, index);
135
135
  case 'textEntryMath': return verifyIeQuestionData.textEntryMathGrading(questionData, index);
136
+ case 'textEntryMathImage': return verifyIeQuestionData.textEntryMathImageGrading(questionData, index);
136
137
  default: throw new Error('Invalid ngie question type');
137
138
  }
138
139
  });
@@ -76,13 +76,11 @@ if (referenceIds.length > 0) {
76
76
  if (lrnMcqTypesRegex.test(currQuestionType)) {
77
77
  currQuestionType = lrnQuestionTypesENUM.mcq
78
78
  }
79
- if (currQuestionType.includes(lrnQuestionTypesENUM.textEntryMath)) {
80
- currQuestionType = lrnQuestionTypesENUM.textEntryMath
81
- }
82
79
  if (migrationQuestionTypesLrn.includes(currQuestionType)) {
83
80
  switch (currQuestionType) {
84
81
  case lrnQuestionTypesENUM.mcq: return extractLrnQuestionData.mcq(lrnQuestionDataArr, index);
85
82
  case lrnQuestionTypesENUM.textEntryMath: return extractLrnQuestionData.textEntryMath(lrnQuestionDataArr, index);
83
+ case lrnQuestionTypesENUM.textEntryMathImage: return extractLrnQuestionData.textEntryMathImage(lrnQuestionDataArr, index);
86
84
  default: throw new Error('Invalid lrn question type');
87
85
  }
88
86
  }
@@ -98,6 +96,7 @@ if (referenceIds.length > 0) {
98
96
  switch (questionType) {
99
97
  case 'mcq': return verifyIeQuestionData.mcq(questionData, index);
100
98
  case 'textEntryMath': return verifyIeQuestionData.textEntryMath(questionData, index);
99
+ case 'textEntryMathImage': return verifyIeQuestionData.textEntryMathImage(questionData, index);
101
100
  default: throw new Error('Invalid ngie question type');
102
101
  }
103
102
  });
@@ -116,6 +115,7 @@ if (referenceIds.length > 0) {
116
115
  switch (currQuestionType) {
117
116
  case lrnQuestionTypesENUM.mcq: return extractLrnQuestionData.mcqGrading(lrnGradingDataArr, index);
118
117
  case lrnQuestionTypesENUM.textEntryMath: return extractLrnQuestionData.textEntryMathGrading(lrnGradingDataArr, index);
118
+ case lrnQuestionTypesENUM.textEntryMathImage: return extractLrnQuestionData.textEntryMathImageGrading(lrnGradingDataArr, index);
119
119
  default: throw new Error('Invalid lrn question type');
120
120
  }
121
121
  }
@@ -133,6 +133,7 @@ if (referenceIds.length > 0) {
133
133
  switch (questionType) {
134
134
  case 'mcq': return verifyIeQuestionData.mcqGrading(questionData, index);
135
135
  case 'textEntryMath': return verifyIeQuestionData.textEntryMathGrading(questionData, index);
136
+ case 'textEntryMathImage': return verifyIeQuestionData.textEntryMathImageGrading(questionData, index);
136
137
  default: throw new Error('Invalid ngie question type');
137
138
  }
138
139
  });
@@ -76,13 +76,11 @@ if (referenceIds.length > 0) {
76
76
  if (lrnMcqTypesRegex.test(currQuestionType)) {
77
77
  currQuestionType = lrnQuestionTypesENUM.mcq
78
78
  }
79
- if (currQuestionType.includes(lrnQuestionTypesENUM.textEntryMath)) {
80
- currQuestionType = lrnQuestionTypesENUM.textEntryMath
81
- }
82
79
  if (migrationQuestionTypesLrn.includes(currQuestionType)) {
83
80
  switch (currQuestionType) {
84
81
  case lrnQuestionTypesENUM.mcq: return extractLrnQuestionData.mcq(lrnQuestionDataArr, index);
85
82
  case lrnQuestionTypesENUM.textEntryMath: return extractLrnQuestionData.textEntryMath(lrnQuestionDataArr, index);
83
+ case lrnQuestionTypesENUM.textEntryMathImage: return extractLrnQuestionData.textEntryMathImage(lrnQuestionDataArr, index);
86
84
  default: throw new Error('Invalid lrn question type');
87
85
  }
88
86
  }
@@ -98,6 +96,7 @@ if (referenceIds.length > 0) {
98
96
  switch (questionType) {
99
97
  case 'mcq': return verifyIeQuestionData.mcq(questionData, index);
100
98
  case 'textEntryMath': return verifyIeQuestionData.textEntryMath(questionData, index);
99
+ case 'textEntryMathImage': return verifyIeQuestionData.textEntryMathImage(questionData, index);
101
100
  default: throw new Error('Invalid ngie question type');
102
101
  }
103
102
  });
@@ -116,6 +115,7 @@ if (referenceIds.length > 0) {
116
115
  switch (currQuestionType) {
117
116
  case lrnQuestionTypesENUM.mcq: return extractLrnQuestionData.mcqGrading(lrnGradingDataArr, index);
118
117
  case lrnQuestionTypesENUM.textEntryMath: return extractLrnQuestionData.textEntryMathGrading(lrnGradingDataArr, index);
118
+ case lrnQuestionTypesENUM.textEntryMathImage: return extractLrnQuestionData.textEntryMathImageGrading(lrnGradingDataArr, index);
119
119
  default: throw new Error('Invalid lrn question type');
120
120
  }
121
121
  }
@@ -133,6 +133,7 @@ if (referenceIds.length > 0) {
133
133
  switch (questionType) {
134
134
  case 'mcq': return verifyIeQuestionData.mcqGrading(questionData, index);
135
135
  case 'textEntryMath': return verifyIeQuestionData.textEntryMathGrading(questionData, index);
136
+ case 'textEntryMathImage': return verifyIeQuestionData.textEntryMathImageGrading(questionData, index);
136
137
  default: throw new Error('Invalid ngie question type');
137
138
  }
138
139
  });
@@ -76,13 +76,11 @@ if (referenceIds.length > 0) {
76
76
  if (lrnMcqTypesRegex.test(currQuestionType)) {
77
77
  currQuestionType = lrnQuestionTypesENUM.mcq
78
78
  }
79
- if (currQuestionType.includes(lrnQuestionTypesENUM.textEntryMath)) {
80
- currQuestionType = lrnQuestionTypesENUM.textEntryMath
81
- }
82
79
  if (migrationQuestionTypesLrn.includes(currQuestionType)) {
83
80
  switch (currQuestionType) {
84
81
  case lrnQuestionTypesENUM.mcq: return extractLrnQuestionData.mcq(lrnQuestionDataArr, index);
85
82
  case lrnQuestionTypesENUM.textEntryMath: return extractLrnQuestionData.textEntryMath(lrnQuestionDataArr, index);
83
+ case lrnQuestionTypesENUM.textEntryMathImage: return extractLrnQuestionData.textEntryMathImage(lrnQuestionDataArr, index);
86
84
  default: throw new Error('Invalid lrn question type');
87
85
  }
88
86
  }
@@ -98,6 +96,7 @@ if (referenceIds.length > 0) {
98
96
  switch (questionType) {
99
97
  case 'mcq': return verifyIeQuestionData.mcq(questionData, index);
100
98
  case 'textEntryMath': return verifyIeQuestionData.textEntryMath(questionData, index);
99
+ case 'textEntryMathImage': return verifyIeQuestionData.textEntryMathImage(questionData, index);
101
100
  default: throw new Error('Invalid ngie question type');
102
101
  }
103
102
  });
@@ -116,6 +115,7 @@ if (referenceIds.length > 0) {
116
115
  switch (currQuestionType) {
117
116
  case lrnQuestionTypesENUM.mcq: return extractLrnQuestionData.mcqGrading(lrnGradingDataArr, index);
118
117
  case lrnQuestionTypesENUM.textEntryMath: return extractLrnQuestionData.textEntryMathGrading(lrnGradingDataArr, index);
118
+ case lrnQuestionTypesENUM.textEntryMathImage: return extractLrnQuestionData.textEntryMathImageGrading(lrnGradingDataArr, index);
119
119
  default: throw new Error('Invalid lrn question type');
120
120
  }
121
121
  }
@@ -133,6 +133,7 @@ if (referenceIds.length > 0) {
133
133
  switch (questionType) {
134
134
  case 'mcq': return verifyIeQuestionData.mcqGrading(questionData, index);
135
135
  case 'textEntryMath': return verifyIeQuestionData.textEntryMathGrading(questionData, index);
136
+ case 'textEntryMathImage': return verifyIeQuestionData.textEntryMathImageGrading(questionData, index);
136
137
  default: throw new Error('Invalid ngie question type');
137
138
  }
138
139
  });
@@ -10,6 +10,7 @@ export const lrnPage = {
10
10
  clozeMathResponse: () => cy.get('.lrn_cloze_response'),
11
11
  clozeMathCorrectAnswerMathMl: () => cy.get('.lrn_correctAnswerList math'),
12
12
  correctAnswersResponseText: () => cy.get('.lrn_responseText'),
13
+ backgroundCanvasImage: () => cy.get('.lrn_imagecloze_image'),
13
14
  steps: {
14
15
  checkShowAnswersToggle: () => {
15
16
  lrnPage.showAnswersToggle()
@@ -183,8 +184,78 @@ export const extractLrnQuestionData = {
183
184
  });
184
185
  obj.correctAnswersMathMl = correctAnswersMathMl;
185
186
  obj.correctAnswersText = correctAnswersText;
186
- //extract math outerhtml
187
- //extract response text and outer html, verify it with the other one
187
+ //response numeration in show answers
188
+ });
189
+ lrnGradingDataArr.push(obj);
190
+ },
191
+
192
+ textEntryMathImage: (lrnQuestionDataArr, index) => {
193
+ let obj = {};
194
+ cy.log(`Extracting the question instructions, question and response count from question ${index}`);
195
+ obj.questionIndex = index;
196
+ obj.questionType = 'textEntryMathImage';
197
+ lrnPage.questionWrapper()
198
+ .eq(index)
199
+ .within(() => {
200
+ lrnPage.questionInstructions()
201
+ .then(($ins) => {
202
+ let text = $ins[0].innerText;
203
+ obj.previewQuestionInstructions = text;
204
+ });
205
+ lrnPage.clozeMathResponse()
206
+ .then(($responseFields) => {
207
+ obj.previewResponseCount = $responseFields.length;
208
+ });
209
+ lrnPage.backgroundCanvasImage()
210
+ .then(($element) => {
211
+ let bgImageAltText = $element[0].alt;
212
+ obj.bgImageAltText = bgImageAltText;
213
+ });
214
+ });
215
+ lrnQuestionDataArr.push(obj);
216
+ },
217
+
218
+ textEntryMathImageGrading: (lrnGradingDataArr, index) => {
219
+ let obj = {};
220
+ cy.log(`Extracting the question instructions, question, response count and correct responses from question ${index}`);
221
+ obj.questionIndex = index;
222
+ obj.questionType = 'textEntryMathImage';
223
+ lrnPage.questionWrapper()
224
+ .eq(index)
225
+ .within(() => {
226
+ lrnPage.questionInstructions()
227
+ .then(($ins) => {
228
+ let text = $ins[0].innerText;
229
+ obj.gradingQuestionInstructions = text;
230
+ });
231
+ lrnPage.clozeMathResponseWrapper()
232
+ .then(($question) => {
233
+ let innerText = $question[0].innerText;
234
+ obj.gradingQuestion = innerText;
235
+ });
236
+ lrnPage.clozeMathResponse()
237
+ .then(($responseFields) => {
238
+ obj.gradingResponseCount = $responseFields.length;
239
+ });
240
+ const correctAnswersMathMl = [];
241
+ const correctAnswersText = [];
242
+ lrnPage.clozeMathCorrectAnswerMathMl()
243
+ .each(($element) => {
244
+ let outerHtml = $element[0].outerHTML;
245
+ correctAnswersMathMl.push(outerHtml);
246
+ });
247
+ lrnPage.correctAnswersResponseText()
248
+ .each(($element) => {
249
+ let innerText = $element[0].innerText;
250
+ correctAnswersText.push(innerText);
251
+ });
252
+ lrnPage.backgroundCanvasImage()
253
+ .then(($element) => {
254
+ let bgImageAltText = $element[0].alt;
255
+ obj.bgImageAltText = bgImageAltText;
256
+ });
257
+ obj.correctAnswersMathMl = correctAnswersMathMl;
258
+ obj.correctAnswersText = correctAnswersText;
188
259
  });
189
260
  lrnGradingDataArr.push(obj);
190
261
  },
@@ -1,6 +1,7 @@
1
1
  const lrnQuestionTypesENUM = {
2
2
  mcq: 'mcq',
3
3
  textEntryMath: 'Cloze math',
4
+ textEntryMathImage: 'Cloze math with image',
4
5
  essayResponseMath: 'Math essay with rich text',
5
6
  singleSelection: 'Multiple choice – standard',
6
7
  multipleSelection: 'Multiple choice – multiple response',
@@ -8,9 +8,10 @@ export const iePage = {
8
8
  questionWrapper: () => cy.get('.ngie-question-wrapper'),
9
9
  barsPreloader: () => cy.get('[id="question-item-instruction-loader"]'),
10
10
  previewQuestionTextWrapper: () => cy.get('.preview-question-text-wrapper'),
11
- textEntryMathResponseWrapper: () => cy.get('.preview-question-text-wrapper .cloze-response-wrapper '),
11
+ textEntryMathResponseWrapper: () => cy.get('.cloze-math-preview-wrapper .cloze-math-response-input-field'),
12
12
  textEntryMathCorrectAnswerMathMl: () => cy.get('.ngie_latex math'),
13
13
  textEntryMathCorrectAnswersResponseText: () => cy.get('.ngie_latex'),
14
+ backgroundCanvasImage: () => cy.get('.background-image'),
14
15
  };
15
16
 
16
17
  export const verifyIeQuestionData = {
@@ -70,7 +71,6 @@ export const verifyIeQuestionData = {
70
71
  });
71
72
  },
72
73
 
73
-
74
74
  textEntryMath: (expectedQuestionData, index) => {
75
75
  cy.get('.cloze-math-preview-wrapper')
76
76
  .eq(index)
@@ -92,6 +92,7 @@ export const verifyIeQuestionData = {
92
92
  utilities.verifyInnerText(singleSelectionPage.questionInstructionsText(), expectedQuestionData.gradingQuestionInstructions);
93
93
  iePage.previewQuestionTextWrapper()
94
94
  .should('exist');
95
+ //Not working due to numeration being displayed above responses in IE
95
96
  // utilities.verifyInnerText(iePage.previewQuestionTextWrapper(), expectedQuestionData.gradingQuestion);
96
97
  iePage.textEntryMathResponseWrapper()
97
98
  .then(($resposneWrapper) => {
@@ -108,6 +109,52 @@ export const verifyIeQuestionData = {
108
109
  });
109
110
  },
110
111
 
112
+ textEntryMathImage: (expectedQuestionData, index) => {
113
+ //Limitations: Verifying text content of the question wrapper as in ie numeration is displayed in the question wrapper section as well
114
+ //Correct answer numeration, as lrn has an option to not select numeration but still numeration is displayed in the correct ans but in that case numeration in not displayed in IE
115
+ cy.get('.cloze-math-preview-wrapper .label-image-with-text-preview')
116
+ .eq(index)
117
+ .parents('.ngie-question-wrapper')
118
+ .within(() => {
119
+ utilities.verifyInnerText(singleSelectionPage.questionInstructionsText(), expectedQuestionData.previewQuestionInstructions);
120
+ // Not working due to numeration being displayed above responses in IE
121
+ // utilities.verifyInnerText(iePage.previewQuestionTextWrapper(), expectedQuestionData.previewQuestion);
122
+ iePage.textEntryMathResponseWrapper()
123
+ .then(($resposneWrapper) => {
124
+ expect($resposneWrapper.length).to.be.eq(expectedQuestionData.previewResponseCount);
125
+ });
126
+ iePage.backgroundCanvasImage()
127
+ .then(($element) => {
128
+ expect($element[0].alt).to.be.eq(expectedQuestionData.bgImageAltText);
129
+ });
130
+ });
131
+ },
132
+
133
+ textEntryMathImageGrading: (expectedQuestionData, index) => {
134
+ cy.get('.cloze-math-preview-wrapper .label-image-with-text-preview')
135
+ .eq(index)
136
+ .parents('.ngie-question-wrapper')
137
+ .within(() => {
138
+ utilities.verifyInnerText(singleSelectionPage.questionInstructionsText(), expectedQuestionData.gradingQuestionInstructions);
139
+ iePage.textEntryMathResponseWrapper()
140
+ .then(($resposneWrapper) => {
141
+ expect($resposneWrapper.length).to.be.eq(expectedQuestionData.gradingResponseCount);
142
+ });
143
+ iePage.textEntryMathCorrectAnswerMathMl()
144
+ .each(($element, index) => {
145
+ expect($element.get(0).outerHTML).to.deep.eq(expectedQuestionData.correctAnswersMathMl[index]);
146
+ });
147
+ iePage.textEntryMathCorrectAnswersResponseText()
148
+ .each(($element, index) => {
149
+ utilities.verifyInnerText(cy.wrap($element), expectedQuestionData.correctAnswersText[index]);
150
+ });
151
+ iePage.backgroundCanvasImage()
152
+ .then(($element) => {
153
+ expect($element[0].alt).to.be.eq(expectedQuestionData.bgImageAltText);
154
+ });
155
+ });
156
+ },
157
+
111
158
  essayResponseMath: (expectedQuestionData, index) => {
112
159
  cy.get('.ngie-essay-response-math')
113
160
  .eq(index)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itemengine-cypress-automation",
3
- "version": "1.0.119",
3
+ "version": "1.0.120",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {