itemengine-cypress-automation 1.0.180-essayResponseLazyLoadingFix-63cd8a3.0 → 1.0.181-figDropdown-5a8309d.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,6 +13,7 @@ export const lrnPage = {
13
13
  correctAnswersResponseText: () => cy.get('.lrn_correctAnswerList li'),
14
14
  backgroundCanvasImage: () => cy.get('.lrn_imagecloze_image'),
15
15
  essayResponseTextArea: () => cy.get('.lrn_texteditor_editable'),
16
+ essayResponseResponseWrapper: () => cy.get('.lrn_response_wrapper'),
16
17
  essayResponseToolbarButton: () => cy.get('[aria-label="Text controls"] button.lrn_btn'),
17
18
  essayResponseFooter: () => cy.get('.lrn-toolbar-footer'),
18
19
  essayResponseToolbarWordCountWrapper: () => cy.get('.lrn_toolbar_right'),
@@ -283,7 +284,7 @@ export const extractLrnQuestionData = {
283
284
  obj.textAreaPlaceholder = textAreaPlaceholder;
284
285
  });
285
286
  let toolbarButtons = [];
286
- lrnPage.essayResponseTextArea()
287
+ lrnPage.essayResponseResponseWrapper()
287
288
  .then(($element) => {
288
289
  if ($element[0].innerHTML.includes('type="button"')) {
289
290
  lrnPage.essayResponseToolbarButton()
@@ -482,7 +483,7 @@ export const extractLrnQuestionData = {
482
483
 
483
484
  figText: (lrnQuestionDataArr, index) => {
484
485
  let obj = {};
485
- cy.log(`Extracting the question instructions, question and response count from question ${index}`);
486
+ cy.log(`Extracting the question instructions, question, response count, response field properties from question ${index}`);
486
487
  obj.questionIndex = index;
487
488
  obj.questionType = 'figText';
488
489
  lrnPage.steps.extractQuestionInstructions(obj, index);
@@ -529,7 +530,7 @@ export const extractLrnQuestionData = {
529
530
 
530
531
  figTextGrading: (lrnQuestionDataArr, index) => {
531
532
  let obj = {};
532
- cy.log(`Extracting the question instructions, question and response count from question ${index}`);
533
+ cy.log(`Extracting the question instructions, question, response count, response field properties from question ${index}`);
533
534
  obj.questionIndex = index;
534
535
  obj.questionType = 'figText';
535
536
  lrnPage.steps.extractQuestionInstructions(obj, index);
@@ -793,7 +794,111 @@ export const extractLrnQuestionData = {
793
794
  obj.correctAnswers = correctAnswers;
794
795
  });
795
796
  lrnGradingDataArr.push(obj);
796
- }
797
+ },
798
+
799
+ figDropdown: (lrnQuestionDataArr, index) => {
800
+ let obj = {};
801
+ cy.log(`Extracting the question instructions, question and response count from question ${index}`);
802
+ obj.questionIndex = index;
803
+ obj.questionType = 'figDropdown';
804
+ lrnPage.steps.extractQuestionInstructions(obj, index);
805
+ lrnPage.questionWrapper()
806
+ .eq(index)
807
+ .within(() => {
808
+ lrnPage.questionContainerPreviewTab()
809
+ .then(($question) => {
810
+ let innerText = $question[0].innerText;
811
+ innerText = innerText.replace(/\n/g, '');
812
+ //getting rid of the   and ​
813
+ innerText = innerText.replace(/\u00a0/g, ' ');
814
+ innerText = innerText.replace(/\u200b/g, '');
815
+ innerText = innerText.trim()
816
+ obj.previewQuestion = innerText;
817
+ });
818
+ lrnPage.clozeResponse()
819
+ .then(($responseFields) => {
820
+ obj.previewResponseCount = $responseFields.length;
821
+ });
822
+ let responses = [];
823
+ lrnPage.clozeResponse()
824
+ .each(($responseField) => {
825
+ let responseObj = {}
826
+ responseObj.placeholder = $responseField[0].placeholder;
827
+ responseObj.spellcheck = $responseField[0].spellcheck;
828
+ // responseObj.ariaLabel = $responseField[0].ariaLabel;
829
+ responses.push(responseObj);
830
+ });
831
+ obj.responses = responses;
832
+ let allDropdownOptions = [];
833
+ lrnPage.clozeResponse()
834
+ .each(($element) => {
835
+ let currentOptions = [];
836
+ cy.wrap($element)
837
+ .find('[role="option"]')
838
+ .each(($element, index) => {
839
+ if (index !== 0) {
840
+ let innerText = $element[0].innerText;
841
+ currentOptions.push(innerText);
842
+ }
843
+ }).then(() => {
844
+ allDropdownOptions.push(currentOptions);
845
+ });
846
+ });
847
+ obj.allDropdownOptions = allDropdownOptions;
848
+ });
849
+ lrnQuestionDataArr.push(obj);
850
+ },
851
+
852
+ figDropdownGrading: (lrnQuestionDataArr, index) => {
853
+ let obj = {};
854
+ cy.log(`Extracting the question instructions, question and response count from question ${index}`);
855
+ obj.questionIndex = index;
856
+ obj.questionType = 'figDropdown';
857
+ lrnPage.steps.extractQuestionInstructions(obj, index);
858
+ lrnPage.questionWrapper()
859
+ .eq(index)
860
+ .within(() => {
861
+ lrnPage.questionContainerPreviewTab()
862
+ .then(($question) => {
863
+ let innerText = $question[0].innerText;
864
+ innerText = innerText.replace(/\n/g, '');
865
+ //getting rid of the   and ​
866
+ innerText = innerText.replace(/\u00a0/g, ' ');
867
+ innerText = innerText.replace(/\u200b/g, '');
868
+ innerText = innerText.trim()
869
+ obj.previewQuestion = innerText;
870
+ });
871
+ cy.get('.lrn_clozedropdown_answer')
872
+ .then(($responseFields) => {
873
+ obj.previewResponseCount = $responseFields.length;
874
+ });
875
+ let correctAnswers = [];
876
+ cy.get('.lrn_correctAnswerList li')
877
+ .each(($answers) => {
878
+ let answerData = {}
879
+ cy.wrap($answers)
880
+ .within(() => {
881
+ cy.get('.lrn_responseIndex')
882
+ .then(($element) => {
883
+ let answerNumeration = $element[0].innerText;
884
+ answerData.answerNumeration = answerNumeration;
885
+ });
886
+ let options = []
887
+ cy.get('.lrn_responseText')
888
+ .each(($option) => {
889
+ let optionData = {}
890
+ let innerText = $option[0].innerText;
891
+ optionData.innerText = innerText;
892
+ options.push(optionData);
893
+ });
894
+ answerData.options = options
895
+ });
896
+ correctAnswers.push(answerData);
897
+ });
898
+ obj.correctAnswers = correctAnswers;
899
+ });
900
+ lrnQuestionDataArr.push(obj);
901
+ },
797
902
 
798
903
  /* singleSelection: (lrnQuestionDataArr, index) => {
799
904
  let obj = {};
@@ -13,7 +13,8 @@ const lrnQuestionTypesENUM = {
13
13
  shortTextResponse: 'Short text',
14
14
  uploadResponse: 'File upload',
15
15
  figDragAndDrop: 'Cloze with drag & drop',
16
- contentBlocks: 'Passage'
16
+ contentBlocks: 'Passage',
17
+ figDropdown: 'Cloze with drop down'
17
18
  }
18
19
 
19
20
  export default lrnQuestionTypesENUM;
@@ -9,6 +9,7 @@ const migrationQuestionTypes = Cypress.env('migrationQuestionTypes');//["textEnt
9
9
  const migrationQuestionTypesLrn = migrationQuestionTypes.map((questionType) => lrnQuestionTypesENUM[questionType]);
10
10
  let lrnMcqTypesRegex = /Multiple choice – standard|Multiple choice – multiple response|True or false|Multiple choice – block layout/;
11
11
  let lrnEssayResponseRegex = /Math essay with rich text|Essay with rich text/
12
+ let lrnFigDropdownRegex = /Cloze with drop down|Cloze dropdown/
12
13
 
13
14
 
14
15
  let lrnQuestionDataArr = [];
@@ -28,6 +29,7 @@ const extractLrnPreviewData = (currQuestionType, lrnQuestionDataArr, index) => {
28
29
  case lrnQuestionTypesENUM.uploadResponse: return extractLrnQuestionData.uploadResponse(lrnQuestionDataArr, index);
29
30
  case lrnQuestionTypesENUM.figDragAndDrop: return extractLrnQuestionData.figDragAndDrop(lrnQuestionDataArr, index);
30
31
  case lrnQuestionTypesENUM.contentBlocks: return extractLrnQuestionData.contentBlocks(lrnQuestionDataArr, index);
32
+ case lrnQuestionTypesENUM.figDropdown: return extractLrnQuestionData.figDropdown(lrnQuestionDataArr, index);
31
33
  default: throw new Error('Invalid lrn question type');
32
34
  }
33
35
  }
@@ -46,6 +48,7 @@ const verifyIePreviewData = (questionType, questionData, index) => {
46
48
  case 'uploadResponse': return verifyIeQuestionData.uploadResponse(questionData, index);
47
49
  case 'figDragAndDrop': return verifyIeQuestionData.figDragAndDrop(questionData, index);
48
50
  case 'contentBlocks': return verifyIeQuestionData.contentBlocks(questionData, index);
51
+ case 'figDropdown': return verifyIeQuestionData.figDropdown(questionData, index);
49
52
  default: throw new Error('Invalid ngie question type');
50
53
  }
51
54
  }
@@ -62,7 +65,9 @@ const extractLrnGradingData = (currQuestionType, lrnGradingDataArr, index) => {
62
65
  case lrnQuestionTypesENUM.figDragAndDrop: return extractLrnQuestionData.figDragAndDropGrading(lrnGradingDataArr, index);
63
66
  case lrnQuestionTypesENUM.essayResponse: return cy.log('Manually Graded Question Type');
64
67
  case lrnQuestionTypesENUM.essayResponseBasic: return cy.log('Manually Graded Question Type');
68
+ case lrnQuestionTypesENUM.drawingResponse: return cy.log('Manually Graded Question Type');
65
69
  case lrnQuestionTypesENUM.contentBlocks: return cy.log('Resource and tool');
70
+ case lrnQuestionTypesENUM.figDropdown: return extractLrnQuestionData.figDropdownGrading(lrnGradingDataArr, index);
66
71
  default: throw new Error('Invalid lrn question type');
67
72
  }
68
73
  }
@@ -80,6 +85,8 @@ const verifyIeGradingData = (questionType, questionData, index) => {
80
85
  case 'contentBlocks': return cy.log('Resource and tool');
81
86
  case 'essayResponse': return cy.log('Manually Graded Question Type');
82
87
  case 'essayResponseBasic': return cy.log('Manually Graded Question Type');
88
+ case 'drawingResponse': return cy.log('Manually Graded Question Type');
89
+ case 'figDropdown': return verifyIeQuestionData.figDropdownGrading(questionData, index);
83
90
  default: throw new Error('Invalid ngie question type');
84
91
  }
85
92
  }
@@ -123,6 +130,9 @@ export const migrationScript = (referenceIds) => {
123
130
  ;
124
131
  currQuestionType = lrnQuestionTypesENUM.essayResponse;
125
132
  }
133
+ if (lrnFigDropdownRegex.test(currQuestionType)) {
134
+ currQuestionType = lrnQuestionTypesENUM.figDropdown;
135
+ }
126
136
  if (migrationQuestionTypesLrn.includes(currQuestionType)) {
127
137
  extractLrnPreviewData(currQuestionType, lrnQuestionDataArr, index)
128
138
  }
@@ -154,6 +164,9 @@ export const migrationScript = (referenceIds) => {
154
164
  if (migrationQuestionTypesLrn.includes(currQuestionType)) {
155
165
  extractLrnGradingData(currQuestionType, lrnGradingDataArr, index);
156
166
  }
167
+ if (migrationQuestionTypesLrn.includes(currQuestionType)) {
168
+ currQuestionType = lrnQuestionTypesENUM.figDropdown;
169
+ }
157
170
  });
158
171
  }
159
172
  });
@@ -1,4 +1,4 @@
1
- import { essayResponsePage, fillInTheGapsDragAndDropPage, contentBlocksPage, fillInTheGapsTextPage, multipleSelectionPage, textEntryMathPage, uploadResponsePage } from "../../pages";
1
+ import { essayResponsePage, fillInTheGapsDragAndDropPage, contentBlocksPage, fillInTheGapsTextPage, multipleSelectionPage, textEntryMathPage, uploadResponsePage, fillInTheGapsDropdownPage } from "../../pages";
2
2
  import { draggableOptionContainer, fillInTheGapsDragAndDropCommonComponents } from "../../pages/components";
3
3
  import { singleSelectionPage } from "../../pages/singleSelectionPage"
4
4
  import utilities from "../helpers/utilities";
@@ -45,11 +45,16 @@ export const iePage = {
45
45
  questionInstructions = questionInstructions.replace(/00:00\n\/\n00:00\n/g, '');
46
46
  expect(questionInstructions).to.be.eq(expectedQuestionData.previewQuestionInstructions)
47
47
  });
48
- } else if (expectedQuestionData.previewQuestionInstructions === '') {
49
- utilities.verifyInnerText(singleSelectionPage.questionInstructionsText(), '');
50
48
  } else {
51
- singleSelectionPage.questionInstructionsText()
52
- .should('not.exist');
49
+ cy.get('[class*="QuestionTypeWrapper"]')
50
+ .then(($questionInstructions) => {
51
+ if ($questionInstructions[0].innerHTML.includes('question-instruction')) {
52
+ utilities.verifyInnerText(singleSelectionPage.questionInstructionsText(), '');
53
+ } else {
54
+ singleSelectionPage.questionInstructionsText()
55
+ .should('not.exist');
56
+ }
57
+ });
53
58
  }
54
59
  }
55
60
  }
@@ -258,7 +263,7 @@ export const verifyIeQuestionData = {
258
263
  let textAreaPlaceholder = $element[0].attributes["data-cke-editorplaceholder"]?.nodeValue;
259
264
  expect(textAreaPlaceholder).to.be.eq(expectedQuestionData.textAreaPlaceholder);
260
265
  });
261
- if (expectedQuestionData.toolbarButtons.length != 0) {
266
+ if (expectedQuestionData.toolbarButtons.length !== 0) {
262
267
  let ieButtonsTitle = [];
263
268
  let ieButtonsExpected = expectedQuestionData.toolbarButtons.map((button) => {
264
269
  return essayResponseToolbarOptionsENUM[button];
@@ -270,6 +275,9 @@ export const verifyIeQuestionData = {
270
275
  }).then(() => {
271
276
  expect(ieButtonsTitle).to.have.deep.members(ieButtonsExpected);
272
277
  });
278
+ } else {
279
+ essayResponsePage.previewTabToolbarOption()
280
+ .should('not.exist');
273
281
  }
274
282
  if (expectedQuestionData.hasWordLimit || expectedQuestionData.hasWordCount) {
275
283
  if (expectedQuestionData.hasWordLimit) {
@@ -740,7 +748,102 @@ export const verifyIeQuestionData = {
740
748
  });
741
749
  });
742
750
  });
743
- }
751
+ },
752
+
753
+ figDropdown: (expectedQuestionData, index) => {
754
+ cy.get('.ngie-cloze-with-dropdown')
755
+ .eq(index)
756
+ .within(() => {
757
+ iePage.steps.verifyQuestionInstructions(expectedQuestionData);
758
+ //Unable to verify question container as dropdown options also appear in expectedQuestionData object
759
+ /* fillInTheGapsDropdownPage.questionContainerPreviewTab()
760
+ .then(($question) => {
761
+ let innerText = $question[0].innerText;
762
+ innerText = innerText.replace(/\n/g, '');
763
+ //getting rid of the   and ​
764
+ innerText = innerText.replace(/\u00a0/g, ' ');
765
+ innerText = innerText.replace(/\u200b/g, '');
766
+ innerText = innerText.trim()
767
+ expect(expectedQuestionData.previewQuestion).to.be.include(innerText);
768
+ }); */
769
+ fillInTheGapsDropdownPage.dropdownWrapperPreviewTab()
770
+ .then(($resposneWrapper) => {
771
+ expect($resposneWrapper.length).to.be.eq(expectedQuestionData.previewResponseCount);
772
+ });
773
+ fillInTheGapsDropdownPage.dropdownWrapperPreviewTab()
774
+ .each(($responseField, index) => {
775
+ expect($responseField[0].placeholder).to.be.eq(expectedQuestionData.responses[index].placeholder);
776
+ expect($responseField[0].spellcheck).to.be.eq(expectedQuestionData.responses[index].spellcheck);
777
+ // expect($responseField[0].ariaLabel).to.be.eq(expectedQuestionData.responses[index].ariaLabel);
778
+ });
779
+
780
+ });
781
+ let allDropdownOptions = [];
782
+ for (let dropdownCount = 0; dropdownCount < expectedQuestionData.allDropdownOptions.length; dropdownCount++) {
783
+ cy.get('.ngie-cloze-with-dropdown')
784
+ .eq(index)
785
+ .within(() => {
786
+ fillInTheGapsDropdownPage.dropdownWrapperPreviewTab()
787
+ .eq(dropdownCount)
788
+ .click();
789
+ });
790
+ let currentOptions = [];
791
+ utilities.verifyElementVisibilityState(fillInTheGapsDropdownPage.dropdownList(), 'visible');
792
+ fillInTheGapsDropdownPage.dropdownListOptions()
793
+ .each(($option) => {
794
+ let optionText = $option[0].innerText;
795
+ currentOptions.push(optionText);
796
+ }).then(() => {
797
+ cy.get('body')
798
+ .click();
799
+ utilities.verifyElementVisibilityState(fillInTheGapsDropdownPage.dropdownList(), 'notExist');
800
+ allDropdownOptions.push(currentOptions);
801
+ if (allDropdownOptions.length === expectedQuestionData.allDropdownOptions.length) {
802
+ expect(allDropdownOptions.length).to.equal(expectedQuestionData.allDropdownOptions.length);
803
+ allDropdownOptions.forEach((options, index) => {
804
+ expect(options).to.deep.equal(expectedQuestionData.allDropdownOptions[index]);
805
+ });
806
+ };
807
+ });
808
+ }
809
+ },
810
+
811
+ figDropdownGrading: (expectedQuestionData, index) => {
812
+ cy.get('.ngie-cloze-with-dropdown')
813
+ .eq(index)
814
+ .within(() => {
815
+ cy.log('Here')
816
+ iePage.steps.verifyQuestionInstructions(expectedQuestionData);
817
+ //Unable to verify question container as dropdown options also appear in expectedQuestionData object
818
+ /* fillInTheGapsDropdownPage.questionContainerPreviewTab()
819
+ .then(($question) => {
820
+ let innerText = $question[0].innerText;
821
+ innerText = innerText.replace(/\n/g, '');
822
+ //getting rid of the &nbsp; and &ZeroWidthSpace;
823
+ innerText = innerText.replace(/\u00a0/g, ' ');
824
+ innerText = innerText.replace(/\u200b/g, '');
825
+ innerText = innerText.trim()
826
+ expect(expectedQuestionData.previewQuestion).to.be.include(innerText);
827
+ });*/
828
+ fillInTheGapsDropdownPage.dropdownWrapperPreviewTab()
829
+ .then(($resposneWrapper) => {
830
+ expect($resposneWrapper.length).to.be.eq(expectedQuestionData.previewResponseCount);
831
+ });
832
+ expectedQuestionData.correctAnswers.forEach((correctAnswerData, index) => {
833
+ fillInTheGapsDropdownPage.correctAnswerResponseWrapper()
834
+ .eq(index)
835
+ .within(() => {
836
+ cy.get('.answer-numeration-number-box')
837
+ .then(($answerNumeration) => {
838
+ expect($answerNumeration[0].innerText).to.be.eq(correctAnswerData.answerNumeration);
839
+ });
840
+ cy.get('.question-text-wrapper').then(($answerOption) => {
841
+ expect($answerOption[0].innerText).to.be.eq(correctAnswerData.options[0].innerText);
842
+ });
843
+ });
844
+ });
845
+ });
846
+ },
744
847
 
745
848
  /* singleSelection: (expectedQuestionData, index) => {
746
849
  cy.get('.ngie-single-select')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itemengine-cypress-automation",
3
- "version": "1.0.180-essayResponseLazyLoadingFix-63cd8a3.0",
3
+ "version": "1.0.181-figDropdown-5a8309d.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {