itemengine-cypress-automation 1.0.176-figDndMigration-409c782.0 → 1.0.177-contentBlocksScript-b1350d4.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.
@@ -155,13 +155,13 @@ Cypress.Commands.add('learnosityLoaderWait', () => {
155
155
  });
156
156
 
157
157
  Cypress.Commands.add('lazyLoadPreviewQuestions', (count, retries = 5) => {
158
- iePage.questionWrapper()
158
+ iePage.questionAndResourceWrapper()
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.questionWrapper()
164
+ iePage.questionAndResourceWrapper()
165
165
  .last()
166
166
  .scrollIntoView()
167
167
  .wait(1000);
@@ -32,6 +32,7 @@ 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'),
35
36
  steps: {
36
37
  checkShowAnswersToggle: () => {
37
38
  lrnPage.showAnswersToggle()
@@ -560,6 +561,7 @@ export const extractLrnQuestionData = {
560
561
  cy.log(`Extracting the question instructions and answer input field attributes from question ${index}`);
561
562
  obj.questionIndex = index;
562
563
  obj.questionType = 'shortTextResponse'
564
+ lrnPage.steps.extractQuestionInstructions(obj, index);
563
565
  lrnPage.questionWrapper()
564
566
  .eq(index)
565
567
  .within(() => {
@@ -576,11 +578,11 @@ export const extractLrnQuestionData = {
576
578
  obj.specialCharactersEnabled = true;
577
579
  }
578
580
  });
579
- });
581
+ })
580
582
  lrnQuestionDataArr.push(obj);
581
583
  },
582
584
 
583
- shortTextResponseGrading: (lrnGradingDataArr, index) => {
585
+ shortTextResponseGrading: (lrnQuestionDataArr, index) => {
584
586
  let obj = {};
585
587
  cy.log(`Extracting the question instructions and correct answers from question ${index}`);
586
588
  obj.questionIndex = index;
@@ -596,7 +598,7 @@ export const extractLrnQuestionData = {
596
598
  });
597
599
  };
598
600
  });
599
- lrnGradingDataArr.push(obj);
601
+ lrnQuestionDataArr.push(obj);
600
602
  },
601
603
 
602
604
  uploadResponse: (lrnQuestionDataArr, index) => {
@@ -629,148 +631,34 @@ export const extractLrnQuestionData = {
629
631
  lrnQuestionDataArr.push(obj);
630
632
  },
631
633
 
632
- figDragAndDrop: (lrnQuestionDataArr, index) => {
634
+ contentBlocks: (lrnQuestionDataArr, index) => {
633
635
  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}`);
636
+ cy.log(`Extracting the passage from question ${index}`);
635
637
  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;
638
+ obj.questionType = 'contentBlocks';
639
+ const passageArray = [];
640
+ lrnPage.contentBlocksQuestion()
641
+ .find('p')
642
+ .each(($element) => {
643
+ let innerText = $element[0].innerText;
644
+ passageArray.push(innerText);
706
645
  });
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;
646
+ obj.passageArray = passageArray;
647
+ lrnPage.contentBlocksQuestion()
648
+ .then(($element) => {
649
+ if ($element[0].innerHTML.includes('passage-next-btn')) {
650
+ obj.pagination = true;
651
+ cy.get('.lrn-sharedpassage-index')
652
+ .then(($element) => {
653
+ let innerText = $element[0].innerText;
654
+ let pageCount = innerText.trim().replace(/\s+/g, '');
655
+ obj.pageCount = pageCount;
656
+ });
657
+ } else {
658
+ obj.pagination = false;
659
+ }
772
660
  });
773
- lrnGradingDataArr.push(obj);
661
+ lrnQuestionDataArr.push(obj);
774
662
  }
775
663
 
776
664
  /* 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
- figDragAndDrop: 'Cloze with drag & drop',
15
+ contentBlocks: 'Passage'
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.figDragAndDrop: return extractLrnQuestionData.figDragAndDrop(lrnQuestionDataArr, index);
29
+ case lrnQuestionTypesENUM.contentBlocks: return extractLrnQuestionData.contentBlocks(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 'figDragAndDrop': return verifyIeQuestionData.figDragAndDrop(questionData, index);
46
+ case 'contentBlocks': return verifyIeQuestionData.contentBlocks(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.figDragAndDrop: return extractLrnQuestionData.figDragAndDropGrading(lrnGradingDataArr, index);
60
+ case lrnQuestionTypesENUM.contentBlocks: return cy.log('Resource and tool');
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 'figDragAndDrop': return verifyIeQuestionData.figDragAndDropGrading(questionData, index);
74
+ case 'contentBlocks': return cy.log('Resource and tool');
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;
95
+ let questionCount = req.response.body.data.getItemPreview.item.questionParts.length + req.response.body.data.getItemPreview.item.resources.length;
96
96
  cy.lazyLoadPreviewQuestions(questionCount);
97
97
  });
98
98
  });
@@ -1,5 +1,5 @@
1
- import { essayResponsePage, fillInTheGapsDragAndDropPage, fillInTheGapsTextPage, multipleSelectionPage, textEntryMathPage, uploadResponsePage } from "../../pages";
2
- import { draggableOptionContainer, fillInTheGapsDragAndDropCommonComponents } from "../../pages/components";
1
+ import { contentBlocksPage, essayResponsePage, fillInTheGapsTextPage, multipleSelectionPage, textEntryMathPage, uploadResponsePage } from "../../pages";
2
+ import { draggableOptionContainer } from "../../pages/components";
3
3
  import { singleSelectionPage } from "../../pages/singleSelectionPage"
4
4
  import utilities from "../helpers/utilities";
5
5
  import drawingToolbarOptionsENUM from "./drawingToolbarOptionsENUM";
@@ -9,6 +9,7 @@ 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'),
12
13
  barsPreloader: () => cy.get('[id="question-item-instruction-loader"]'),
13
14
  previewQuestionTextWrapper: () => cy.get('.preview-question-text-wrapper'),
14
15
  //textEntryMathResponseWrapper: () => cy.get('.cloze-math-preview-wrapper .cloze-math-response-input-field'),
@@ -19,6 +20,7 @@ export const iePage = {
19
20
  essayResponseWordLimit: () => cy.get('.input-limit-label'),
20
21
  essayResponseWordCount: () => cy.get('[class*="indexstyle__WordCharCountWrapper"]'),
21
22
  essayResponseFooter: () => cy.get('.essay-character-view-wrapper'),
23
+ essayResponseLoader: () => cy.get('[class*="InlineLoaderstyles__LoaderDiv"] img'),
22
24
  drawingResponseToolbarButton: () => cy.get('[class*="DrawingToolButtonstyled__Container"] svg'),
23
25
  drawingResponseLowerCanvas: () => cy.get('.lower-canvas'),
24
26
  figCorrectAnswerBlock: () => cy.get('[class*="AnswerCell"]'),
@@ -244,6 +246,9 @@ export const verifyIeQuestionData = {
244
246
  cy.get('[class*="ngie-essay-response"]')
245
247
  .eq(index)
246
248
  .within(() => {
249
+ iePage.essayResponseLoader()
250
+ .scrollIntoView()
251
+ .should('not.be.visible');
247
252
  iePage.steps.verifyQuestionInstructions(expectedQuestionData);
248
253
  essayResponsePage.responseField()
249
254
  .then(($element) => {
@@ -289,6 +294,9 @@ export const verifyIeQuestionData = {
289
294
  cy.get('[class*="ngie-essay-response"]')
290
295
  .eq(index)
291
296
  .within(() => {
297
+ iePage.essayResponseLoader()
298
+ .scrollIntoView()
299
+ .should('not.be.visible');
292
300
  iePage.steps.verifyQuestionInstructions(expectedQuestionData);
293
301
  essayResponsePage.responseField()
294
302
  .then(($element) => {
@@ -556,7 +564,7 @@ export const verifyIeQuestionData = {
556
564
  });
557
565
  } else {
558
566
  utilities.verifyElementVisibilityState(iePage.shortTextResponseCorrectAnswerText(), 'notExist');
559
- };
567
+ }
560
568
  });
561
569
  },
562
570
 
@@ -595,123 +603,28 @@ export const verifyIeQuestionData = {
595
603
  });
596
604
  },
597
605
 
598
- figDragAndDrop: (expectedQuestionData, index) => {
599
- cy.get('.ngie-cloze-with-drag-and-drop')
606
+ contentBlocks: (expectedQuestionData, index) => {
607
+ cy.get('[class*="ContentBlocksPreviewstyles__ContentBlocksPreviewWrapper"]')
600
608
  .eq(index)
601
609
  .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);
610
+ contentBlocksPage.contentWrapperPreviewTab()
611
+ .find('p')
612
+ .each(($element, index) => {
613
+ let innerText = $element[0].innerText;
614
+ expect(innerText).to.be.eq(expectedQuestionData.passageArray[index]);
615
+ });
616
+ if (expectedQuestionData.pagination) {
617
+ cy.get('.content-blocks-pagination')
618
+ .should('exist');
619
+ //Unable to check the passage on all pages, checked only for first page
620
+ contentBlocksPage.paginationText()
621
+ .then(($element) => {
622
+ let pageCount = $element[0].innerText;
623
+ let pageCountText = pageCount.trim().replace(/\s+/g, '');
624
+ expect(pageCountText).to.be.eq(expectedQuestionData.pageCount);
662
625
  });
663
626
  }
664
627
  });
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
- });
715
628
  }
716
629
 
717
630
  /* singleSelection: (expectedQuestionData, index) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itemengine-cypress-automation",
3
- "version": "1.0.176-figDndMigration-409c782.0",
3
+ "version": "1.0.177-contentBlocksScript-b1350d4.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {