itemengine-cypress-automation 1.0.175-15thAprilRepoUpdate-cb0f7d0.0 → 1.0.177-figDndMigration-9070657.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -560,7 +560,6 @@ export const extractLrnQuestionData = {
560
560
  cy.log(`Extracting the question instructions and answer input field attributes from question ${index}`);
561
561
  obj.questionIndex = index;
562
562
  obj.questionType = 'shortTextResponse'
563
- lrnPage.steps.extractQuestionInstructions(obj, index);
564
563
  lrnPage.questionWrapper()
565
564
  .eq(index)
566
565
  .within(() => {
@@ -577,11 +576,11 @@ export const extractLrnQuestionData = {
577
576
  obj.specialCharactersEnabled = true;
578
577
  }
579
578
  });
580
- })
579
+ });
581
580
  lrnQuestionDataArr.push(obj);
582
581
  },
583
582
 
584
- shortTextResponseGrading: (lrnQuestionDataArr, index) => {
583
+ shortTextResponseGrading: (lrnGradingDataArr, index) => {
585
584
  let obj = {};
586
585
  cy.log(`Extracting the question instructions and correct answers from question ${index}`);
587
586
  obj.questionIndex = index;
@@ -597,7 +596,7 @@ export const extractLrnQuestionData = {
597
596
  });
598
597
  };
599
598
  });
600
- lrnQuestionDataArr.push(obj);
599
+ lrnGradingDataArr.push(obj);
601
600
  },
602
601
 
603
602
  uploadResponse: (lrnQuestionDataArr, index) => {
@@ -630,6 +629,151 @@ export const extractLrnQuestionData = {
630
629
  lrnQuestionDataArr.push(obj);
631
630
  },
632
631
 
632
+ figDragAndDrop: (lrnQuestionDataArr, index) => {
633
+ let obj = {};
634
+ cy.log(`Extracting the question instructions, question, response areas count, draggable option container position, drag handle visibility, draggable options from question ${index}`);
635
+ obj.questionIndex = index;
636
+ obj.questionType = 'figDragAndDrop';
637
+ lrnPage.steps.extractQuestionInstructions(obj, index);
638
+ lrnPage.questionWrapper()
639
+ .eq(index)
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;
707
+ });
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);
775
+ }
776
+
633
777
  /* singleSelection: (lrnQuestionDataArr, index) => {
634
778
  let obj = {};
635
779
  cy.log(`Extracting the question instructions and options from question ${index}`);
@@ -11,7 +11,8 @@ const lrnQuestionTypesENUM = {
11
11
  trueOrFalse: 'True or false',
12
12
  figText: 'Cloze with text',
13
13
  shortTextResponse: 'Short text',
14
- uploadResponse: 'File upload'
14
+ uploadResponse: 'File upload',
15
+ figDragAndDrop: 'Cloze with drag & drop',
15
16
  }
16
17
 
17
18
  export default lrnQuestionTypesENUM;
@@ -26,6 +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.figDragAndDrop: return extractLrnQuestionData.figDragAndDrop(lrnQuestionDataArr, index);
29
30
  default: throw new Error('Invalid lrn question type');
30
31
  }
31
32
  }
@@ -42,6 +43,7 @@ const verifyIePreviewData = (questionType, questionData, index) => {
42
43
  case 'figText': return verifyIeQuestionData.figText(questionData, index);
43
44
  case 'shortTextResponse': return verifyIeQuestionData.shortTextResponse(questionData, index);
44
45
  case 'uploadResponse': return verifyIeQuestionData.uploadResponse(questionData, index);
46
+ case 'figDragAndDrop': return verifyIeQuestionData.figDragAndDrop(questionData, index);
45
47
  default: throw new Error('Invalid ngie question type');
46
48
  }
47
49
  }
@@ -55,6 +57,7 @@ const extractLrnGradingData = (currQuestionType, lrnGradingDataArr, index) => {
55
57
  case lrnQuestionTypesENUM.figText: return extractLrnQuestionData.figTextGrading(lrnGradingDataArr, index);
56
58
  case lrnQuestionTypesENUM.shortTextResponse: return extractLrnQuestionData.shortTextResponseGrading(lrnGradingDataArr, index);
57
59
  case lrnQuestionTypesENUM.uploadResponse: return cy.log('Manually Graded Question Type');
60
+ case lrnQuestionTypesENUM.figDragAndDrop: return extractLrnQuestionData.figDragAndDropGrading(lrnGradingDataArr, index);
58
61
  default: throw new Error('Invalid lrn question type');
59
62
  }
60
63
  }
@@ -68,6 +71,7 @@ const verifyIeGradingData = (questionType, questionData, index) => {
68
71
  case 'figText': return verifyIeQuestionData.figTextGrading(questionData, index);
69
72
  case 'shortTextResponse': return verifyIeQuestionData.shortTextResponseGrading(questionData, index);
70
73
  case 'uploadResponse': return cy.log('Manually Graded Question Type');
74
+ case 'figDragAndDrop': return verifyIeQuestionData.figDragAndDropGrading(questionData, index);
71
75
  default: throw new Error('Invalid ngie question type');
72
76
  }
73
77
  }
@@ -1,5 +1,5 @@
1
- import { 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";
@@ -556,7 +556,7 @@ export const verifyIeQuestionData = {
556
556
  });
557
557
  } else {
558
558
  utilities.verifyElementVisibilityState(iePage.shortTextResponseCorrectAnswerText(), 'notExist');
559
- }
559
+ };
560
560
  });
561
561
  },
562
562
 
@@ -593,6 +593,125 @@ export const verifyIeQuestionData = {
593
593
  });
594
594
  }
595
595
  });
596
+ },
597
+
598
+ figDragAndDrop: (expectedQuestionData, index) => {
599
+ cy.get('.ngie-cloze-with-drag-and-drop')
600
+ .eq(index)
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) {
630
+ draggableOptionContainer.draggableOption()
631
+ .eq(0)
632
+ .within(() => {
633
+ utilities.verifyElementVisibilityState(draggableOptionContainer.draggableOptionDragIcon(), 'exist');
634
+ });
635
+ }
636
+ let options = [];
637
+ draggableOptionContainer.draggableOption()
638
+ .each(($option) => {
639
+ let innerText = $option[0].innerText;
640
+ options.push(innerText);
641
+ }).then(() => {
642
+ expect(options).to.have.deep.members(expectedQuestionData.options);
643
+ });
644
+ if (expectedQuestionData.optionEquations.length > 0) {
645
+ let optionEquations = [];
646
+ draggableOptionContainer.draggableOption()
647
+ .find('math')
648
+ .each(($math) => {
649
+ optionEquations.push($math.get(0).outerHTML);
650
+ }).then(() => {
651
+ expect(optionEquations).to.have.deep.members(expectedQuestionData.optionEquations);
652
+ });
653
+ }
654
+ if (expectedQuestionData.optionImages.length > 0) {
655
+ let optionImages = [];
656
+ draggableOptionContainer.draggableOption()
657
+ .find('img')
658
+ .each(($img) => {
659
+ optionImages.push($img.get(0).alt);
660
+ }).then(() => {
661
+ expect(optionImages).to.have.deep.members(expectedQuestionData.optionImages);
662
+ });
663
+ }
664
+ });
665
+ },
666
+
667
+ figDragAndDropGrading: (expectedQuestionData, index) => {
668
+ cy.get('.ngie-cloze-with-drag-and-drop')
669
+ .eq(index)
670
+ .within(() => {
671
+ iePage.steps.verifyQuestionInstructions(expectedQuestionData);
672
+ /* fillInTheGapsTextPage.questionContainerPreviewTab()
673
+ .then(($question) => {
674
+ let innerText = $question[0].innerText;
675
+ expect(expectedQuestionData.previewQuestion).to.be.eq(innerText);
676
+ });
677
+ fillInTheGapsDragAndDropPage.dropzonePreviewTab()
678
+ .then(($resposneWrapper) => {
679
+ expect($resposneWrapper.length).to.be.eq(expectedQuestionData.previewResponseCount);
680
+ }); */
681
+ fillInTheGapsDragAndDropCommonComponents.correctAnswersOptions()
682
+ .then(($answerWrapper) => {
683
+ expect($answerWrapper.length).to.be.eq(expectedQuestionData.correctAnswers.length);
684
+ });
685
+ expectedQuestionData.correctAnswers.forEach((correctAnswerData, index) => {
686
+ iePage.figCorrectAnswerBlock()
687
+ .eq(index)
688
+ .within(() => {
689
+ cy.get('.answer-numeration-number-box')
690
+ .then(($answerNumeration) => {
691
+ expect($answerNumeration[0].innerText).to.be.eq(correctAnswerData.answerNumeration);
692
+ });
693
+ cy.get('.question-text-wrapper').then(($answerOption) => {
694
+ expect($answerOption[0].innerText).to.be.eq(correctAnswerData.options[0].innerText);
695
+ if (correctAnswerData.equation) {
696
+ cy.get('.question-text-wrapper')
697
+ .eq(index)
698
+ .find('math')
699
+ .then(($math) => {
700
+ expect($math[0].outerHTML).to.be.eq(correctAnswerData.equation);
701
+ });
702
+ }
703
+ if (correctAnswerData.altText) {
704
+ cy.get('.question-text-wrapper')
705
+ .eq(index)
706
+ .find('img')
707
+ .then(($img) => {
708
+ expect($img[0].alt).to.be.eq(correctAnswerData.altText);
709
+ });
710
+ }
711
+ });
712
+ });
713
+ });
714
+ });
596
715
  }
597
716
 
598
717
  /* singleSelection: (expectedQuestionData, index) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itemengine-cypress-automation",
3
- "version": "1.0.175-15thAprilRepoUpdate-cb0f7d0.0",
3
+ "version": "1.0.177-figDndMigration-9070657.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {