itemengine-cypress-automation 1.0.385 → 1.0.386-IEI-5793-73a4fdf.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.
@@ -0,0 +1,156 @@
1
+
2
+ import { singleSelectionPage, createItemPage, studentViewPage, gradingGridViewPage } from "../../pages";
3
+ import utilities from '../../support/helpers/utilities';
4
+ import { browseItemsPage } from "../../pages/components";
5
+
6
+ describe('Test grading view with multiple session and student Ids', { tags: 'smoke' }, () => {
7
+ const studentIds = [];
8
+ const sessionIds = [];
9
+ let itemId = '';
10
+ const responseIds = [];
11
+ const updateStudentsAndItemData = () => {
12
+ const interval = setInterval(() => {
13
+ const itemActivityMap = JSON.parse(window.localStorage.getItem(`ngie_itemActivityMap`) || '[]');
14
+ if (itemActivityMap.length > 0) {
15
+ itemActivityMap.forEach(({
16
+ sessionId, userId
17
+ }) => {
18
+ studentIds.push(userId);
19
+ sessionIds.push(sessionId);
20
+ });
21
+ clearInterval(interval);
22
+ }
23
+ }, 100);
24
+ }
25
+ const updateResposneIds = (response) => {
26
+ const {
27
+ body: {
28
+ data: {
29
+ gradingMultipleSession: {
30
+ sessionData = [],
31
+ } = {},
32
+ } = {},
33
+ } = {},
34
+ } = response;
35
+ sessionData.forEach(({items}) => {
36
+ items.forEach(({questions}) => {
37
+ questions.forEach((question) => {
38
+ responseIds.push(question.responseId);
39
+ });
40
+ });
41
+ })
42
+ }
43
+ before(() => {
44
+ cy.loginAs('admin');
45
+ cy.setGraphqlWait();
46
+ singleSelectionPage.steps.navigateToCreateQuestion('single selection');
47
+ singleSelectionPage.steps.createBasicSingleSelectionQuestion({
48
+ questionInstruction: "Question 1",
49
+ options: ["Option 1", "Option 2", "Option 3", "Option 4"],
50
+ correctAnswer: 2,
51
+ points: 10,
52
+ });
53
+ singleSelectionPage.steps.clickOnAddQuestion();
54
+ singleSelectionPage.steps.selectQuestionType('single selection');
55
+ singleSelectionPage.steps.createBasicSingleSelectionQuestion({
56
+ questionInstruction: "Question 2",
57
+ options: ["Option 5", "Option 6", "Option 7", "Option 8"],
58
+ correctAnswer: 3,
59
+ points: 10,
60
+ });
61
+ createItemPage.referenceId()
62
+ .invoke('text')
63
+ .then(text => {
64
+ itemId = text;
65
+ cy.visit(`/item-engine/demo/render-item/student-view/${utilities.base64Encoding(itemId)}`);
66
+ });
67
+ cy.then(() => {
68
+ updateStudentsAndItemData();
69
+ });
70
+ cy.pageLoadWait();
71
+
72
+ cy.then(() => {
73
+ singleSelectionPage.optionsWrapperStudentView()
74
+ .eq(2)
75
+ .click();
76
+ singleSelectionPage.optionsWrapperStudentView()
77
+ .eq(4)
78
+ .click();
79
+ studentViewPage.steps.submitResponse();
80
+ })
81
+
82
+ cy.logout();
83
+ cy.loginAs('admin').then(() => {
84
+ cy.visit(`/item-engine/demo/render-item/student-view/${utilities.base64Encoding(itemId)}`)
85
+ cy.then(() => {
86
+ updateStudentsAndItemData();
87
+ });
88
+ cy.pageLoadWait();
89
+ cy.then(() => {
90
+ singleSelectionPage.optionsWrapperStudentView()
91
+ .eq(3)
92
+ .click();
93
+ singleSelectionPage.optionsWrapperStudentView()
94
+ .eq(7)
95
+ .click();
96
+ studentViewPage.steps.submitResponse();
97
+ })
98
+ });
99
+
100
+ cy.visit('/item-engine/grading-grid-view');
101
+
102
+ });
103
+ describe('Launch grading grid view for each session', { tags: 'smoke' }, () => {
104
+ it('Should launch with correct Item and responses', () => {
105
+ gradingGridViewPage.steps.addSessionDataAndLaunchGrading({studentIds, sessionIds});
106
+
107
+ cy.interceptGraphql("gradingMultipleSession");
108
+
109
+ // waiting for signed request to be completed
110
+ cy.pageLoadWait()
111
+ // waiting for grading multiple session data to be loaded
112
+ cy.wait('@gradingMultipleSession').then(({response}) => {
113
+ updateResposneIds(response);
114
+ });
115
+
116
+ gradingGridViewPage.steps.verifySessionData(
117
+ sessionIds[0],
118
+ itemId,
119
+ 0,
120
+ 'Question 1',
121
+ 'Your answer iscorrect'
122
+ );
123
+ gradingGridViewPage.steps.verifySessionData(
124
+ sessionIds[0],
125
+ itemId,
126
+ 1,
127
+ 'Question 2',
128
+ 'Your answer isincorrect'
129
+ );
130
+ gradingGridViewPage.steps.verifySessionData(
131
+ sessionIds[1],
132
+ itemId,
133
+ 0,
134
+ 'Question 1',
135
+ 'Your answer isincorrect'
136
+ )
137
+ gradingGridViewPage.steps.verifySessionData(
138
+ sessionIds[1],
139
+ itemId,
140
+ 1,
141
+ 'Question 2',
142
+ 'Your answer iscorrect'
143
+ );
144
+ });
145
+ it('Should launch single question for the responseId', () => {
146
+ gradingGridViewPage.steps.addSessionDataAndLaunchGrading({
147
+ studentIds: [studentIds[0]],
148
+ sessionIds: [sessionIds[0]],
149
+ responseIds: [responseIds[0]],
150
+ });
151
+
152
+ gradingGridViewPage.getGradingViewforResponseId(responseIds[0])
153
+ .should('be.visible');
154
+ })
155
+ })
156
+ })
@@ -0,0 +1,64 @@
1
+ import utilities from "../support/helpers/utilities";
2
+ import { verifyIeQuestionData } from "../support/migrationHelpers/verifyIeQuestionData";
3
+
4
+ const selectors = {
5
+ sessionIdField: () => cy.get('[data-testid="SessionId"]'),
6
+ responseIdField: () => cy.get('[data-testid="ResponseId"]'),
7
+ itemIdField: () => cy.get('[data-testid="ItemId"]'),
8
+ studentIdField: () => cy.get('[data-testid="StudentId"]'),
9
+ launchGradingButton: () => cy.get('[data-testid="launchGrading"]'),
10
+ getgradingViewContainer: (sessionId, itemId, questionNo) =>
11
+ cy.get(`[data-reference="${sessionId}"] [data-reference="${itemId}_${sessionId}"] [class*="GradingViewstyles__SingleQuestionContainer"]`)
12
+ .eq(questionNo),
13
+ getGradingViewforResponseId: (responseId) =>
14
+ cy.get(`[data-reference="${responseId}"]`),
15
+ getquestionInstruction: () => cy.get('[data-testid = "question-instruction-element"]').eq(0),
16
+ getAnswerStatus: () => cy.get('[class*="indexstyle__AnswerTextWrapper"]'),
17
+ };
18
+
19
+ const steps = {
20
+ /**
21
+ * Adds session data and launches the grading view.
22
+ *
23
+ * @param {Object} params - Parameters for session setup and grading.
24
+ * @param {Array<string>} params.studentIds - Array of studentIds to be graded.
25
+ * @param {Array<string>} params.studentIds - Array of sessionIds to be graded.
26
+ * @param {Array<string>} params.itemIds - Array of item IDs involved in the session.
27
+ * @param {Array<string>} params.responseIds - Array of response IDs corresponding to each student/item.
28
+ */
29
+ addSessionDataAndLaunchGrading: ({studentIds = [], sessionIds = [], itemIds = [], responseIds = []}) => {
30
+ const students = studentIds.join(", ");
31
+ const sessions = sessionIds.join(", ");
32
+ const Items = itemIds.join(", ");
33
+ const responses = responseIds.join(", ");
34
+ sessions && gradingGridViewPage.sessionIdField().clear().type(sessions);
35
+ students && gradingGridViewPage.studentIdField().clear().type(students);
36
+ Items && gradingGridViewPage.itemIdField().clear().type(Items);
37
+ responses && gradingGridViewPage.responseIdField().clear().type(responses);
38
+ gradingGridViewPage.launchGradingButton().click();
39
+ },
40
+
41
+ /**
42
+ * Verifies the session data displayed in the grading view container for a specific question.
43
+ *
44
+ * @param {string} sessionId - The unique identifier for the session.
45
+ * @param {string} itemId - The unique identifier for the item within the session.
46
+ * @param {number} questionNo - The zero-based index of the question to verify.
47
+ * @param {string} questionInstruction - The expected instruction text for the question.
48
+ * @param {string} answerStatus - The expected answer status (e.g., "Answered", "Not Answered").
49
+ */
50
+ verifySessionData: (sessionId, itemId, questionNo, questionInstruction, answerStatus) => {
51
+ gradingGridViewPage.getgradingViewContainer(sessionId, itemId, questionNo)
52
+ .within(() => {
53
+ gradingGridViewPage.getquestionInstruction()
54
+ .should('contain.text', questionInstruction);
55
+ gradingGridViewPage.getAnswerStatus()
56
+ .should('contain.text', answerStatus);
57
+ });
58
+ },
59
+ };
60
+
61
+ export const gradingGridViewPage = {
62
+ ...selectors,
63
+ steps
64
+ };
@@ -54,3 +54,4 @@ export * from './numberLineLabelPage';
54
54
  export * from './chartsDotPlotPage';
55
55
  export * from './imageHighlightPage';
56
56
  export * from './compassPage';
57
+ export * from './gradingGridViewPage';
@@ -704,7 +704,36 @@ const steps = {
704
704
  optionsTextArray.forEach((option, optionIndex) => {
705
705
  utilities.verifyTextContent(utilities.getNthElement(singleSelectionPage.optionsInputFieldInQuestionPreviewTab(), optionIndex), option);
706
706
  });
707
- }
707
+ },
708
+
709
+ /**
710
+ * @description. Checks the options checkbox in the 'Specify correct answer' section for multiple selection questions.
711
+ * @param {number} optionIndex - The index of the option checkbox to be checked.
712
+ * @throws {Error} Will throw an error if the checkbox is not checked after the operation.
713
+ * @example - checkOptionsCheckboxInSpecifyCorrectAnswerSection(0);
714
+ */
715
+ setcorrectAnswer: (optionIndex) => {
716
+ singleSelectionPage.optionWrapperCorrectAnswerSection()
717
+ .eq(optionIndex)
718
+ .click()
719
+ },
720
+
721
+ /**
722
+ * Creates a basic single selection question
723
+ * @param {Object} params - Parameters for the question.
724
+ * @param {string} params.questionInstruction - The question text.
725
+ * @param {Array<string>} params.options - The list of options.
726
+ * @param {number} params.points - The points allotted for the question.
727
+ * @param {number} params.correctAnswer - Index of the correct answer.
728
+ */
729
+ createBasicSingleSelectionQuestion: ({questionInstruction, options, points, correctAnswer}) => {
730
+ cy.barsPreLoaderWait();
731
+ singleSelectionPage.steps.addTextInQuestionInstructionsInputField(questionInstruction);
732
+ singleSelectionPage.steps.addInputToOptionsInputField(options);
733
+ singleSelectionPage.steps.allotPoints(points);
734
+ singleSelectionPage.steps.setcorrectAnswer(correctAnswer);
735
+ singleSelectionPage.saveQuestionButton().click();
736
+ },
708
737
  };
709
738
 
710
739
  const tests = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itemengine-cypress-automation",
3
- "version": "1.0.385",
3
+ "version": "1.0.386-IEI-5793-73a4fdf.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -52,4 +52,4 @@
52
52
  "devDependencies": {
53
53
  "@applitools/eyes-cypress": "^3.47.0"
54
54
  }
55
- }
55
+ }