itemengine-cypress-automation 1.0.177-contentBlocksScript-8f6c76a.0 → 1.0.177-figDndMigration-78a290b.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -155,13 +155,13 @@ Cypress.Commands.add('learnosityLoaderWait', () => {
155
155
  });
156
156
 
157
157
  Cypress.Commands.add('lazyLoadPreviewQuestions', (count, retries = 5) => {
158
- iePage.questionAndResourceWrapper()
158
+ iePage.questionWrapper()
159
159
  .then((elements) => {
160
160
  if (retries <= 0) {
161
161
  throw new Error('Itemengine questions did not lazy load in time');
162
162
  };
163
163
  if (elements.length < count) {
164
- iePage.questionAndResourceWrapper()
164
+ iePage.questionWrapper()
165
165
  .last()
166
166
  .scrollIntoView()
167
167
  .wait(1000);
@@ -32,7 +32,6 @@ export const lrnPage = {
32
32
  uploadResponseSupportedFileTypes: () => cy.get('.lrn-fileupload-support-copy'),
33
33
  uploadResponseFileLimit: () => cy.get('.lrn-limit-status'),
34
34
  uploadResponseToolbar: () => cy.get('[data-lrn-component="toolbar"]'),
35
- contentBlocksQuestion: () => cy.get('.lrn_sharedpassage'),
36
35
  steps: {
37
36
  checkShowAnswersToggle: () => {
38
37
  lrnPage.showAnswersToggle()
@@ -561,7 +560,6 @@ export const extractLrnQuestionData = {
561
560
  cy.log(`Extracting the question instructions and answer input field attributes from question ${index}`);
562
561
  obj.questionIndex = index;
563
562
  obj.questionType = 'shortTextResponse'
564
- lrnPage.steps.extractQuestionInstructions(obj, index);
565
563
  lrnPage.questionWrapper()
566
564
  .eq(index)
567
565
  .within(() => {
@@ -578,11 +576,11 @@ export const extractLrnQuestionData = {
578
576
  obj.specialCharactersEnabled = true;
579
577
  }
580
578
  });
581
- })
579
+ });
582
580
  lrnQuestionDataArr.push(obj);
583
581
  },
584
582
 
585
- shortTextResponseGrading: (lrnQuestionDataArr, index) => {
583
+ shortTextResponseGrading: (lrnGradingDataArr, index) => {
586
584
  let obj = {};
587
585
  cy.log(`Extracting the question instructions and correct answers from question ${index}`);
588
586
  obj.questionIndex = index;
@@ -598,7 +596,7 @@ export const extractLrnQuestionData = {
598
596
  });
599
597
  };
600
598
  });
601
- lrnQuestionDataArr.push(obj);
599
+ lrnGradingDataArr.push(obj);
602
600
  },
603
601
 
604
602
  uploadResponse: (lrnQuestionDataArr, index) => {
@@ -631,18 +629,149 @@ export const extractLrnQuestionData = {
631
629
  lrnQuestionDataArr.push(obj);
632
630
  },
633
631
 
634
- contentBlocks: (lrnQuestionDataArr, index) => {
632
+ figDragAndDrop: (lrnQuestionDataArr, index) => {
635
633
  let obj = {};
636
- cy.log(`Extracting the passage from question ${index}`);
634
+ cy.log(`Extracting the question instructions, question, response areas count, draggable option container position, drag handle visibility, draggable options from question ${index}`);
637
635
  obj.questionIndex = index;
638
- obj.questionType = 'contentBlocks';
639
- lrnPage.contentBlocksQuestion()
636
+ obj.questionType = 'figDragAndDrop';
637
+ lrnPage.steps.extractQuestionInstructions(obj, index);
638
+ lrnPage.questionWrapper()
640
639
  .eq(index)
641
- .then(($question) => {
642
- let text = $question[0].innerText;
643
- obj.passageText = text;
640
+ .within(() => {
641
+ lrnPage.questionContainerPreviewTab()
642
+ .then(($question) => {
643
+ let innerText = $question[0].innerText;
644
+ obj.previewQuestion = innerText;
645
+ });
646
+ lrnPage.clozeResponse()
647
+ .then(($responseFields) => {
648
+ obj.previewResponseCount = $responseFields.length;
649
+ });
650
+ let options = [];
651
+ let optionImages = [];
652
+ let optionEquations = [];
653
+ lrnPage.draggableResponse()
654
+ .each(($option, index) => {
655
+ let innerText = $option[0].innerText;
656
+ options.push(innerText);
657
+ let innerHTML = $option[0].innerHTML;
658
+ if (innerHTML.includes('<img')) {
659
+ lrnPage.draggableResponse()
660
+ .eq(index)
661
+ .find('img')
662
+ .then(($img) => {
663
+ let altText = $img[0].alt;
664
+ optionImages.push(altText);
665
+ });
666
+ }
667
+ if (innerHTML.includes('<math')) {
668
+ lrnPage.draggableResponse()
669
+ .eq(index)
670
+ .find('math')
671
+ .then(($element) => {
672
+ let outerHtml = $element[0].outerHTML;
673
+ optionEquations.push(outerHtml);
674
+ });
675
+ }
676
+ });
677
+ let position;
678
+ cy.get('.lrn_possibilityList').invoke('attr', 'class').then(classAttribute => {
679
+ const classList = classAttribute.split(' ');
680
+ if (classList.includes('lrn_list_bottom')) {
681
+ position = 'bottom';
682
+ } else if (classList.includes('lrn_list_top')) {
683
+ position = 'top';
684
+ } else if (classList.includes('lrn_list_left')) {
685
+ position = 'left'
686
+ } else if (classList.includes('lrn_list_right')) {
687
+ position = 'right'
688
+ } else {
689
+ position = null;
690
+ }
691
+ obj.position = position;
692
+ });
693
+ let dragHandleVisibility;
694
+ lrnPage.draggableResponse()
695
+ .eq(0)
696
+ .then(($draggableResponse) => {
697
+ if ($draggableResponse[0].className.includes('lrn_btn_no_handle')) {
698
+ dragHandleVisibility = false;
699
+ } else {
700
+ dragHandleVisibility = true;
701
+ }
702
+ obj.dragHandleVisibility = dragHandleVisibility;
703
+ });
704
+ obj.options = options;
705
+ obj.optionImages = optionImages;
706
+ obj.optionEquations = optionEquations;
644
707
  });
645
708
  lrnQuestionDataArr.push(obj);
709
+ },
710
+
711
+ figDragAndDropGrading: (lrnGradingDataArr, index) => {
712
+ let obj = {};
713
+ cy.log(`Extracting the question instructions, response area count and correct answers from question ${index}`);
714
+ obj.questionIndex = index;
715
+ obj.questionType = 'figDragAndDrop';
716
+ lrnPage.steps.extractQuestionInstructions(obj, index);
717
+ lrnPage.questionWrapper()
718
+ .eq(index)
719
+ .within(() => {
720
+ lrnPage.questionContainerPreviewTab()
721
+ .then(($question) => {
722
+ let innerText = $question[0].innerText;
723
+ obj.previewQuestion = innerText;
724
+ });
725
+ lrnPage.clozeResponse()
726
+ .then(($responseFields) => {
727
+ obj.previewResponseCount = $responseFields.length;
728
+ });
729
+ let correctAnswers = [];
730
+ //correctAnswer
731
+ cy.get('.lrn_correctAnswerList li')
732
+ .each(($answers) => {
733
+ let answerData = {}
734
+ cy.wrap($answers)
735
+ .within(() => {
736
+ cy.get('.lrn_responseIndex')
737
+ .then(($element) => {
738
+ let answerNumeration = $element[0].innerText;
739
+ answerData.answerNumeration = answerNumeration;
740
+ });
741
+ let options = []
742
+ cy.get('.lrn_responseText')
743
+ .each(($option, index) => {
744
+ let optionData = {}
745
+ let innerText = $option[0].innerText;
746
+ optionData.innerText = innerText;
747
+ let innerHTML = $option[0].innerHTML;
748
+ if (innerHTML.includes('<img')) {
749
+ cy.get('.lrn_responseText')
750
+ .eq(index)
751
+ .find('img')
752
+ .then(($img) => {
753
+ let altText = $img[0].alt;
754
+ optionData.altText = altText;
755
+ });
756
+ }
757
+ if (innerHTML.includes('<math')) {
758
+ cy.get('.lrn_responseText')
759
+ .eq(index)
760
+ .find('math')
761
+ .then(($element) => {
762
+ let outerHtml = $element[0].outerHTML;
763
+ optionData.equation = outerHtml;
764
+ });
765
+ }
766
+ options.push(optionData);
767
+ });
768
+ answerData.options = options
769
+ });
770
+ correctAnswers.push(answerData);
771
+ });
772
+ obj.correctAnswers = correctAnswers;
773
+ });
774
+ lrnGradingDataArr.push(obj);
646
775
  }
647
776
 
648
777
  /* singleSelection: (lrnQuestionDataArr, index) => {
@@ -12,7 +12,7 @@ const lrnQuestionTypesENUM = {
12
12
  figText: 'Cloze with text',
13
13
  shortTextResponse: 'Short text',
14
14
  uploadResponse: 'File upload',
15
- contentBlocks: 'Passage'
15
+ figDragAndDrop: 'Cloze with drag & drop',
16
16
  }
17
17
 
18
18
  export default lrnQuestionTypesENUM;
@@ -26,7 +26,7 @@ const extractLrnPreviewData = (currQuestionType, lrnQuestionDataArr, index) => {
26
26
  case lrnQuestionTypesENUM.figText: return extractLrnQuestionData.figText(lrnQuestionDataArr, index);
27
27
  case lrnQuestionTypesENUM.shortTextResponse: return extractLrnQuestionData.shortTextResponse(lrnQuestionDataArr, index);
28
28
  case lrnQuestionTypesENUM.uploadResponse: return extractLrnQuestionData.uploadResponse(lrnQuestionDataArr, index);
29
- case lrnQuestionTypesENUM.contentBlocks: return extractLrnQuestionData.contentBlocks(lrnQuestionDataArr, index);
29
+ case lrnQuestionTypesENUM.figDragAndDrop: return extractLrnQuestionData.figDragAndDrop(lrnQuestionDataArr, index);
30
30
  default: throw new Error('Invalid lrn question type');
31
31
  }
32
32
  }
@@ -43,7 +43,7 @@ const verifyIePreviewData = (questionType, questionData, index) => {
43
43
  case 'figText': return verifyIeQuestionData.figText(questionData, index);
44
44
  case 'shortTextResponse': return verifyIeQuestionData.shortTextResponse(questionData, index);
45
45
  case 'uploadResponse': return verifyIeQuestionData.uploadResponse(questionData, index);
46
- case 'contentBlocks': return verifyIeQuestionData.contentBlocks(questionData, index);
46
+ case 'figDragAndDrop': return verifyIeQuestionData.figDragAndDrop(questionData, index);
47
47
  default: throw new Error('Invalid ngie question type');
48
48
  }
49
49
  }
@@ -57,7 +57,7 @@ const extractLrnGradingData = (currQuestionType, lrnGradingDataArr, index) => {
57
57
  case lrnQuestionTypesENUM.figText: return extractLrnQuestionData.figTextGrading(lrnGradingDataArr, index);
58
58
  case lrnQuestionTypesENUM.shortTextResponse: return extractLrnQuestionData.shortTextResponseGrading(lrnGradingDataArr, index);
59
59
  case lrnQuestionTypesENUM.uploadResponse: return cy.log('Manually Graded Question Type');
60
- case lrnQuestionTypesENUM.contentBlocks: return cy.log('Resource and tool');
60
+ case lrnQuestionTypesENUM.figDragAndDrop: return extractLrnQuestionData.figDragAndDropGrading(lrnGradingDataArr, index);
61
61
  default: throw new Error('Invalid lrn question type');
62
62
  }
63
63
  }
@@ -71,7 +71,7 @@ const verifyIeGradingData = (questionType, questionData, index) => {
71
71
  case 'figText': return verifyIeQuestionData.figTextGrading(questionData, index);
72
72
  case 'shortTextResponse': return verifyIeQuestionData.shortTextResponseGrading(questionData, index);
73
73
  case 'uploadResponse': return cy.log('Manually Graded Question Type');
74
- case 'contentBlocks': return cy.log('Resource and tool');
74
+ case 'figDragAndDrop': return verifyIeQuestionData.figDragAndDropGrading(questionData, index);
75
75
  default: throw new Error('Invalid ngie question type');
76
76
  }
77
77
  }
@@ -92,7 +92,7 @@ export const migrationScript = (referenceIds) => {
92
92
  cy.visit(`/items-list/item/${utilities.base64Encoding(referenceId)}`);
93
93
  cy.pageLoadWait('getItemPreview');
94
94
  cy.get('@getItemPreview').then((req) => {
95
- let questionCount = req.response.body.data.getItemPreview.item.questionParts.length + req.response.body.data.getItemPreview.item.resources.length;
95
+ let questionCount = req.response.body.data.getItemPreview.item.questionParts.length;
96
96
  cy.lazyLoadPreviewQuestions(questionCount);
97
97
  });
98
98
  });
@@ -1,5 +1,5 @@
1
- import { contentBlocksPage, essayResponsePage, fillInTheGapsTextPage, multipleSelectionPage, textEntryMathPage, uploadResponsePage } from "../../pages";
2
- import { draggableOptionContainer } from "../../pages/components";
1
+ import { essayResponsePage, fillInTheGapsDragAndDropPage, fillInTheGapsTextPage, multipleSelectionPage, textEntryMathPage, uploadResponsePage } from "../../pages";
2
+ import { draggableOptionContainer, fillInTheGapsDragAndDropCommonComponents } from "../../pages/components";
3
3
  import { singleSelectionPage } from "../../pages/singleSelectionPage"
4
4
  import utilities from "../helpers/utilities";
5
5
  import drawingToolbarOptionsENUM from "./drawingToolbarOptionsENUM";
@@ -9,7 +9,6 @@ export const iePage = {
9
9
  mcqOption: () => cy.get('.mcq_Label'),
10
10
  mcqOptionWrapper: () => cy.get('div[class*="option-wrapper"]'),
11
11
  questionWrapper: () => cy.get('.ngie-question-wrapper'),
12
- questionAndResourceWrapper: () => cy.get('.item_Widget'),
13
12
  barsPreloader: () => cy.get('[id="question-item-instruction-loader"]'),
14
13
  previewQuestionTextWrapper: () => cy.get('.preview-question-text-wrapper'),
15
14
  //textEntryMathResponseWrapper: () => cy.get('.cloze-math-preview-wrapper .cloze-math-response-input-field'),
@@ -20,7 +19,6 @@ export const iePage = {
20
19
  essayResponseWordLimit: () => cy.get('.input-limit-label'),
21
20
  essayResponseWordCount: () => cy.get('[class*="indexstyle__WordCharCountWrapper"]'),
22
21
  essayResponseFooter: () => cy.get('.essay-character-view-wrapper'),
23
- essayResponseLoader: () => cy.get('[class*="InlineLoaderstyles__LoaderDiv"] img'),
24
22
  drawingResponseToolbarButton: () => cy.get('[class*="DrawingToolButtonstyled__Container"] svg'),
25
23
  drawingResponseLowerCanvas: () => cy.get('.lower-canvas'),
26
24
  figCorrectAnswerBlock: () => cy.get('[class*="AnswerCell"]'),
@@ -246,9 +244,6 @@ export const verifyIeQuestionData = {
246
244
  cy.get('[class*="ngie-essay-response"]')
247
245
  .eq(index)
248
246
  .within(() => {
249
- iePage.essayResponseLoader()
250
- .scrollIntoView()
251
- .should('not.be.visible');
252
247
  iePage.steps.verifyQuestionInstructions(expectedQuestionData);
253
248
  essayResponsePage.responseField()
254
249
  .then(($element) => {
@@ -294,9 +289,6 @@ export const verifyIeQuestionData = {
294
289
  cy.get('[class*="ngie-essay-response"]')
295
290
  .eq(index)
296
291
  .within(() => {
297
- iePage.essayResponseLoader()
298
- .scrollIntoView()
299
- .should('not.be.visible');
300
292
  iePage.steps.verifyQuestionInstructions(expectedQuestionData);
301
293
  essayResponsePage.responseField()
302
294
  .then(($element) => {
@@ -564,7 +556,7 @@ export const verifyIeQuestionData = {
564
556
  });
565
557
  } else {
566
558
  utilities.verifyElementVisibilityState(iePage.shortTextResponseCorrectAnswerText(), 'notExist');
567
- }
559
+ };
568
560
  });
569
561
  },
570
562
 
@@ -603,12 +595,128 @@ export const verifyIeQuestionData = {
603
595
  });
604
596
  },
605
597
 
606
- contentBlocks: (expectedQuestionData, index) => {
607
- cy.get('[class*="ContentBlocksPreviewstyles__ContentBlocksPreviewWrapper"]')
598
+ figDragAndDrop: (expectedQuestionData, index) => {
599
+ cy.get('.ngie-cloze-with-drag-and-drop')
608
600
  .eq(index)
609
- .then(($element) => {
610
- let passageText = $element[0].innerText
611
- expect(passageText).to.be.eq(expectedQuestionData.passageText)
601
+ .within(() => {
602
+ iePage.steps.verifyQuestionInstructions(expectedQuestionData);
603
+ /* fillInTheGapsDragAndDropPage.questionContainerPreviewTab()
604
+ .then(($question) => {
605
+ let innerText = $question[0].innerText;
606
+ expect(expectedQuestionData.previewQuestion).to.be.eq(innerText);
607
+ });
608
+ fillInTheGapsDragAndDropPage.dropzonePreviewTab()
609
+ .then(($resposneWrapper) => {
610
+ expect($resposneWrapper.length).to.be.eq(expectedQuestionData.previewResponseCount);
611
+ }); */
612
+ let position;
613
+ cy.get('.preview-container-split-view').invoke('attr', 'class').then(classAttribute => {
614
+ const classList = classAttribute.split(' ');
615
+ if (classList.includes('placement-bottom')) {
616
+ position = 'bottom';
617
+ } else if (classList.includes('placement-top')) {
618
+ position = 'top';
619
+ } else if (classList.includes('placement-left')) {
620
+ position = 'left'
621
+ } else if (classList.includes('placement-right')) {
622
+ position = 'right'
623
+ } else {
624
+ position = null;
625
+ }
626
+ }).then(() => {
627
+ expect(position).to.be.eq(expectedQuestionData.position);
628
+ });
629
+ if (expectedQuestionData.dragHandleVisibility === true) {
630
+ draggableOptionContainer.draggableOption()
631
+ .eq(0)
632
+ .within(() => {
633
+ utilities.verifyElementVisibilityState(draggableOptionContainer.draggableOptionDragIcon(), 'exist');
634
+ });
635
+ } else {
636
+ draggableOptionContainer.draggableOption()
637
+ .eq(0)
638
+ .within(() => {
639
+ utilities.verifyElementVisibilityState(draggableOptionContainer.draggableOptionDragIcon(), 'notExist');
640
+ });
641
+ }
642
+ let options = [];
643
+ draggableOptionContainer.draggableOption()
644
+ .each(($option) => {
645
+ let innerText = $option[0].innerText;
646
+ options.push(innerText);
647
+ }).then(() => {
648
+ expect(options).to.have.deep.members(expectedQuestionData.options);
649
+ });
650
+ if (expectedQuestionData.optionEquations.length > 0) {
651
+ let optionEquations = [];
652
+ draggableOptionContainer.draggableOption()
653
+ .find('math')
654
+ .each(($math) => {
655
+ optionEquations.push($math.get(0).outerHTML);
656
+ }).then(() => {
657
+ expect(optionEquations).to.have.deep.members(expectedQuestionData.optionEquations);
658
+ });
659
+ }
660
+ if (expectedQuestionData.optionImages.length > 0) {
661
+ let optionImages = [];
662
+ draggableOptionContainer.draggableOption()
663
+ .find('img')
664
+ .each(($img) => {
665
+ optionImages.push($img.get(0).alt);
666
+ }).then(() => {
667
+ expect(optionImages).to.have.deep.members(expectedQuestionData.optionImages);
668
+ });
669
+ }
670
+ });
671
+ },
672
+
673
+ figDragAndDropGrading: (expectedQuestionData, index) => {
674
+ cy.get('.ngie-cloze-with-drag-and-drop')
675
+ .eq(index)
676
+ .within(() => {
677
+ iePage.steps.verifyQuestionInstructions(expectedQuestionData);
678
+ /* fillInTheGapsTextPage.questionContainerPreviewTab()
679
+ .then(($question) => {
680
+ let innerText = $question[0].innerText;
681
+ expect(expectedQuestionData.previewQuestion).to.be.eq(innerText);
682
+ });
683
+ fillInTheGapsDragAndDropPage.dropzonePreviewTab()
684
+ .then(($resposneWrapper) => {
685
+ expect($resposneWrapper.length).to.be.eq(expectedQuestionData.previewResponseCount);
686
+ }); */
687
+ fillInTheGapsDragAndDropCommonComponents.correctAnswersOptions()
688
+ .then(($answerWrapper) => {
689
+ expect($answerWrapper.length).to.be.eq(expectedQuestionData.correctAnswers.length);
690
+ });
691
+ expectedQuestionData.correctAnswers.forEach((correctAnswerData, index) => {
692
+ iePage.figCorrectAnswerBlock()
693
+ .eq(index)
694
+ .within(() => {
695
+ cy.get('.answer-numeration-number-box')
696
+ .then(($answerNumeration) => {
697
+ expect($answerNumeration[0].innerText).to.be.eq(correctAnswerData.answerNumeration);
698
+ });
699
+ cy.get('.question-text-wrapper').then(($answerOption) => {
700
+ expect($answerOption[0].innerText).to.be.eq(correctAnswerData.options[0].innerText);
701
+ if (correctAnswerData.equation) {
702
+ cy.get('.question-text-wrapper')
703
+ .eq(index)
704
+ .find('math')
705
+ .then(($math) => {
706
+ expect($math[0].outerHTML).to.be.eq(correctAnswerData.equation);
707
+ });
708
+ }
709
+ if (correctAnswerData.altText) {
710
+ cy.get('.question-text-wrapper')
711
+ .eq(index)
712
+ .find('img')
713
+ .then(($img) => {
714
+ expect($img[0].alt).to.be.eq(correctAnswerData.altText);
715
+ });
716
+ }
717
+ });
718
+ });
719
+ });
612
720
  });
613
721
  }
614
722
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itemengine-cypress-automation",
3
- "version": "1.0.177-contentBlocksScript-8f6c76a.0",
3
+ "version": "1.0.177-figDndMigration-78a290b.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {