itemengine-cypress-automation 1.0.174 → 1.0.176-figDndMigration-409c782.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cypress/support/migrationHelpers/extractLrnQuestionData.js +147 -4
- package/cypress/support/migrationHelpers/lrnQestionTypesENUM.js +2 -1
- package/cypress/support/migrationHelpers/migrationScript.js +4 -0
- package/cypress/support/migrationHelpers/verifyIeQuestionData.js +122 -3
- package/package.json +2 -2
@@ -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: (
|
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
|
-
|
599
|
+
lrnGradingDataArr.push(obj);
|
601
600
|
},
|
602
601
|
|
603
602
|
uploadResponse: (lrnQuestionDataArr, index) => {
|
@@ -630,6 +629,150 @@ 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().eq(0).invoke('attr', 'class').then(classAttribute => {
|
695
|
+
const classList = classAttribute.split(' ');
|
696
|
+
if (classList.includes('lrn_btn_no_handle')) {
|
697
|
+
dragHandleVisibility = false;
|
698
|
+
} else {
|
699
|
+
dragHandleVisibility = true;
|
700
|
+
}
|
701
|
+
obj.dragHandleVisibility = dragHandleVisibility;
|
702
|
+
});
|
703
|
+
obj.options = options;
|
704
|
+
obj.optionImages = optionImages;
|
705
|
+
obj.optionEquations = optionEquations;
|
706
|
+
});
|
707
|
+
lrnQuestionDataArr.push(obj);
|
708
|
+
},
|
709
|
+
|
710
|
+
figDragAndDropGrading: (lrnGradingDataArr, index) => {
|
711
|
+
let obj = {};
|
712
|
+
cy.log(`Extracting the question instructions, response area count and correct answers from question ${index}`);
|
713
|
+
obj.questionIndex = index;
|
714
|
+
obj.questionType = 'figDragAndDrop';
|
715
|
+
lrnPage.steps.extractQuestionInstructions(obj, index);
|
716
|
+
lrnPage.questionWrapper()
|
717
|
+
.eq(index)
|
718
|
+
.within(() => {
|
719
|
+
lrnPage.questionContainerPreviewTab()
|
720
|
+
.then(($question) => {
|
721
|
+
let innerText = $question[0].innerText;
|
722
|
+
obj.previewQuestion = innerText;
|
723
|
+
});
|
724
|
+
lrnPage.clozeResponse()
|
725
|
+
.then(($responseFields) => {
|
726
|
+
obj.previewResponseCount = $responseFields.length;
|
727
|
+
});
|
728
|
+
let correctAnswers = [];
|
729
|
+
//correctAnswer
|
730
|
+
cy.get('.lrn_correctAnswerList li')
|
731
|
+
.each(($answers) => {
|
732
|
+
let answerData = {}
|
733
|
+
cy.wrap($answers)
|
734
|
+
.within(() => {
|
735
|
+
cy.get('.lrn_responseIndex')
|
736
|
+
.then(($element) => {
|
737
|
+
let answerNumeration = $element[0].innerText;
|
738
|
+
answerData.answerNumeration = answerNumeration;
|
739
|
+
});
|
740
|
+
let options = []
|
741
|
+
cy.get('.lrn_responseText')
|
742
|
+
.each(($option, index) => {
|
743
|
+
let optionData = {}
|
744
|
+
let innerText = $option[0].innerText;
|
745
|
+
optionData.innerText = innerText;
|
746
|
+
let innerHTML = $option[0].innerHTML;
|
747
|
+
if (innerHTML.includes('<img')) {
|
748
|
+
cy.get('.lrn_responseText')
|
749
|
+
.eq(index)
|
750
|
+
.find('img')
|
751
|
+
.then(($img) => {
|
752
|
+
let altText = $img[0].alt;
|
753
|
+
optionData.altText = altText;
|
754
|
+
});
|
755
|
+
}
|
756
|
+
if (innerHTML.includes('<math')) {
|
757
|
+
cy.get('.lrn_responseText')
|
758
|
+
.eq(index)
|
759
|
+
.find('math')
|
760
|
+
.then(($element) => {
|
761
|
+
let outerHtml = $element[0].outerHTML;
|
762
|
+
optionData.equation = outerHtml;
|
763
|
+
});
|
764
|
+
}
|
765
|
+
options.push(optionData);
|
766
|
+
});
|
767
|
+
answerData.options = options
|
768
|
+
});
|
769
|
+
correctAnswers.push(answerData);
|
770
|
+
});
|
771
|
+
obj.correctAnswers = correctAnswers;
|
772
|
+
});
|
773
|
+
lrnGradingDataArr.push(obj);
|
774
|
+
}
|
775
|
+
|
633
776
|
/* singleSelection: (lrnQuestionDataArr, index) => {
|
634
777
|
let obj = {};
|
635
778
|
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.
|
3
|
+
"version": "1.0.176-figDndMigration-409c782.0",
|
4
4
|
"description": "",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -35,4 +35,4 @@
|
|
35
35
|
"node-fetch": "^3.3.2",
|
36
36
|
"react-uuid": "^2.0.0"
|
37
37
|
}
|
38
|
-
}
|
38
|
+
}
|