itemengine-cypress-automation 1.0.331-e2eFixes4thMarch-e038ad7.0 → 1.0.331

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itemengine-cypress-automation",
3
- "version": "1.0.331-e2eFixes4thMarch-e038ad7.0",
3
+ "version": "1.0.331",
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
+ }
@@ -1,443 +0,0 @@
1
- import { createdAndUpdatedAtDate, questionAndResourceReferenceIds } from '../../support/helpers/createItem';
2
- import utilities from "../../support/helpers/utilities";
3
-
4
- describe('Fetch Responses API', () => {
5
- var sessionData = [{}, {}, {}];
6
- var timestamp;
7
- let itemReferenceIdNew;
8
- var responseIds = [];
9
- var questionReferences = [];
10
- let dtStartedNew;
11
- let dtCompletedNew;
12
- let dtStartedNew1;
13
- let dtCompletedNew1;
14
- let activityTemplateIdNew;
15
- let activityTemplateIdNew1;
16
- before(() => {
17
- cy.loginAs('admin');
18
- cy.createItem('FetchResponseTest1');
19
- cy.wait(5000)
20
- cy.visit(`${Cypress.env('itemEngineHomePage')}`);
21
- });
22
-
23
- after(() => {
24
- cy.deleteItems();
25
- cy.logout();
26
- });
27
-
28
- it('fetch question reference id from the api', () => {
29
- cy.contains('Item Bank')
30
- .click();
31
- cy.contains('Fetch Questions')
32
- .click();
33
- cy.contains('Fetch Questions')
34
- .parent()
35
- .parent()
36
- .should('have.class', 'Mui-selected');
37
- cy.url()
38
- .should('eq', Cypress.config().baseUrl + '/item-engine/data-api/item-bank/fetch-questions');
39
- cy.get('.try-out__btn')
40
- .click();
41
- cy.get('textarea[class="body-param__text"]')
42
- .clear()
43
- .fill(`{\n "item_references": ["FetchResponseTest1"],\n "references": [],\n "types": [],\n "limit": 50,\n "sort_field": "created",\n "sort": "desc"\n}\n`);
44
- cy.get('.execute')
45
- .click();
46
- cy.wait(2000);
47
- cy.get('.loading-container')
48
- .should('not.exist');
49
- cy.get('pre[class="microlight"]')
50
- .eq(1)
51
- .invoke('text')
52
- .then((text) => {
53
- // Parse the JSON from the DOM
54
- const actualResponse = JSON.parse(text);
55
- const test1Data = actualResponse.data.FetchResponseTest1[0];
56
- const { reference: ref1 } = test1Data;
57
- itemReferenceIdNew = ref1;
58
- });
59
- });
60
-
61
- it('Setting responses for an item using saveSessions API', () => {
62
- cy.interceptGraphql('createOrUpdateUserSession');
63
- cy.interceptGraphql('fetchActivity');
64
- cy.visit(`/item-engine/demo/render-item/student-view/${utilities.base64Encoding(itemReferenceIdNew)}`)
65
- cy.wait('@createOrUpdateUserSession');
66
- cy.get('[data-testid="question-instruction-element"]')
67
- .eq(2)
68
- .scrollIntoView()
69
- //mcq question 1
70
- var checkboxes = ["ChoiceA", "ChoiceB", "ChoiceC", "ChoiceD"];
71
- cy.get('div[class*="SinglePageAssessmentQuestionsstyles__QuestionPartContainer"]')
72
- .eq(0)
73
- .within(() => {
74
- checkboxes.forEach((i) => {
75
- cy.get(`input[value="${i}"]`)
76
- .should('not.be.checked');
77
- });
78
- });
79
-
80
- //Extracting session data for activity 1 (All correct answers)
81
- cy.get('@createOrUpdateUserSession').then((data) => {
82
- sessionData[0]["activity_id"] = data.request.body.variables.input.sessionData.itemActivityMap[0].activityId;
83
- sessionData[0]["user_id"] = data.request.body.variables.input.sessionData.itemActivityMap[0].userId;
84
- sessionData[0]["session_id"] = data.request.body.variables.input.sessionData.itemActivityMap[0].sessionId;
85
- }).then(() => {
86
- //Extracting question reference ids
87
- cy.get('@fetchActivity').then((resp) => {
88
- sessionData[0]["activity_template_id"] = resp.response.body.data.fetchActivity.activityTemplateId;
89
- var questionReferenceIds = [];
90
- for (var i = 0; i < resp.response.body.data.fetchActivity.playerData.questions[0].questionParts.length; i++) {
91
- questionReferenceIds.push(resp.response.body.data.fetchActivity.playerData.questions[0].questionParts[i].referenceId);
92
- };
93
- sessionData[0]["questionReferenceIds"] = questionReferenceIds;
94
- sessionData[0]["question_id"] = resp.response.body.data.fetchActivity.playerData.questions[0].id;
95
- }).then(() => {
96
- cy.visit('/item-engine/data-api/sessions/save-sessions');
97
- cy.get('.try-out__btn')
98
- .click();
99
- cy.get('textarea[class="body-param__text"]')
100
- .clear()
101
- .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"]}", "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}`);
102
- cy.get('.execute')
103
- .click();
104
- cy.wait(2000);
105
- cy.get('.loading-container')
106
- .should('not.exist');
107
- });
108
- });
109
-
110
- cy.logout();
111
- cy.loginAs('admin');
112
- cy.visit(`/item-engine/demo/render-item/student-view/${utilities.base64Encoding(itemReferenceIdNew)}`)
113
- cy.wait('@createOrUpdateUserSession');
114
- cy.get('[data-testid="question-instruction-element"]')
115
- .eq(2)
116
- .scrollIntoView()
117
- //mcq question 1
118
- var checkboxes = ["ChoiceA", "ChoiceB", "ChoiceC", "ChoiceD"];
119
- cy.get('div[class*="SinglePageAssessmentQuestionsstyles__QuestionPartContainer"]')
120
- .eq(0)
121
- .within(() => {
122
- checkboxes.forEach((i) => {
123
- cy.get(`input[value="${i}"]`)
124
- .should('not.be.checked');
125
- });
126
- });
127
-
128
- //Extracting session data for activity 2 (Incorrect answers)
129
- cy.get('@createOrUpdateUserSession').then((data) => {
130
- sessionData[1]["activity_id"] = data.request.body.variables.input.sessionData.itemActivityMap[0].activityId;
131
- sessionData[1]["user_id"] = data.request.body.variables.input.sessionData.itemActivityMap[0].userId;
132
- sessionData[1]["session_id"] = data.request.body.variables.input.sessionData.itemActivityMap[0].sessionId;
133
- }).then(() => {
134
- //Extracting question reference ids
135
- cy.get('@fetchActivity').then((resp) => {
136
- sessionData[1]["activity_template_id"] = resp.response.body.data.fetchActivity.activityTemplateId;
137
- var questionReferenceIds = [];
138
- for (var i = 0; i < resp.response.body.data.fetchActivity.playerData.questions[0].questionParts.length; i++) {
139
- questionReferenceIds.push(resp.response.body.data.fetchActivity.playerData.questions[0].questionParts[i].referenceId);
140
- };
141
- sessionData[1]["questionReferenceIds"] = questionReferenceIds;
142
- sessionData[1]["question_id"] = resp.response.body.data.fetchActivity.playerData.questions[0].id;
143
- }).then(() => {
144
- cy.visit('/item-engine/data-api/sessions/save-sessions');
145
- cy.get('.try-out__btn')
146
- .click();
147
- cy.get('textarea[class="body-param__text"]')
148
- .clear()
149
- .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"]}", "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}`);
150
- cy.get('.execute')
151
- .click();
152
- cy.wait(2000);
153
- cy.get('.loading-container')
154
- .should('not.exist');
155
- });
156
- });
157
- });
158
-
159
- describe('Response API cases', () => {
160
- it('If the user clicks on the Responses option from the menu bar, user should be navigated to the Responses page', () => {
161
- cy.contains('Fetch Responses')
162
- .click();
163
- cy.contains('Fetch Responses')
164
- .parent()
165
- .parent()
166
- .should('have.class', 'Mui-selected');
167
- cy.url()
168
- .should('eq', Cypress.config().baseUrl + '/item-engine/data-api/sessions/fetch-responses');
169
- });
170
-
171
- it('Example Request should be displayed', () => {
172
- cy.get('pre[class="body-param__example microlight"]')
173
- .eq(0)
174
- .should('have.text', "{\n \"activity_id\": [\n \"db27c257-8991-42cb-acec-009c7816cbfa\"\n ],\n \"user_id\": [\n \"5805c32e-51ca-472d-899a-fce07ebf3577\"\n ],\n \"session_id\": [\n \"6ba1cea0-7a3c-4af0-b72f-c2c8583668c7\"\n ],\n \"sort_field\": \"created\",\n \"sort\": \"desc\",\n \"limit\": 10,\n \"include_percentage_score\": false,\n \"organisation_id\": \"eb7d4a20-c96c-4852-9b34-7e3231016315\",\n \"next_token\": [\n 1703069388983,\n \"c765e28-fd62-0351-8385-05c165ac05d5\"\n ]\n}\n");
175
- });
176
-
177
- it('Example Response for status code 200 should be displayed', () => {
178
- cy.get('td[class="response-col_status"]')
179
- .eq(0)
180
- .should('have.text', '200');
181
- cy.get('.response-col_description__inner')
182
- .eq(0)
183
- .should('have.text', 'OK');
184
- cy.get('pre[class="example microlight"]')
185
- .eq(0)
186
- .should('have.text', "{\n \"meta\": {\n \"records\": 1,\n \"status\": true,\n \"timestamp\": 1653650543869,\n \"next_token\": [\n 1703069388983,\n \"f86cfbcd-254e-4f3c-add7-d2ab2fffc2e0\"\n ]\n },\n \"data\": [\n {\n \"user_id\": \"c96eadb2-8e0b-49e7-ada2-0645734789a7\",\n \"dt_started\": null,\n \"dt_completed\": null,\n \"score\": 14,\n \"session_id\": \"80c8312d-af7d-48de-8771-5b33ff27632d\",\n \"activity_id\": \"f86cfbcd-254e-4f3c-add7-d2ab2fffc2e0\",\n \"max_score\": \"47.95\",\n \"activity_template_id\": \"263d353-ca6c-20-60-1a2c60e21ec3\",\n \"num_questions\": 1,\n \"responses\": [\n {\n \"erater\": null,\n \"plagiarism\": null,\n \"score\": 10,\n \"max_score\": 10,\n \"serial_no\": 1,\n \"item_reference\": \"263d353-ca6c-20-60-1a2c60e21ec3\",\n \"question_reference\": \"d22c326-33e-352d-ad1-547a0c3e8b48\",\n \"response_id\": \"4cdda1d1-d697-4870-a000-89f7a2eedf71\",\n \"attempted\": true,\n \"automarkable\": true,\n \"responses\": [\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceA\"\n },\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceD\"\n }\n ]\n },\n {\n \"erater\": null,\n \"plagiarism\": null,\n \"score\": 4,\n \"max_score\": 8,\n \"serial_no\": 2,\n \"item_reference\": \"263d353-ca6c-20-60-1a2c60e21ec3\",\n \"question_reference\": \"28c16bd-6e0-1bf-a25-24c117203f3\",\n \"response_id\": \"531d4c26-997a-487d-a820-bb300ed50fa2\",\n \"attempted\": true,\n \"automarkable\": true,\n \"responses\": [\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceB\"\n }\n ]\n },\n {\n \"erater\": null,\n \"plagiarism\": null,\n \"score\": null,\n \"max_score\": 10,\n \"serial_no\": 3,\n \"item_reference\": \"263d353-ca6c-20-60-1a2c60e21ec3\",\n \"question_reference\": \"d8818e-ce55-7283-4fa2-d585d0ccf021\",\n \"response_id\": \"923d99c0-2c75-40f9-9d39-7e987fa62a55\",\n \"attempted\": true,\n \"automarkable\": false,\n \"responses\": [\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"<p>Plants</p>\\n\"\n }\n ]\n },\n {\n \"erater\": null,\n \"plagiarism\": null,\n \"score\": null,\n \"max_score\": 10,\n \"serial_no\": 4,\n \"item_reference\": \"263d353-ca6c-20-60-1a2c60e21ec3\",\n \"question_reference\": \"4a3c6e6-11a-2dc8-8e88-feef042fc1b4\",\n \"response_id\": \"a86d2651-fcd9-4ad3-8d39-b2eecee6878a\",\n \"attempted\": true,\n \"automarkable\": false,\n \"responses\": [\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"<p>Animal</p>\\n\"\n }\n ]\n },\n {\n \"erater\": null,\n \"plagiarism\": null,\n \"score\": 0,\n \"max_score\": 0,\n \"serial_no\": 5,\n \"item_reference\": \"263d353-ca6c-20-60-1a2c60e21ec3\",\n \"question_reference\": \"15a7b61-c36-d81-df3c-cf25852e6e8a\",\n \"response_id\": \"736d220d-f5d3-4aad-8b88-847b817d380d\",\n \"attempted\": true,\n \"automarkable\": false,\n \"responses\": [\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"<p>Weather</p>\\n\"\n }\n ]\n },\n {\n \"erater\": null,\n \"plagiarism\": null,\n \"score\": null,\n \"max_score\": 10,\n \"serial_no\": 6,\n \"item_reference\": \"263d353-ca6c-20-60-1a2c60e21ec3\",\n \"question_reference\": \"756f84b-0f20-631c-f537-b800ac7ed6a2\",\n \"response_id\": \"955fcf33-6d6d-4a04-af01-960c2385fa05\",\n \"attempted\": true,\n \"automarkable\": false,\n \"responses\": [\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"{\\\"version\\\":\\\"3.6.3\\\",\\\"objects\\\":[{\\\"type\\\":\\\"ellipse\\\",\\\"version\\\":\\\"3.6.3\\\",\\\"originX\\\":\\\"left\\\",\\\"originY\\\":\\\"top\\\",\\\"left\\\":134.23,\\\"top\\\":110,\\\"width\\\":185.28,\\\"height\\\":176.61,\\\"fill\\\":\\\"rgba(0, 0, 0, 0)\\\",\\\"stroke\\\":\\\"rgb(0, 0, 0)\\\",\\\"strokeWidth\\\":1,\\\"strokeDashArray\\\":null,\\\"strokeLineCap\\\":\\\"butt\\\",\\\"strokeDashOffset\\\":0,\\\"strokeLineJoin\\\":\\\"miter\\\",\\\"strokeMiterLimit\\\":4,\\\"scaleX\\\":1,\\\"scaleY\\\":1,\\\"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,\\\"rx\\\":92.63803680981596,\\\"ry\\\":88.30742594753283},{\\\"type\\\":\\\"ellipse\\\",\\\"version\\\":\\\"3.6.3\\\",\\\"originX\\\":\\\"left\\\",\\\"originY\\\":\\\"top\\\",\\\"left\\\":464.29,\\\"top\\\":113.93,\\\"width\\\":179.14,\\\"height\\\":174.16,\\\"fill\\\":\\\"rgba(0, 0, 0, 0)\\\",\\\"stroke\\\":\\\"rgb(0, 0, 0)\\\",\\\"strokeWidth\\\":1,\\\"strokeDashArray\\\":null,\\\"strokeLineCap\\\":\\\"butt\\\",\\\"strokeDashOffset\\\":0,\\\"strokeLineJoin\\\":\\\"miter\\\",\\\"strokeMiterLimit\\\":4,\\\"scaleX\\\":1,\\\"scaleY\\\":1,\\\"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,\\\"rx\\\":89.57055214723925,\\\"ry\\\":87.08093392048377},{\\\"type\\\":\\\"rect\\\",\\\"version\\\":\\\"3.6.3\\\",\\\"originX\\\":\\\"left\\\",\\\"originY\\\":\\\"top\\\",\\\"left\\\":307.24,\\\"top\\\":311.15,\\\"width\\\":279.75,\\\"height\\\":116.52,\\\"fill\\\":\\\"rgba(0, 0, 0, 0)\\\",\\\"stroke\\\":\\\"rgb(0, 0, 0)\\\",\\\"strokeWidth\\\":1,\\\"strokeDashArray\\\":null,\\\"strokeLineCap\\\":\\\"butt\\\",\\\"strokeDashOffset\\\":0,\\\"strokeLineJoin\\\":\\\"miter\\\",\\\"strokeMiterLimit\\\":4,\\\"scaleX\\\":1,\\\"scaleY\\\":1,\\\"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,\\\"rx\\\":0,\\\"ry\\\":0},{\\\"type\\\":\\\"rect\\\",\\\"version\\\":\\\"3.6.3\\\",\\\"originX\\\":\\\"right\\\",\\\"originY\\\":\\\"bottom\\\",\\\"left\\\":518.28,\\\"top\\\":384.74,\\\"width\\\":265.03,\\\"height\\\":219.54,\\\"fill\\\":\\\"rgba(0, 0, 0, 0)\\\",\\\"stroke\\\":\\\"rgb(0, 0, 0)\\\",\\\"strokeWidth\\\":1,\\\"strokeDashArray\\\":null,\\\"strokeLineCap\\\":\\\"butt\\\",\\\"strokeDashOffset\\\":0,\\\"strokeLineJoin\\\":\\\"miter\\\",\\\"strokeMiterLimit\\\":4,\\\"scaleX\\\":1,\\\"scaleY\\\":1,\\\"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,\\\"rx\\\":0,\\\"ry\\\":0}]}\"\n }\n ]\n }\n ],\n \"items\": [\n {\n \"reference\": \"263d353-ca6c-20-60-1a2c60e21ec3\",\n \"response_ids\": [\n \"4cdda1d1-d697-4870-a000-89f7a2eedf71\",\n \"531d4c26-997a-487d-a820-bb300ed50fa2\",\n \"923d99c0-2c75-40f9-9d39-7e987fa62a55\",\n \"a86d2651-fcd9-4ad3-8d39-b2eecee6878a\",\n \"736d220d-f5d3-4aad-8b88-847b817d380d\",\n \"955fcf33-6d6d-4a04-af01-960c2385fa05\"\n ],\n \"scoring\": {\n \"score\": 14,\n \"max_score\": 48,\n \"item_scoring_type\": \"sum up all individual scores\"\n }\n }\n ]\n }\n ]\n}\n");
187
- });
188
-
189
- it('Example Response for status code 401 should be displayed', () => {
190
- cy.get('td[class="response-col_status"]')
191
- .eq(1)
192
- .should('have.text', '401');
193
- cy.get('.response-col_description__inner')
194
- .eq(1)
195
- .should('have.text', 'Unauthorized');
196
- cy.get('pre[class="example microlight"]')
197
- .eq(1)
198
- .should('have.text', "{\n \"meta\": {\n \"status\": false,\n \"message\": \"Invalid Signature\",\n \"timestamp\": 1653650826764\n },\n \"data\": []\n}\n");
199
- });
200
-
201
- it('Example Response for status code 422 should be displayed', () => {
202
- cy.get('td[class="response-col_status"]')
203
- .eq(2)
204
- .should('have.text', '422');
205
- cy.get('.response-col_description__inner')
206
- .eq(2)
207
- .should('have.text', 'Unprocessable Entity (WebDAV)');
208
- cy.get('pre[class="example microlight"]')
209
- .eq(2)
210
- .should('have.text', "{\n \"meta\": {\n \"status\": false,\n \"message\": \"\\\"activity_id\\\" must be an array\",\n \"timestamp\": 1653650826764\n },\n \"data\": []\n}\n");
211
- });
212
-
213
- it('Example Response for status code 500 should be displayed', () => {
214
- cy.get('td[class="response-col_status"]')
215
- .eq(3)
216
- .should('have.text', '500');
217
- cy.get('.response-col_description__inner')
218
- .eq(3)
219
- .should('have.text', 'Internal Server Error');
220
- cy.get('pre[class="example microlight"]')
221
- .eq(3)
222
- .should('have.text', "{\n \"meta\": {\n \"status\": false,\n \"message\": \"Error occurred while fetching data\",\n \"timestamp\": 1653650826764\n },\n \"data\": []\n}\n");
223
- });
224
-
225
- it('Entering request to get Response data for activity 1 (All correct responses, all questions attempted)', () => {
226
- cy.visit('/item-engine/data-api/sessions/fetch-responses');
227
- cy.get('.try-out__btn')
228
- .click();
229
- cy.get('textarea[class="body-param__text"]')
230
- .clear()
231
- .fill(`{\n "activity_id": ["${sessionData[0]["activity_id"]}"],\n "user_id": ["${sessionData[0]["user_id"]}"],\n "session_id": ["${sessionData[0]["session_id"]}"],\n "sort": "desc",\n "limit": 10,\n "page": 0\n}\n`);
232
- cy.get('.execute')
233
- .click();
234
- cy.wait(2000);
235
- cy.get('.loading-container')
236
- .should('not.exist');
237
-
238
- //Storing the unknown values from the response for assertion
239
- cy.get('pre[class="microlight"]')
240
- .eq(1)
241
- .invoke('text')
242
- .then((text) => {
243
- // Parse the JSON from the DOM
244
- const actualResponse = JSON.parse(text);
245
- timestamp = actualResponse.meta.timestamp;
246
- // Loop through each data item
247
- actualResponse.data.forEach((dataItem) => {
248
- // Loop through each response in the responses array
249
- dataItem.responses.forEach((response) => {
250
- questionReferences.push(response.question_reference);
251
- responseIds.push(response.response_id);
252
- });
253
- });
254
- const dataItem = actualResponse.data[0];
255
- activityTemplateIdNew = dataItem.activity_template_id;
256
- dtStartedNew = dataItem.dt_started;
257
- dtCompletedNew = dataItem.dt_completed;
258
- });
259
- });
260
-
261
- it('Response data of all the activity for the entered user_id should be returned in the response', () => {
262
- cy.get('pre[class="microlight"]')
263
- .eq(1)
264
- .should('have.text',`{\n \"meta\": {\n \"records\": 1,\n \"status\": true,\n \"timestamp\": ${timestamp},\n \"next_token\": null\n },\n \"data\": [\n {\n \"user_id\": \"${sessionData[0]["user_id"]}\",\n \"session_id\": \"${sessionData[0]["session_id"]}\",\n \"activity_id\": \"${sessionData[0]["activity_id"]}\",\n \"score\": 1.5,\n \"dt_started\": \"${dtStartedNew}\",\n \"dt_completed\": \"${dtCompletedNew}\",\n \"max_score\": 14,\n \"activity_template_id\": \"${activityTemplateIdNew}\",\n \"num_questions\": 1,\n \"responses\": [\n {\n \"erater\": null,\n \"plagiarism\": null,\n \"score\": 1.5,\n \"max_score\": 4,\n \"serial_no\": 1,\n \"item_reference\": \"${itemReferenceIdNew}\",\n \"question_reference\": \"${questionReferences[0]}\",\n \"automarkable\": true,\n \"response_id\": \"${responseIds[0]}\",\n \"attempted\": true,\n \"responses\": [\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceA\"\n },\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceD\"\n }\n ]\n },\n {\n \"erater\": null,\n \"plagiarism\": null,\n \"score\": 0,\n \"max_score\": 10,\n \"serial_no\": 2,\n \"item_reference\": \"${itemReferenceIdNew}\",\n \"question_reference\": \"${questionReferences[1]}\",\n \"automarkable\": true,\n \"response_id\": \"${responseIds[1]}\",\n \"attempted\": true,\n \"responses\": [\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceA\"\n },\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceD\"\n }\n ]\n }\n ],\n \"items\": [\n {\n \"reference\": \"${itemReferenceIdNew}\",\n \"response_ids\": [\n \"${responseIds[0]}\",\n \"${responseIds[1]}\"\n ],\n \"scoring\": {\n \"score\": 1.5,\n \"max_score\": 14,\n \"item_scoring_type\": \"sum up all individual scores\"\n }\n }\n ]\n }\n ]\n}\n`)
265
- });
266
-
267
- it('Entering request to get Response data for activity 2- Sending multiple activities and filtering by session id and userid for activity 2 (Incorrect responses, incomplete i.e. all questions are not attempted)', () => {
268
- cy.get('textarea[class="body-param__text"]')
269
- .clear()
270
- .fill(`{\n "activity_id": ["${sessionData[1]["activity_id"]}","${sessionData[0]["activity_id"]}"],\n "user_id": ["${sessionData[1]["user_id"]}"],\n "session_id": ["${sessionData[1]["session_id"]}"],\n "sort": "desc",\n "limit": 10,\n "page": 0\n}\n`);
271
- cy.get('.execute')
272
- .click();
273
- cy.wait(2000);
274
- cy.get('.loading-container')
275
- .should('not.exist');
276
-
277
- //Storing the unknown values from the response for assertion
278
- cy.get('pre[class="microlight"]')
279
- .eq(1)
280
- .invoke('text')
281
- .then((text) => {
282
- // Parse the JSON from the DOM
283
- const actualResponse = JSON.parse(text);
284
- timestamp = actualResponse.meta.timestamp;
285
- // Loop through each data item
286
- actualResponse.data.forEach((dataItem) => {
287
- // Loop through each response in the responses array
288
- dataItem.responses.forEach((response) => {
289
- questionReferences.push(response.question_reference);
290
- responseIds.push(response.response_id);
291
- });
292
- });
293
- const dataItem = actualResponse.data[0];
294
- activityTemplateIdNew = dataItem.activity_template_id;
295
- dtStartedNew = dataItem.dt_started;
296
- dtCompletedNew = dataItem.dt_completed;
297
- });
298
- });
299
-
300
- it('Response data of all the activity for the entered user_id should be returned in the response', () => {
301
- cy.get('pre[class="microlight"]')
302
- .eq(1)
303
- .should('have.text',`{\n \"meta\": {\n \"records\": 1,\n \"status\": true,\n \"timestamp\": ${timestamp},\n \"next_token\": null\n },\n \"data\": [\n {\n \"user_id\": \"${sessionData[1]["user_id"]}\",\n \"session_id\": \"${sessionData[1]["session_id"]}\",\n \"activity_id\": \"${sessionData[1]["activity_id"]}\",\n \"score\": 1.5,\n \"dt_started\": \"${dtStartedNew}\",\n \"dt_completed\": \"${dtCompletedNew}\",\n \"max_score\": 14,\n \"activity_template_id\": \"${activityTemplateIdNew}\",\n \"num_questions\": 1,\n \"responses\": [\n {\n \"erater\": null,\n \"plagiarism\": null,\n \"score\": 1.5,\n \"max_score\": 4,\n \"serial_no\": 1,\n \"item_reference\": \"${itemReferenceIdNew}\",\n \"question_reference\": \"${questionReferences[2]}\",\n \"automarkable\": true,\n \"response_id\": \"${responseIds[2]}\",\n \"attempted\": true,\n \"responses\": [\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceA\"\n },\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceB\"\n }\n ]\n },\n {\n \"erater\": null,\n \"plagiarism\": null,\n \"score\": 0,\n \"max_score\": 10,\n \"serial_no\": 2,\n \"item_reference\": \"${itemReferenceIdNew}\",\n \"question_reference\": \"${questionReferences[3]}\",\n \"automarkable\": true,\n \"response_id\": \"${responseIds[3]}\",\n \"attempted\": true,\n \"responses\": [\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceB\"\n },\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceC\"\n }\n ]\n }\n ],\n \"items\": [\n {\n \"reference\": \"${itemReferenceIdNew}\",\n \"response_ids\": [\n \"${responseIds[2]}\",\n \"${responseIds[3]}\"\n ],\n \"scoring\": {\n \"score\": 1.5,\n \"max_score\": 14,\n \"item_scoring_type\": \"sum up all individual scores\"\n }\n }\n ]\n }\n ]\n}\n`)
304
- });
305
-
306
- it('Entering request to get Response data for both activity 1 and activity 2, keeping sort field blank', () => {
307
- cy.get('textarea[class="body-param__text"]')
308
- .clear()
309
- .fill(`{\n "activity_id": ["${sessionData[0]["activity_id"]}", "${sessionData[1]["activity_id"]}"],\n "user_id": [],\n "session_id": [],\n "sort": "",\n "limit": 10,\n "page": 0\n}\n`);
310
- cy.get('.execute')
311
- .click();
312
- cy.wait(2000);
313
- cy.get('.loading-container')
314
- .should('not.exist');
315
-
316
- //Storing the unknown values from the response for assertion
317
- cy.get('pre[class="microlight"]')
318
- .eq(1)
319
- .within(() => {
320
- cy.contains('timestamp')
321
- .next().next().then((currTimestamp) => {
322
- timestamp = currTimestamp[0].innerText
323
- });
324
- });
325
- });
326
-
327
- it('"\"sort\" must be one of [asc, desc]" error message should be received in the response with error code 422', () => {
328
- cy.get('pre[class="microlight"]')
329
- .eq(1)
330
- .should('have.text',`{\n \"meta\": {\n \"message\": \"\\\"sort\\\" must be one of [asc, desc]\",\n \"timestamp\": ${timestamp},\n \"status\": false\n },\n \"data\": []\n}\n`)
331
- });
332
-
333
- it('Entering request to get Response data for both activity 1 and activity 2, keeping session_id and user_id array blank', () => {
334
- cy.get('textarea[class="body-param__text"]')
335
- .clear()
336
- .fill(`{\n "activity_id": ["${sessionData[0]["activity_id"]}", "${sessionData[1]["activity_id"]}"],\n "user_id": [],\n "session_id": [],\n "sort": "asc",\n "limit": 10,\n "page": 0\n}\n`);
337
- cy.get('.execute')
338
- .click();
339
- cy.wait(2000);
340
- cy.get('.loading-container')
341
- .should('not.exist');
342
-
343
- //Storing the unknown values from the response for assertion
344
- cy.get('pre[class="microlight"]')
345
- .eq(1)
346
- .invoke('text')
347
- .then((text) => {
348
- // Parse the JSON from the DOM
349
- const actualResponse = JSON.parse(text);
350
- timestamp = actualResponse.meta.timestamp;
351
- // Loop through each data item
352
- questionReferences.length = 0;
353
- responseIds.length = 0;
354
- actualResponse.data.forEach((dataItem) => {
355
- // Loop through each response in the responses array
356
- dataItem.responses.forEach((response) => {
357
- questionReferences.push(response.question_reference);
358
- responseIds.push(response.response_id);
359
- });
360
- });
361
- const dataItem = actualResponse.data[0];
362
- if (actualResponse.data && actualResponse.data.length >= 1) {
363
- dtStartedNew = actualResponse.data[0].dt_started;
364
- dtCompletedNew = actualResponse.data[0].dt_completed;
365
- activityTemplateIdNew = actualResponse.data[0].activity_template_id;
366
- }
367
-
368
- if (actualResponse.data && actualResponse.data.length >= 2) {
369
- dtStartedNew1 = actualResponse.data[1].dt_started;
370
- dtCompletedNew1 = actualResponse.data[1].dt_completed;
371
- activityTemplateIdNew1 = actualResponse.data[1].activity_template_id;
372
- }
373
- });
374
- });
375
-
376
- it('Verifying the response', () => {
377
- cy.get('pre[class="microlight"]')
378
- .eq(1)
379
- .should('have.text',`{\n \"meta\": {\n \"records\": 2,\n \"status\": true,\n \"timestamp\": ${timestamp},\n \"next_token\": null\n },\n \"data\": [\n {\n \"user_id\": \"${sessionData[0]["user_id"]}\",\n \"session_id\": \"${sessionData[0]["session_id"]}\",\n \"activity_id\": \"${sessionData[0]["activity_id"]}\",\n \"score\": 1.5,\n \"dt_started\": \"${dtStartedNew}\",\n \"dt_completed\": \"${dtCompletedNew}\",\n \"max_score\": 14,\n \"activity_template_id\": \"${activityTemplateIdNew}\",\n \"num_questions\": 1,\n \"responses\": [\n {\n \"erater\": null,\n \"plagiarism\": null,\n \"score\": 1.5,\n \"max_score\": 4,\n \"serial_no\": 1,\n \"item_reference\": \"${itemReferenceIdNew}\",\n \"question_reference\": \"${questionReferences[0]}\",\n \"automarkable\": true,\n \"response_id\": \"${responseIds[0]}\",\n \"attempted\": true,\n \"responses\": [\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceA\"\n },\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceD\"\n }\n ]\n },\n {\n \"erater\": null,\n \"plagiarism\": null,\n \"score\": 0,\n \"max_score\": 10,\n \"serial_no\": 2,\n \"item_reference\": \"${itemReferenceIdNew}\",\n \"question_reference\": \"${questionReferences[1]}\",\n \"automarkable\": true,\n \"response_id\": \"${responseIds[1]}\",\n \"attempted\": true,\n \"responses\": [\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceA\"\n },\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceD\"\n }\n ]\n }\n ],\n \"items\": [\n {\n \"reference\": \"${itemReferenceIdNew}\",\n \"response_ids\": [\n \"${responseIds[0]}\",\n \"${responseIds[1]}\"\n ],\n \"scoring\": {\n \"score\": 1.5,\n \"max_score\": 14,\n \"item_scoring_type\": \"sum up all individual scores\"\n }\n }\n ]\n },\n {\n \"user_id\": \"${sessionData[1]["user_id"]}\",\n \"session_id\": \"${sessionData[1]["session_id"]}\",\n \"activity_id\": \"${sessionData[1]["activity_id"]}\",\n \"score\": 1.5,\n \"dt_started\": \"${dtStartedNew1}\",\n \"dt_completed\": \"${dtCompletedNew1}\",\n \"max_score\": 14,\n \"activity_template_id\": \"${activityTemplateIdNew1}\",\n \"num_questions\": 1,\n \"responses\": [\n {\n \"erater\": null,\n \"plagiarism\": null,\n \"score\": 1.5,\n \"max_score\": 4,\n \"serial_no\": 1,\n \"item_reference\": \"${itemReferenceIdNew}\",\n \"question_reference\": \"${questionReferences[2]}\",\n \"automarkable\": true,\n \"response_id\": \"${responseIds[2]}\",\n \"attempted\": true,\n \"responses\": [\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceA\"\n },\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceB\"\n }\n ]\n },\n {\n \"erater\": null,\n \"plagiarism\": null,\n \"score\": 0,\n \"max_score\": 10,\n \"serial_no\": 2,\n \"item_reference\": \"${itemReferenceIdNew}\",\n \"question_reference\": \"${questionReferences[3]}\",\n \"automarkable\": true,\n \"response_id\": \"${responseIds[3]}\",\n \"attempted\": true,\n \"responses\": [\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceB\"\n },\n {\n \"xml_identifier\": \"RESPONSE\",\n \"response_text\": \"ChoiceC\"\n }\n ]\n }\n ],\n \"items\": [\n {\n \"reference\": \"${itemReferenceIdNew}\",\n \"response_ids\": [\n \"${responseIds[2]}\",\n \"${responseIds[3]}\"\n ],\n \"scoring\": {\n \"score\": 1.5,\n \"max_score\": 14,\n \"item_scoring_type\": \"sum up all individual scores\"\n }\n }\n ]\n }\n ]\n}\n`)
380
- });
381
-
382
- it.skip('Entering request to get Response Scores data for activities using userid, filtered by activity id', () => {
383
- cy.get('textarea[class="body-param__text"]')
384
- .clear()
385
- .fill(`{\n "activity_id": ["${sessionData[2]["activity_id"]}"],\n "user_id": ["${sessionData[1]["user_id"]}"],\n "session_id": [],\n "sort": "desc",\n "limit": 10,\n "page": 0\n}\n`);
386
- cy.get('.execute')
387
- .click();
388
- cy.wait(2000);
389
- cy.get('.loading-container')
390
- .should('not.exist');
391
-
392
- //Storing the unknown values from the response for assertion
393
- cy.get('pre[class="microlight"]')
394
- .eq(1)
395
- .within(() => {
396
- var responseIdsArray = [];
397
- cy.get('span')
398
- .eq(135)
399
- .then((id) => {
400
- responseIdsArray.push(id[0].innerText);
401
- });
402
- sessionData[2]["responseIdsArray"] = responseIdsArray;
403
- cy.contains('timestamp')
404
- .next().next().then((currTimestamp) => {
405
- timestamp = currTimestamp[0].innerText
406
- });
407
- });
408
- });
409
-
410
- it.skip('Response Scores data for only activity 3 should be returned in the response', () => {
411
- cy.get('pre[class="microlight"]')
412
- .eq(1)
413
- .should('have.text', `{\n "meta": {\n "records": 1,\n "status": true,\n "timestamp": ${timestamp}\n },\n "data": [\n {\n "user_id": "${sessionData[2]["user_id"]}",\n "dt_started": null,\n "dt_completed": null,\n "score": 2,\n "session_id": "${sessionData[2]["session_id"]}",\n "activity_id": "${sessionData[2]["activity_id"]}",\n "max_score": "10.00",\n "activity_template_id": "${sessionData[2]["activity_template_id"]}",\n "num_questions": 1,\n "responses": [\n {\n "score": 2,\n "max_score": 10,\n "serial_no": 1,\n "item_reference": "sessionsAPIAutogradedItem",\n "question_reference": "${sessionData[2]["questionReferenceIds"][0]}",\n "automarkable": true,\n "response_id": ${sessionData[2]["responseIdsArray"][0]},\n "attempted": true,\n "responses": [\n {\n "xml_identifier": "RESPONSE",\n "response_text": "ChoiceB"\n }\n ]\n }\n ],\n "items": [\n {\n "reference": "sessionsAPIAutogradedItem",\n "response_ids": [\n ${sessionData[2]["responseIdsArray"][0]}\n ],\n "scoring": {\n "score": 2,\n "max_score": 10\n }\n }\n ]\n }\n ]\n}\n`);
414
- });
415
-
416
- it('Entering request with a non existing session id', () => {
417
- cy.get('textarea[class="body-param__text"]')
418
- .clear()
419
- .fill(`{\n "activity_id": ["${sessionData[1]["activity_id"]}"],\n "user_id": ["${sessionData[1]["user_id"]}"],\n "session_id": ["non existing session id"],\n "sort": "desc",\n "limit": 10,\n "page": 0\n}\n`);
420
- cy.get('.execute')
421
- .click();
422
- cy.wait(2000);
423
- cy.get('.loading-container')
424
- .should('not.exist');
425
-
426
- //Storing the unknown values from the response for assertion
427
- cy.get('pre[class="microlight"]')
428
- .eq(1)
429
- .within(() => {
430
- cy.contains('timestamp')
431
- .next().next().then((currTimestamp) => {
432
- timestamp = currTimestamp[0].innerText
433
- });
434
- });
435
- });
436
-
437
- it('A blank data array should be received in the response with status code 200', () => {
438
- cy.get('pre[class="microlight"]')
439
- .eq(1)
440
- .should('have.text', `{\n \"data\": [],\n \"meta\": {\n \"records\": 0,\n \"status\": true,\n \"timestamp\": ${timestamp},\n \"next_token\": null\n }\n}\n`)
441
- });
442
- });
443
- });