itemengine-cypress-automation 1.0.331 → 1.0.332

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,236 @@
1
+ import { createdAndUpdatedAtDate, questionAndResourceReferenceIds } from '../../support/helpers/createItem';
2
+ import utilities from "../../support/helpers/utilities";
3
+ var sessionData = {};
4
+ var questionReferenceIds = [];
5
+ var timestamp;
6
+ let itemReferenceIdNew;
7
+
8
+ describe('Save Sessions API', () => {
9
+ before(() => {
10
+ cy.loginAs('admin');
11
+ cy.createItem('SaveSessionTest1');
12
+ cy.wait(5000)
13
+ cy.visit(`${Cypress.env('itemEngineHomePage')}`);
14
+ });
15
+
16
+ after(() => {
17
+ cy.deleteItems();
18
+ cy.logout();
19
+ });
20
+
21
+ it('fetch question reference id from the api', () => {
22
+ cy.contains('Item Bank')
23
+ .click();
24
+ cy.contains('Fetch Questions')
25
+ .click();
26
+ cy.contains('Fetch Questions')
27
+ .parent()
28
+ .parent()
29
+ .should('have.class', 'Mui-selected');
30
+ cy.url()
31
+ .should('eq', Cypress.config().baseUrl + '/item-engine/data-api/item-bank/fetch-questions');
32
+ cy.get('.try-out__btn')
33
+ .click();
34
+ cy.get('textarea[class="body-param__text"]')
35
+ .clear()
36
+ .fill(`{\n "item_references": ["SaveSessionTest1"],\n "references": [],\n "types": [],\n "limit": 50,\n "sort_field": "created",\n "sort": "desc"\n}\n`);
37
+ cy.get('.execute')
38
+ .click();
39
+ cy.wait(2000);
40
+ cy.get('.loading-container')
41
+ .should('not.exist');
42
+ cy.get('pre[class="microlight"]')
43
+ .eq(1)
44
+ .invoke('text')
45
+ .then((text) => {
46
+ // Parse the JSON from the DOM
47
+ const actualResponse = JSON.parse(text);
48
+ // Extract dynamic values from the parsed object
49
+ const test1Data = actualResponse.data.SaveSessionTest1[0];
50
+ const { reference: ref1 } = test1Data;
51
+ itemReferenceIdNew = ref1;
52
+ });
53
+ });
54
+
55
+ it('No responses should be set for an item unless Save Sessions API is run', () => {
56
+ cy.interceptGraphql('createOrUpdateUserSession');
57
+ cy.interceptGraphql('fetchActivity');
58
+ cy.visit(`/item-engine/demo/render-item/student-view/${utilities.base64Encoding(itemReferenceIdNew)}`)
59
+ cy.wait('@createOrUpdateUserSession');
60
+ cy.get('[data-testid="question-instruction-element"]')
61
+ .eq(2)
62
+ .scrollIntoView()
63
+ //mcq question 1
64
+ var checkboxes = ["ChoiceA", "ChoiceB", "ChoiceC", "ChoiceD"];
65
+ cy.get('div[class*="SinglePageAssessmentQuestionsstyles__QuestionPartContainer"]')
66
+ .eq(0)
67
+ .within(() => {
68
+ checkboxes.forEach((i) => {
69
+ cy.get(`input[value="${i}"]`)
70
+ .should('not.be.checked');
71
+ });
72
+ });
73
+
74
+ //Extracting session data
75
+ cy.get('@createOrUpdateUserSession').then((data) => {
76
+ const activityMap = data.request.body.variables.input.sessionData.itemActivityMap[0];
77
+ // Assign values to sessionData
78
+ sessionData["activity_id"] = activityMap.activityId;
79
+ sessionData["user_id"] = activityMap.userId;
80
+ sessionData["session_id"] = activityMap.sessionId;
81
+ });
82
+ //Extracting question reference ids
83
+ cy.get('@fetchActivity').then((resp) => {
84
+ sessionData["activity_template_id"] = resp.response.body.data.fetchActivity.activityTemplateId;
85
+ for (var i = 0; i < resp.response.body.data.fetchActivity.playerData.questions[0].questionParts.length; i++) {
86
+ questionReferenceIds.push(resp.response.body.data.fetchActivity.playerData.questions[0].questionParts[i].referenceId);
87
+ };
88
+ });
89
+ });
90
+
91
+ it('If the user clicks on the Save Sessions option from the menu bar, user should be navigated to the Save Sessions page', () => {
92
+ cy.contains('Sessions', { matchCase: true })
93
+ .click();
94
+ cy.contains('Save Sessions')
95
+ .click();
96
+ cy.contains('Save Sessions')
97
+ .parent()
98
+ .parent()
99
+ .should('have.class', 'Mui-selected');
100
+ cy.url()
101
+ .should('eq', Cypress.config().baseUrl + '/item-engine/data-api/sessions/save-sessions');
102
+ });
103
+
104
+ it('Example Request should be displayed', () => {
105
+ cy.get('pre[class="body-param__example microlight"]')
106
+ .eq(0)
107
+ .should('have.text', `{\n "data": [\n {\n "activity_id": "db27c257-8991-42cb-acec-009c7816cbfa",\n "activity_template_id": "Math problem item",\n "user_id": "5805c32e-51ca-472d-899a-fce07ebf3577",\n "session_id": "6ba1cea0-7a3c-4af0-b72f-c2c8583668c7",\n "scoring_options": [\n "autoscore"\n ],\n "responses": [\n {\n "question_id": "bfc27e-024f-062f-f02-76670545845",\n "is_attempted": true,\n "value": [\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceA"\n },\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceD"\n }\n ]\n }\n ]\n }\n ],\n "organisation_id": "${Cypress.env('organisation_id')}"\n}\n`);
108
+ });
109
+
110
+ it('Example Response for status code 200 should be displayed', () => {
111
+ cy.get('td[class="response-col_status"]')
112
+ .eq(0)
113
+ .should('have.text', '200');
114
+ cy.get('.response-col_description__inner')
115
+ .eq(0)
116
+ .should('have.text', 'OK');
117
+ cy.get('pre[class="example microlight"]')
118
+ .eq(0)
119
+ .should('have.text', "{\n \"meta\": {\n \"status\": true,\n \"timestamp\": 1653650826764\n }\n}\n");
120
+ });
121
+
122
+ it('Example Response for status code 401 should be displayed', () => {
123
+ cy.get('td[class="response-col_status"]')
124
+ .eq(1)
125
+ .should('have.text', '401');
126
+ cy.get('.response-col_description__inner')
127
+ .eq(1)
128
+ .should('have.text', 'Unauthorized');
129
+ cy.get('pre[class="example microlight"]')
130
+ .eq(1)
131
+ .should('have.text', "{\n \"meta\": {\n \"status\": false,\n \"message\": \"Invalid Signature\",\n \"timestamp\": 1653650826764\n }\n}\n");
132
+ });
133
+
134
+ it('Example Response for status code 422 should be displayed', () => {
135
+ cy.get('td[class="response-col_status"]')
136
+ .eq(2)
137
+ .should('have.text', '422');
138
+ cy.get('.response-col_description__inner')
139
+ .eq(2)
140
+ .should('have.text', 'Unprocessable Entity (WebDAV)');
141
+ cy.get('pre[class="example microlight"]')
142
+ .eq(2)
143
+ .should('have.text', "{\n \"meta\": {\n \"status\": false,\n \"message\": \"\\\"data[0].activity_id\\\" is required\",\n \"timestamp\": 1653650826764\n }\n}\n");
144
+ });
145
+
146
+ it('Example Response for status code 500 should be displayed', () => {
147
+ cy.get('td[class="response-col_status"]')
148
+ .eq(3)
149
+ .should('have.text', '500');
150
+ cy.get('.response-col_description__inner')
151
+ .eq(3)
152
+ .should('have.text', 'Internal Server Error');
153
+ cy.get('pre[class="example microlight"]')
154
+ .eq(3)
155
+ .should('have.text', "{\n \"meta\": {\n \"status\": false,\n \"message\": \"Error while saving data\",\n \"timestamp\": 1653650826764\n }\n}\n");
156
+ });
157
+
158
+ it('Entering request with empty activity id', () => {
159
+ cy.get('.try-out__btn')
160
+ .click();
161
+ cy.get('textarea[class="body-param__text"]')
162
+ .clear()
163
+ .fill(`{\n "data": [\n {\n "activity_id": "",\n "activity_template_id": "Math problem item",\n "user_id": "5805c32e-51ca-472d-899a-fce07ebf3577",\n "session_id": "6ba1cea0-7a3c-4af0-b72f-c2c8583668c7",\n "scoring_options": [\n "autoscore"\n ],\n "responses": [\n {\n "question_id": "bfc27e-024f-062f-f02-76670545845",\n "is_attempted": true,\n "value": [\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceA"\n },\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceD"\n }\n ]\n }\n ]\n }\n ]\n}`);
164
+ cy.get('.execute')
165
+ .click();
166
+ cy.wait(2000);
167
+ cy.get('.loading-container')
168
+ .should('not.exist');
169
+ cy.get('pre[class="microlight"]')
170
+ .eq(1)
171
+ .within(() => {
172
+ cy.contains('timestamp')
173
+ .next().next().then((currTimestamp) => {
174
+ timestamp = currTimestamp[0].innerText
175
+ });
176
+ });
177
+ });
178
+
179
+ it('activity_id is not allowed to be empty message should be received in the response, with status code 422', () => {
180
+ cy.get('td[class="response-col_status"]')
181
+ .eq(0)
182
+ .should('have.text', '200');
183
+ cy.get('pre[class="microlight"]')
184
+ .eq(1)
185
+ .should('have.text', `{\n \"meta\": {\n \"message\": \"\\\"data[0].activity_id\\\" is not allowed to be empty\",\n \"timestamp\": ${timestamp},\n \"status\": false\n }\n}\n`);
186
+ });
187
+
188
+ it('Entering request with all correct parameters to set session for an item', () => {
189
+ cy.get('textarea[class="body-param__text"]')
190
+ .clear()
191
+ .fill(`{\n \"data\": [\n {\n \"activity_id\": "${sessionData["activity_id"]}",\n \"activity_template_id\": "${sessionData["activity_template_id"]}",\n \"user_id\": "${sessionData["user_id"]}",\n \"session_id\":"${sessionData["session_id"]}",\n \"scoring_options\": [\n \"autoscore\"\n ],\n \"responses\": [\n {\n \"question_id\": "${questionReferenceIds[0]}",\n \"is_attempted\": true,\n \"value\": [\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceD\"\n },\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceB\"\n }\n ]\n }\n ]\n }\n ]\n}\n`)
192
+ cy.get('.execute')
193
+ .click();
194
+ cy.wait(2000);
195
+ cy.get('.loading-container')
196
+ .should('not.exist');
197
+ cy.get('pre[class="microlight"]')
198
+ .eq(1)
199
+ .within(() => {
200
+ cy.contains('timestamp')
201
+ .next().next().then((currTimestamp) => {
202
+ timestamp = currTimestamp[0].innerText
203
+ });
204
+ });
205
+ });
206
+
207
+ it('Status:true message should be received in the response, with status code 200', () => {
208
+ cy.get('td[class="response-col_status"]')
209
+ .eq(0)
210
+ .should('have.text', '200');
211
+ cy.get('pre[class="microlight"]')
212
+ .eq(1)
213
+ .should('have.text', `{\n \"meta\": {\n \"timestamp\": ${timestamp},\n \"status\": true\n }\n}\n`);
214
+ });
215
+
216
+ it('The responses set via the Save Sessions API should be displayed in the Student view of that item', () => {
217
+ cy.interceptGraphql('createOrUpdateUserSession');
218
+ cy.interceptGraphql('fetchActivity');
219
+ cy.visit(`/item-engine/demo/render-item/student-view/${utilities.base64Encoding(itemReferenceIdNew)}`)
220
+ cy.get('[data-testid="question-instruction-element"]')
221
+ .eq(2)
222
+ .scrollIntoView()
223
+
224
+ //mcq question 1
225
+ var checkboxes = ["ChoiceA", "ChoiceB", "ChoiceC", "ChoiceD"];
226
+ var state1 = ['not.be.checked', 'be.checked', 'not.be.checked', 'be.checked'];
227
+ cy.get('div[class*="SinglePageAssessmentQuestionsstyles__QuestionPartContainer"]')
228
+ .eq(1)
229
+ .within(() => {
230
+ checkboxes.forEach((i, count) => {
231
+ cy.get(`input[value="${i}"]`)
232
+ .should(`${state1[count]}`);
233
+ });
234
+ });
235
+ });
236
+ });
@@ -0,0 +1,381 @@
1
+ import utilities from "../../support/helpers/utilities";
2
+ const domainName = `${Cypress.env('SANDBOX_SERVICES_URL')}`.slice(8);
3
+
4
+ describe('Scores API cases', () => {
5
+ var sessionData = [{}, {}, {}];
6
+ var timestamp;
7
+ var dtScoreUpdateArray = [];
8
+ let itemReferenceIdNew = "a50ba14-5603-b55e-7cc-d17404ce5afb";
9
+ let dt_score_update;
10
+ let response_id;
11
+ let dt_saved;
12
+ let records;
13
+ var responseIds = [];
14
+ var questionReferences = [];
15
+ before(() => {
16
+ cy.loginAs('admin');
17
+ });
18
+
19
+ after(() => {
20
+ cy.logout();
21
+ });
22
+
23
+ it('Setting responses for an item using saveSessions API', () => {
24
+ cy.interceptGraphql('createOrUpdateUserSession');
25
+ cy.interceptGraphql('fetchActivity');
26
+ cy.visit(`/item-engine/demo/render-item/student-view/${utilities.base64Encoding(itemReferenceIdNew)}`)
27
+ cy.wait('@createOrUpdateUserSession');
28
+ cy.get('[data-testid="question-instruction-element"]')
29
+ .eq(2)
30
+ .scrollIntoView()
31
+ //mcq question 1
32
+ var checkboxes = ["ChoiceA", "ChoiceB", "ChoiceC", "ChoiceD"];
33
+ cy.get('div[class*="SinglePageAssessmentQuestionsstyles__QuestionPartContainer"]')
34
+ .eq(0)
35
+ .within(() => {
36
+ checkboxes.forEach((i) => {
37
+ cy.get(`input[value="${i}"]`)
38
+ .should('not.be.checked');
39
+ });
40
+ });
41
+ cy.get('@createOrUpdateUserSession').then((data) => {
42
+ sessionData[0]["activity_id"] = data.request.body.variables.input.sessionData.itemActivityMap[0].activityId;
43
+ sessionData[0]["user_id"] = data.request.body.variables.input.sessionData.itemActivityMap[0].userId;
44
+ sessionData[0]["session_id"] = data.request.body.variables.input.sessionData.itemActivityMap[0].sessionId;
45
+ }).then(() => {
46
+ //Extracting question reference ids and activity template id
47
+ cy.get('@fetchActivity').then((resp) => {
48
+ var questionReferenceIds = [];
49
+ for (var i = 0; i < resp.response.body.data.fetchActivity.playerData.questions[0].questionParts.length; i++) {
50
+ questionReferenceIds.push(resp.response.body.data.fetchActivity.playerData.questions[0].questionParts[i].referenceId);
51
+ };
52
+ sessionData[0]["activity_template_id"] = resp.response.body.data.fetchActivity.activityTemplateId;
53
+ sessionData[0]["questionReferenceIds"] = questionReferenceIds;
54
+ sessionData[0]["question_id"] = resp.response.body.data.fetchActivity.playerData.questions[0].id;
55
+ }).then(() => {
56
+ cy.visit('/item-engine/data-api/sessions/save-sessions');
57
+ cy.get('.try-out__btn')
58
+ .click();
59
+ cy.get('textarea[class="body-param__text"]')
60
+ .clear()
61
+ .fill(`{\n "data": [\n {\n "activity_id": "${sessionData[0]["activity_id"]}",\n "activity_template_id": "${sessionData[0]["activity_template_id"]}",\n "user_id": "${sessionData[0]["user_id"]}",\n "session_id": "${sessionData[0]["session_id"]}",\n "scoring_options": [\n "autoscore"\n ],\n "responses": [\n {\n "question_id": "${sessionData[0]["questionReferenceIds"][0]}",\n "is_attempted": true,\n "value": [\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceA"\n },\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceD"\n }\n ]\n },\n {\n "question_id": "${sessionData[0]["questionReferenceIds"][1]}",\n "is_attempted": true,\n "value": [\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceA"\n },\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceD"\n }\n ]\n },\n {\n "question_id": "${sessionData[0]["questionReferenceIds"][2]}",\n "is_attempted": true,\n "value": [\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceC"\n }\n ]\n },\n {\n "question_id": "${sessionData[0]["questionReferenceIds"][3]}",\n "is_attempted": true,\n "value": [\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceD"\n }\n ]\n },\n {\n "question_id": "${sessionData[0]["questionReferenceIds"][4]}",\n "is_attempted": true,\n "value": [\n {\n "xml_identifier": "RESPONSE",\n "response_text": "<p>Response set using set sessions API</p>\\n"\n }\n ]\n },\n {\n "question_id": "${sessionData[0]["questionReferenceIds"][5]}",\n "is_attempted": true,\n "value": [\n {\n "xml_identifier": "RESPONSE",\n "response_text": "<p>Long text response to reach 100 word limit. Long text response to reach 100 word limit. Long text response to reach 100 word limit. Long text response to reach 100 word limit. Long text response to reach 100 word limit. Long text response to reach 100 word limit. Long text response to reach 100 word limit. Long text response to reach 100 word limit. Long text response to reach 100 word limit. Long text response to reach 100 word limit. Long text response to reach 100 word limit. Long text response to reach 100 word limit. Long text response to reach 100 word limit</p>\\n"\n }\n ]\n },\n {\n "question_id": "${sessionData[0]["questionReferenceIds"][6]}",\n "is_attempted": true,\n "value": [\n {\n "response_text": "{\\\"version\\\":\\\"3.6.3\\\",\\\"objects\\\":[{\\\"type\\\":\\\"image\\\",\\\"version\\\":\\\"3.6.3\\\",\\\"originX\\\":\\\"left\\\",\\\"originY\\\":\\\"top\\\",\\\"left\\\":187.42,\\\"top\\\":100.28,\\\"width\\\":1000,\\\"height\\\":992,\\\"fill\\\":\\\"rgb(0,0,0)\\\",\\\"stroke\\\":null,\\\"strokeWidth\\\":0,\\\"strokeDashArray\\\":null,\\\"strokeLineCap\\\":\\\"butt\\\",\\\"strokeDashOffset\\\":0,\\\"strokeLineJoin\\\":\\\"miter\\\",\\\"strokeMiterLimit\\\":4,\\\"scaleX\\\":0.44,\\\"scaleY\\\":0.4,\\\"angle\\\":0,\\\"flipX\\\":false,\\\"flipY\\\":false,\\\"opacity\\\":1,\\\"shadow\\\":null,\\\"visible\\\":true,\\\"clipTo\\\":null,\\\"backgroundColor\\\":\\\"\\\",\\\"fillRule\\\":\\\"nonzero\\\",\\\"paintFirst\\\":\\\"fill\\\",\\\"globalCompositeOperation\\\":\\\"source-over\\\",\\\"transformMatrix\\\":null,\\\"skewX\\\":0,\\\"skewY\\\":0,\\\"crossOrigin\\\":\\\"\\\",\\\"cropX\\\":0,\\\"cropY\\\":0,\\\"src\\\":\\\"https://twig-next-gen-sandbox-staging.zeuslearning.com/item/file?key=images/b17394b2-0684-4d4a-a4b6-b0cd93c24ba1.png\\\",\\\"filters\\\":[]}]}",\n "xml_identifier": "RESPONSE"\n }\n ]\n }\n ]\n }\n ]\n}`);
62
+ cy.get('.execute')
63
+ .click();
64
+ cy.wait(2000);
65
+ cy.get('.loading-container')
66
+ .should('not.exist');
67
+ });
68
+ });
69
+
70
+ cy.logout();
71
+ cy.loginAs('admin');
72
+ cy.visit(`/item-engine/demo/render-item/student-view/${utilities.base64Encoding(itemReferenceIdNew)}`)
73
+ cy.wait('@createOrUpdateUserSession');
74
+ cy.get('[data-testid="question-instruction-element"]')
75
+ .eq(2)
76
+ .scrollIntoView()
77
+ //mcq question 1
78
+ var checkboxes = ["ChoiceA", "ChoiceB", "ChoiceC", "ChoiceD"];
79
+ cy.get('div[class*="SinglePageAssessmentQuestionsstyles__QuestionPartContainer"]')
80
+ .eq(0)
81
+ .within(() => {
82
+ checkboxes.forEach((i) => {
83
+ cy.get(`input[value="${i}"]`)
84
+ .should('not.be.checked');
85
+ });
86
+ });
87
+
88
+
89
+ //Extracting session data for activity 2 (Incorrect answers)
90
+ cy.get('@createOrUpdateUserSession').then((data) => {
91
+ sessionData[1]["activity_id"] = data.request.body.variables.input.sessionData.itemActivityMap[0].activityId;
92
+ sessionData[1]["user_id"] = data.request.body.variables.input.sessionData.itemActivityMap[0].userId;
93
+ sessionData[1]["session_id"] = data.request.body.variables.input.sessionData.itemActivityMap[0].sessionId;
94
+ sessionData[1]["teacher_id"] = data.request.body.variables.input.sessionData.users[2].id;
95
+ }).then(() => {
96
+ //Extracting question reference ids
97
+ cy.get('@fetchActivity').then((resp) => {
98
+ var questionReferenceIds = [];
99
+ for (var i = 0; i < resp.response.body.data.fetchActivity.playerData.questions[0].questionParts.length; i++) {
100
+ questionReferenceIds.push(resp.response.body.data.fetchActivity.playerData.questions[0].questionParts[i].referenceId);
101
+ };
102
+ sessionData[1]["activity_template_id"] = resp.response.body.data.fetchActivity.activityTemplateId;
103
+ sessionData[1]["questionReferenceIds"] = questionReferenceIds;
104
+ sessionData[1]["question_id"] = resp.response.body.data.fetchActivity.playerData.questions[0].id;
105
+ }).then(() => {
106
+ cy.visit('/item-engine/data-api/sessions/save-sessions');
107
+ cy.get('.try-out__btn')
108
+ .click();
109
+ cy.get('textarea[class="body-param__text"]')
110
+ .clear()
111
+ .fill(`{\n "data": [\n {\n "activity_id": "${sessionData[1]["activity_id"]}",\n "activity_template_id": "${sessionData[1]["activity_template_id"]}",\n "user_id": "${sessionData[1]["user_id"]}",\n "session_id": "${sessionData[1]["session_id"]}",\n "scoring_options": [\n "autoscore"\n ],\n "responses": [\n {\n "question_id": "${sessionData[1]["questionReferenceIds"][0]}",\n "is_attempted": true,\n "value": [\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceB"\n },\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceC"\n }\n ]\n },\n {\n "question_id": "${sessionData[1]["questionReferenceIds"][1]}",\n "is_attempted": true,\n "value": [\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceA"\n },\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceB"\n }\n ]\n },\n {\n "question_id": "${sessionData[1]["questionReferenceIds"][2]}",\n "is_attempted": true,\n "value": [\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceC"\n }\n ]\n },\n {\n "question_id": "${sessionData[1]["questionReferenceIds"][3]}",\n "is_attempted": true,\n "value": [\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceD"\n }\n ]\n }\n ]\n }\n ]\n}`);
112
+ cy.get('.execute')
113
+ .click();
114
+ cy.wait(2000);
115
+ cy.get('.loading-container')
116
+ .should('not.exist');
117
+ });
118
+ });
119
+ });
120
+
121
+ it('If the user clicks on the Scores option from the menu bar, user should be navigated to the Scores API page', () => {
122
+ cy.contains('Scores')
123
+ .click();
124
+ cy.contains('Scores')
125
+ .parent()
126
+ .parent()
127
+ .should('have.class', 'Mui-selected');
128
+ cy.url()
129
+ .should('eq', Cypress.config().baseUrl + '/item-engine/data-api/sessions/fetch-scores');
130
+ });
131
+
132
+ it('Example Request should be displayed', () => {
133
+ cy.get('pre[class="body-param__example microlight"]')
134
+ .eq(0)
135
+ .should('have.text', "{\n \"limit\": 50,\n \"max_time\": \"2023-03-29\",\n \"min_time\": \"2022-03-29\",\n \"sort_field\": \"created\",\n \"sort\": \"asc\",\n \"activity_id\": [\n \"16c96ca3-b6ac-47be-8dc9-093c7cbb752a\"\n ],\n \"session_id\": [\n \"33496ca3-b6ac-47be-8dc9-093c7cbb752a\"\n ],\n \"include_response_scores\": true,\n \"include_percentage_score\": false,\n \"include_item_scores\": false,\n \"status\": [\n \"completed\",\n \"incomplete\"\n ],\n \"user_id\": [\n \"12c96ca3-b6ac-47be-8dc9-093c7cbb752a\"\n ],\n \"organisation_id\": \"eb7d4a20-c96c-4852-9b34-7e3231016315\",\n \"next_token\": [\n 1703069388983,\n \"f86cfbcd-254e-4f3c-add7-d2ab2fffc2e0\"\n ]\n}\n");
136
+ cy.contains('timestamp')
137
+ .next().next().then((currTimestamp) => {
138
+ timestamp = currTimestamp[0].innerText
139
+ });
140
+ });
141
+
142
+ it('Example Response for status code 200 should be displayed', () => {
143
+ cy.get('td[class="response-col_status"]')
144
+ .eq(0)
145
+ .should('have.text', '200');
146
+ cy.get('.response-col_description__inner')
147
+ .eq(0)
148
+ .should('have.text', 'OK');
149
+ cy.get('pre[class="example microlight"]')
150
+ .eq(0)
151
+ .should('have.text', "{\n \"meta\": {\n \"records\": 1,\n \"status\": true,\n \"timestamp\": 1651748805013,\n \"next_token\": [\n 1703069388983,\n \"54c96ca3-b6ac-47be-8dc9-093c7cbb752a\"\n ]\n },\n \"data\": [\n {\n \"activity_id\": \"54c96ca3-b6ac-47be-8dc9-093c7cbb752a\",\n \"user_id\": \"d86a95cc-07fa-4f94-bcb9-1f8f21a0c85e\",\n \"session_id\": \"773e822b-c25a-448a-95c0-d1738d66485c\",\n \"score\": 0,\n \"max_score\": 13,\n \"dt_saved\": \"2022-04-27T23:47:56.085Z\",\n \"status\": \"incomplete\"\n }\n ]\n}\n");
152
+ });
153
+
154
+ it('Example Response for status code 401 should be displayed', () => {
155
+ cy.get('td[class="response-col_status"]')
156
+ .eq(1)
157
+ .should('have.text', '401');
158
+ cy.get('.response-col_description__inner')
159
+ .eq(1)
160
+ .should('have.text', 'Unauthorized');
161
+ cy.get('pre[class="example microlight"]')
162
+ .eq(1)
163
+ .should('have.text', "{\n \"meta\": {\n \"status\": false,\n \"message\": \"Invalid Signature\",\n \"timestamp\": 1653650826764\n },\n \"data\": []\n}\n");
164
+ });
165
+
166
+ it('Example Response for status code 422 should be displayed', () => {
167
+ cy.get('td[class="response-col_status"]')
168
+ .eq(2)
169
+ .should('have.text', '422');
170
+ cy.get('.response-col_description__inner')
171
+ .eq(2)
172
+ .should('have.text', 'Invalid Input Provided');
173
+ cy.get('pre[class="example microlight"]')
174
+ .eq(2)
175
+ .should('have.text', "{\n \"meta\": {\n \"status\": false,\n \"message\": \"Invalid OrganisationId\",\n \"timestamp\": 1653650826764\n },\n \"data\": []\n}\n");
176
+ });
177
+
178
+ it('Example Response for status code 500 should be displayed', () => {
179
+ cy.get('td[class="response-col_status"]')
180
+ .eq(3)
181
+ .should('have.text', '500');
182
+ cy.get('.response-col_description__inner')
183
+ .eq(3)
184
+ .should('have.text', 'Internal Server Error');
185
+ cy.get('pre[class="example microlight"]')
186
+ .eq(3)
187
+ .should('have.text', "{\n \"meta\": {\n \"status\": false,\n \"message\": \"Error occurred while fetching data\",\n \"timestamp\": 1653650826764\n },\n \"data\": []\n}\n");
188
+ });
189
+
190
+ it('Entering request to get scores data for an activity using the user_id and its activity_id(session_id array remains blank)', () => {
191
+ cy.get('.try-out__btn')
192
+ .click();
193
+ cy.get('textarea[class="body-param__text"]')
194
+ .clear()
195
+ .fill(`{\n "limit": 50,\n "sort": "asc",\n "activity_id": ["${sessionData[0]["activity_id"]}"],\n "session_id": [],\n "include_response_scores": true,\n "include_percentage_score": false,\n "status": ["completed","incomplete"],\n "page": 0,\n "user_id": ["${sessionData[0]["user_id"]}"]\n}`);
196
+ cy.get('.execute')
197
+ .click();
198
+ cy.wait(2000);
199
+ cy.get('.loading-container')
200
+ .should('not.exist');
201
+ //Storing the unknown values from the response for assertion
202
+ cy.get('pre[class="microlight"]')
203
+ .eq(1)
204
+ .invoke('text')
205
+ .then((text) => {
206
+ // Parse the JSON from the DOM
207
+ const actualResponse = JSON.parse(text);
208
+ timestamp = actualResponse.meta.timestamp;
209
+ response_id = actualResponse.data[0].responses[0].response_id;
210
+ dt_score_update = actualResponse.data[0].responses[0].dt_score_update; // Assuming dt_completed is equivalent
211
+ dt_saved = actualResponse.data[0].dt_saved;
212
+ });
213
+ });
214
+
215
+ it('Scores data of the activity for the entered user_id should be returned in the response', () => {
216
+ cy.get('pre[class="microlight"]')
217
+ .eq(1)
218
+ .should('have.text', `{\n \"meta\": {\n \"records\": 1,\n \"status\": true,\n \"timestamp\": ${timestamp},\n \"next_token\": null\n },\n \"data\": [\n {\n \"responses\": [\n {\n \"erater\": {\n \"status\": \"NA\"\n },\n \"plagiarism\": {\n \"status\": \"pending\"\n },\n \"points_scored\": 10,\n \"question_reference\": \"${sessionData[0]["questionReferenceIds"][0]}\",\n \"score\": 10,\n \"max_score\": 10,\n \"attempted\": true,\n \"dt_score_update\": \"${dt_score_update}\",\n \"response_id\": \"${response_id}\",\n \"item_reference\": \"${itemReferenceIdNew}\"\n }\n ],\n \"activity_id\": \"${sessionData[0]["activity_id"]}\",\n \"user_id\": \"${sessionData[0]["user_id"]}\",\n \"session_id\": \"${sessionData[0]["session_id"]}\",\n \"score\": 10,\n \"max_score\": 10,\n \"dt_saved\": \"${dt_saved}\",\n \"status\": \"incomplete\"\n }\n ]\n}\n`)
219
+ });
220
+
221
+ it('Entering request to get scores data for an activity using the session_id and its activity_id(user_id array remains blank)', () => {
222
+ //for activity 2
223
+ cy.get('textarea[class="body-param__text"]')
224
+ .clear()
225
+ .fill(`{\n "limit": 50,\n "sort": "asc",\n "activity_id": ["${sessionData[1]["activity_id"]}"],\n "session_id": ["${sessionData[1]["session_id"]}"],\n "include_response_scores": true,\n "status": ["completed","incomplete"],\n "page": 0,\n "user_id": []\n}`);
226
+ cy.get('.execute')
227
+ .click();
228
+ cy.wait(2000);
229
+ cy.get('.loading-container')
230
+ .should('not.exist');
231
+
232
+ //Storing the unknown values from the response for assertion
233
+ cy.get('pre[class="microlight"]')
234
+ .eq(1)
235
+ .invoke('text')
236
+ .then((text) => {
237
+ const actualResponse = JSON.parse(text);
238
+ questionReferences.length = 0;
239
+ responseIds.length = 0;
240
+ actualResponse.data.forEach((dataItem) => {
241
+ dataItem.responses.forEach((response) => {
242
+ // dtScoreUpdateArray.push(response.dt_score_update);
243
+ responseIds.push(response.response_id);
244
+ questionReferences.push(response.question_reference);
245
+ });
246
+ });
247
+ timestamp = actualResponse.meta.timestamp;
248
+ dt_score_update = actualResponse.data[0].responses[0].dt_score_update;
249
+ dt_saved = actualResponse.data[0].dt_saved;
250
+ });
251
+ });
252
+
253
+ it('Scores data of the activity for the entered session_id should be returned in the response', () => {
254
+ cy.get('pre[class="microlight"]')
255
+ .eq(1)
256
+ .should('have.text', `{\n \"meta\": {\n \"records\": 1,\n \"status\": true,\n \"timestamp\": ${timestamp},\n \"next_token\": null\n },\n \"data\": [\n {\n \"responses\": [\n {\n \"erater\": {\n \"status\": \"NA\"\n },\n \"plagiarism\": {\n \"status\": \"pending\"\n },\n \"points_scored\": 0,\n \"question_reference\": \"${questionReferences[0]}\",\n \"score\": 0,\n \"max_score\": 10,\n \"attempted\": true,\n \"dt_score_update\": \"${dt_score_update}\",\n \"response_id\": \"${responseIds[0]}\",\n \"item_reference\": \"${itemReferenceIdNew}\"\n }\n ],\n \"activity_id\": \"${sessionData[1]["activity_id"]}\",\n \"user_id\": \"${sessionData[1]["user_id"]}\",\n \"session_id\": \"${sessionData[1]["session_id"]}\",\n \"score\": 0,\n \"max_score\": 10,\n \"dt_saved\": \"${dt_saved}\",\n \"status\": \"incomplete\"\n }\n ]\n}\n`)
257
+ });
258
+
259
+ it('Entering request with include_response_scores set as false', () => {
260
+ cy.get('textarea[class="body-param__text"]')
261
+ .clear()
262
+ .fill(`{\n "limit": 50,\n "sort": "desc",\n "activity_id": ["${sessionData[1]["activity_id"]}"],\n "session_id": [],\n "include_response_scores": false,\n "status": ["completed","incomplete"],\n "page": 0,\n "user_id": []\n}`);
263
+ cy.get('.execute')
264
+ .click();
265
+ cy.wait(2000);
266
+ cy.get('.loading-container')
267
+ .should('not.exist');
268
+
269
+ //Storing the unknown values from the response for assertion
270
+ cy.get('pre[class="microlight"]')
271
+ .eq(1)
272
+ .invoke('text')
273
+ .then((text) => {
274
+ const actualResponse = JSON.parse(text);
275
+ dt_saved = actualResponse.data[0].dt_saved;
276
+ timestamp = actualResponse.meta.timestamp;
277
+ records = actualResponse.meta.records;
278
+ });
279
+ });
280
+
281
+ it('Scores data of the activity id entered in the request should be returned in the response without the responses array', () => {
282
+ cy.get('pre[class="microlight"]')
283
+ .eq(1)
284
+ .should('have.text', `{\n \"meta\": {\n \"records\": ${records},\n \"status\": true,\n \"timestamp\": ${timestamp},\n \"next_token\": null\n },\n \"data\": [\n {\n \"activity_id\": \"${sessionData[1]["activity_id"]}\",\n \"user_id\": \"${sessionData[1]["user_id"]}\",\n \"session_id\": \"${sessionData[1]["session_id"]}\",\n \"score\": 0,\n \"max_score\": 10,\n \"dt_saved\": \"${dt_saved}\",\n \"status\": \"incomplete\"\n }\n ]\n}\n`)
285
+ });
286
+
287
+ it('Entering request to get scores data for an activity using the activity_id, filtered by user_id and session_id', () => {
288
+ cy.get('textarea[class="body-param__text"]')
289
+ .clear()
290
+ .fill(`{\n "limit": 50,\n "sort": "desc",\n "activity_id": ["${sessionData[0]["activity_id"]}"],\n "session_id": ["${sessionData[0]["session_id"]}"],\n "include_response_scores": true,\n "status": ["completed","incomplete"],\n "page": 0,\n "user_id": ["${sessionData[0]["user_id"]}"]\n}`);
291
+ cy.get('.execute')
292
+ .click();
293
+ cy.wait(2000);
294
+ cy.get('.loading-container')
295
+ .should('not.exist');
296
+ cy.get('pre[class="microlight"]')
297
+ .eq(1)
298
+ .invoke('text')
299
+ .then((text) => {
300
+ // Parse the JSON from the DOM
301
+ const actualResponse = JSON.parse(text);
302
+ timestamp = actualResponse.meta.timestamp;
303
+ response_id = actualResponse.data[0].responses[0].response_id;
304
+ dt_score_update = actualResponse.data[0].responses[0].dt_score_update;
305
+ dt_saved = actualResponse.data[0].dt_saved;
306
+ });
307
+ });
308
+
309
+ it('Scores data for the activity_id entered, filtered by session_id and user_id should be returned in the response', () => {
310
+ cy.get('pre[class="microlight"]')
311
+ .eq(1)
312
+ .should('have.text', `{\n \"meta\": {\n \"records\": 1,\n \"status\": true,\n \"timestamp\": ${timestamp},\n \"next_token\": null\n },\n \"data\": [\n {\n \"responses\": [\n {\n \"erater\": {\n \"status\": \"NA\"\n },\n \"plagiarism\": {\n \"status\": \"pending\"\n },\n \"points_scored\": 10,\n \"question_reference\": \"${sessionData[0]["questionReferenceIds"][0]}\",\n \"score\": 10,\n \"max_score\": 10,\n \"attempted\": true,\n \"dt_score_update\": \"${dt_score_update}\",\n \"response_id\": \"${response_id}\",\n \"item_reference\": \"${itemReferenceIdNew}\"\n }\n ],\n \"activity_id\": \"${sessionData[0]["activity_id"]}\",\n \"user_id\": \"${sessionData[0]["user_id"]}\",\n \"session_id\": \"${sessionData[0]["session_id"]}\",\n \"score\": 10,\n \"max_score\": 10,\n \"dt_saved\": \"${dt_saved}\",\n \"status\": \"incomplete\"\n }\n ]\n}\n`)
313
+ });
314
+
315
+ it.skip('Entering request to get scores data for an activity filtered by status- completed', () => {
316
+ //for activity 3
317
+ cy.get('textarea[class="body-param__text"]')
318
+ .clear()
319
+ .fill(`{\n "limit": 50,\n "maxtime": "",\n "mintime": "2022-03-29",\n "sort": "asc",\n "activity_id": ["${sessionData[2]["activity_id"]}"],\n "session_id": ["${sessionData[2]["session_id"]}"],\n "include_response_scores": true,\n "status": ["completed","incomplete"],\n "page": 0,\n "user_id": []\n}`);
320
+ cy.get('.execute')
321
+ .click();
322
+ cy.wait(2000);
323
+ cy.get('.loading-container')
324
+ .should('not.exist');
325
+
326
+ //Storing the unknown values from the response for assertion
327
+ cy.get('pre[class=" microlight"]')
328
+ .eq(0)
329
+ .within(() => {
330
+ cy.contains('\"dt_saved\"')
331
+ .eq(0)
332
+ .next().next().then((id) => {
333
+ var dt_saved = id[0].innerText
334
+ sessionData[2]["dt_saved"] = dt_saved.replace(/"/g, '');
335
+ });
336
+ cy.contains('\"dt_score_update\"')
337
+ .eq(0)
338
+ .next().next().then((id) => {
339
+ var dt_score_update = id[0].innerText
340
+ sessionData[2]["dt_score_update"] = dt_score_update.replace(/"/g, '');
341
+ });
342
+ cy.contains('timestamp')
343
+ .next().next().then((currTimestamp) => {
344
+ timestamp = currTimestamp[0].innerText
345
+ });
346
+ });
347
+ });
348
+
349
+ it.skip('If the entered activity_id is in completed state, filtered data array should be returned in the response', () => {
350
+ cy.get('pre[class=" microlight"]')
351
+ .eq(0)
352
+ .should('have.text', `{\n "meta": {\n "records": 1,\n "status": true,\n "timestamp": ${timestamp}\n },\n "data": [\n {\n "responses": [\n {\n "plagiarism": {},\n "erater": {},\n "points_scored": 2,\n "question_reference": "${sessionData[2]["questionReferenceIds"][0]}",\n "max_score": 10,\n "attempted": true,\n "dt_score_update": "${sessionData[2]["dt_score_update"]}",\n "response_id": ${sessionData[2]["responseIdsArray"]},\n "item_reference": "sessionsAPIAutogradedItem"\n }\n ],\n "activity_id": "${sessionData[2]["activity_id"]}",\n "user_id": "${sessionData[2]["user_id"]}",\n "session_id": "${sessionData[2]["session_id"]}",\n "score": 2,\n "max_score": 10,\n "dt_saved": "${sessionData[2]["dt_saved"]}",\n "status": "completed"\n }\n ]\n}\n`);
353
+ });
354
+
355
+ it('Entering request with incorrect combination of activity_id, session_id & response_id', () => {
356
+ cy.get('textarea[class="body-param__text"]')
357
+ .clear()
358
+ .fill(`{\n "limit": 50,\n "sort": "asc",\n "activity_id": ["${sessionData[0]["activity_id"]}"],\n "session_id": ["${sessionData[1]["session_id"]}"],\n "include_response_scores": true,\n "status": ["completed"],\n "page": 0,\n "user_id": ["${sessionData[0]["user_id"]}"]\n}`);
359
+ cy.get('.execute')
360
+ .click();
361
+ cy.wait(2000);
362
+ cy.get('.loading-container')
363
+ .should('not.exist');
364
+
365
+ //Storing the unknown values from the response for assertion
366
+ cy.get('pre[class="microlight"]')
367
+ .eq(1)
368
+ .within(() => {
369
+ cy.contains('timestamp')
370
+ .next().next().then((currTimestamp) => {
371
+ timestamp = currTimestamp[0].innerText
372
+ });
373
+ });
374
+ });
375
+
376
+ it('Blank data array should be returned in the response', () => {
377
+ cy.get('pre[class="microlight"]')
378
+ .eq(1)
379
+ .should('have.text', `{\n \"meta\": {\n \"records\": 0,\n \"status\": true,\n \"timestamp\": ${timestamp},\n \"next_token\": null\n },\n \"data\": []\n}\n`)
380
+ });
381
+ });