itemengine-cypress-automation 1.0.323-updateBumpVersion-82a2c50.0 → 1.0.324-updateBumpVersion-4da7a9c.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,408 @@
1
+ import { createdAndUpdatedAtDate, questionAndResourceReferenceIds } from '../../support/helpers/createItem'
2
+
3
+ describe('Get Question Data API cases', () => {
4
+ let records, timestamp, created_date, updated_date;
5
+ let next_token = {};
6
+ let questionRef1, questionRef2;
7
+
8
+ before(() => {
9
+ cy.loginAs('admin');
10
+ cy.createItem('DataApiGetQuestionTest1');
11
+ cy.wait(5000)
12
+ cy.createItem('DataApiGetQuestionTest2');
13
+ cy.visit(`${Cypress.env('itemEngineHomePage')}`);
14
+ });
15
+
16
+ after(() => {
17
+ cy.deleteItems();
18
+ cy.logout();
19
+ });
20
+
21
+ it('If the user clicks on the Fetch Questions option from the menu bar, user should be navigated to the Fetch Questions page', () => {
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
+ });
33
+
34
+ it('Example Request should be displayed', () => {
35
+ cy.get('pre[class="body-param__example microlight"]')
36
+ .eq(0)
37
+ .then((text) => {
38
+ console.log(text[0].innerText)
39
+ });
40
+ cy.get('pre[class="body-param__example microlight"]')
41
+ .eq(0)
42
+ .should('have.text', "{\n \"item_references\": [\n \"0ec96b24-78cc-4170-93d3-64fd68eff1c6\",\n \"3e7801d-6f7f-4b85-660f-3b363e2bed23\"\n ],\n \"references\": [],\n \"types\": [],\n \"limit\": 2,\n \"sort_field\": \"created\",\n \"sort\": \"desc\",\n \"next_token\": [\n 1703069388983,\n \"c765e28-fd62-0351-8385-05c165ac05d5\"\n ]\n}\n")
43
+ });
44
+
45
+ it('Example Response for status code 200 should be displayed', () => {
46
+ cy.get('td[class="response-col_status"]')
47
+ .eq(0)
48
+ .should('have.text', '200');
49
+ cy.get('.response-col_description__inner')
50
+ .eq(0)
51
+ .should('have.text', 'OK');
52
+ cy.get('pre[class="example microlight"]')
53
+ .eq(0)
54
+ .should('have.text', "{\n \"meta\": {\n \"status\": true,\n \"records\": 6,\n \"next_token\": [\n 1703069388982,\n \"7fc24e1-86-ba65-a2e3-4c60c4c838\"\n ],\n \"timestamp\": 1703225704064\n },\n \"data\": {\n \"3e7801d-6f7f-4b85-660f-3b363e2bed23\": [\n {\n \"reference\": \"6da7776-dfb-cc2-1118-1a6f71e738f\",\n \"type\": \"multiple selection\",\n \"dt_created\": \"2023-12-20T10:49:48.982Z\",\n \"dt_updated\": \"2023-12-20T10:50:21.868Z\",\n \"scoring_type\": \"Auto-scored\",\n \"points\": 10,\n \"penalty_points\": 0,\n \"min_score_if_attempted\": 0,\n \"scoring_guidance\": \"\",\n \"sample_response\": \"\",\n \"data\": \"<assessmentItem xmlns=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xsi:schemaLocation=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\\\" identifier=\\\"choiceMultiple\\\" title=\\\"Welcome to Biodome\\\" timeDependent=\\\"false\\\"><responseDeclaration identifier=\\\"RESPONSE\\\" cardinality=\\\"multiple\\\" baseType=\\\"identifier\\\"><correctResponse><value>ChoiceB</value></correctResponse></responseDeclaration><outcomeDeclaration identifier=\\\"SCORE\\\" cardinality=\\\"single\\\" baseType=\\\"float\\\"/><itemBody><choiceInteraction responseIdentifier=\\\"RESPONSE\\\" orientation=\\\"vertical\\\"><prompt>Testing</prompt><simpleChoice identifier=\\\"ChoiceA\\\">1</simpleChoice><simpleChoice identifier=\\\"ChoiceB\\\">2</simpleChoice><simpleChoice identifier=\\\"ChoiceC\\\">3</simpleChoice><simpleChoice identifier=\\\"ChoiceD\\\">4</simpleChoice></choiceInteraction></itemBody><responseProcessing template=\\\"http://www.imsglobal.org/question/qti_v2p2/rptemplates/map_response\\\"/></assessmentItem>\"\n },\n {\n \"reference\": \"7fc24e1-86-ba65-a2e3-4c60c4c838\",\n \"type\": \"essay response - rich text\",\n \"dt_created\": \"2023-12-20T10:49:48.982Z\",\n \"dt_updated\": \"2023-12-20T10:50:21.868Z\",\n \"scoring_type\": \"Manually-scored\",\n \"points\": 100,\n \"penalty_points\": 0,\n \"min_score_if_attempted\": 0,\n \"scoring_guidance\": \"\",\n \"sample_response\": \"\",\n \"data\": \"<assessmentItem xmlns=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xsi:schemaLocation=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\\\" identifier=\\\"extendedText\\\" title=\\\"This is title for Essay Response\\\" timeDependent=\\\"false\\\"><responseDeclaration identifier=\\\"RESPONSE\\\" cardinality=\\\"single\\\" baseType=\\\"string\\\"/><outcomeDeclaration identifier=\\\"SCORE\\\" cardinality=\\\"single\\\" baseType=\\\"float\\\"/><itemBody><p class=\\\"predefinedText\\\" role=\\\"presentation\\\"/><extendedTextInteraction responseIdentifier=\\\"RESPONSE\\\" placeholderText=\\\"Your Answer\\\" expectedLength=\\\"10000\\\"><prompt>TEst</prompt></extendedTextInteraction></itemBody></assessmentItem>\"\n }\n ]\n }\n}\n");
55
+ });
56
+
57
+ it('Example Response for status code 401 should be displayed', () => {
58
+ cy.get('td[class="response-col_status"]')
59
+ .eq(1)
60
+ .should('have.text', '401');
61
+ cy.get('.response-col_description__inner')
62
+ .eq(1)
63
+ .should('have.text', 'Unauthorized');
64
+ cy.get('pre[class="example microlight"]')
65
+ .eq(1)
66
+ .should('have.text', "{\n \"meta\": {\n \"status\": false,\n \"message\": \"Invalid Signature\",\n \"timestamp\": 1653650826764\n },\n \"data\": []\n}\n");
67
+ });
68
+
69
+ it('Example Response for status code 422 should be displayed', () => {
70
+ cy.get('td[class="response-col_status"]')
71
+ .eq(2)
72
+ .should('have.text', '422');
73
+ cy.get('.response-col_description__inner')
74
+ .eq(2)
75
+ .should('have.text', 'Unprocessable Entity (WebDAV)');
76
+ cy.get('pre[class="example microlight"]')
77
+ .eq(2)
78
+ .should('have.text', "{\n \"meta\": {\n \"status\": false,\n \"message\": \"Invalid OrganisationId\",\n \"timestamp\": 1653650826764\n },\n \"data\": []\n}\n");
79
+ });
80
+
81
+ it('Example Response for status code 500 should be displayed', () => {
82
+ cy.get('td[class="response-col_status"]')
83
+ .eq(3)
84
+ .should('have.text', '500');
85
+ cy.get('.response-col_description__inner')
86
+ .eq(3)
87
+ .should('have.text', 'Internal Server Error');
88
+ cy.get('pre[class="example microlight"]')
89
+ .eq(3)
90
+ .should('have.text', "{\n \"meta\": {\n \"status\": false,\n \"message\": \"Error occurred while fetching data\",\n \"timestamp\": 1653650826764\n },\n \"data\": []\n}\n");
91
+ });
92
+
93
+ it('Entering request with a non existing item reference id', () => {
94
+ cy.get('.try-out__btn')
95
+ .click();
96
+ cy.get('textarea[class="body-param__text"]')
97
+ .clear()
98
+ .fill(`{\n "item_references": [\n "non existing reference"\n ],\n "references": [],\n "types": [],\n "limit": 50,\n "page": 0,\n "sort_field": "created",\n "sort": "desc"\n}\n`);
99
+ cy.get('.execute')
100
+ .click();
101
+ cy.wait(2000);
102
+ cy.get('.loading-container')
103
+ .should('not.exist');
104
+ //Storing the timestamp for assertion
105
+ cy.get('pre[class="microlight"]')
106
+ .eq(1)
107
+ .within(() => {
108
+ cy.contains('timestamp')
109
+ .next().next().then((currTimestamp) => {
110
+ timestamp = currTimestamp[0].innerText
111
+ });
112
+ });
113
+ });
114
+
115
+ it('A blank data array should be received in the response with status code 200', () => {
116
+ cy.get('td[class="response-col_status"]')
117
+ .eq(0)
118
+ .should('have.text', '200');
119
+ cy.get('pre[class="microlight"]')
120
+ .eq(1)
121
+ .should('have.text', `{\n \"meta\": {\n \"status\": true,\n \"records\": 0,\n \"next_token\": null,\n \"timestamp\": ${timestamp}\n },\n \"data\": []\n}\n`);
122
+ });
123
+
124
+ it('Entering the request with multiple item references separated by a comma', () => {
125
+ cy.get('textarea[class="body-param__text"]')
126
+ .clear()
127
+ .fill(`{\n "item_references": ["DataApiGetQuestionTest1","DataApiGetQuestionTest2"],\n "references": [],\n "types": [],\n "limit": 50,\n "sort_field": "created",\n "sort": "desc"\n}\n`);
128
+ cy.get('.execute')
129
+ .click();
130
+ cy.wait(2000);
131
+ cy.get('.loading-container')
132
+ .should('not.exist');
133
+ });
134
+
135
+ it('All the questions of the entered item reference should be returned in the response with status code 200', () => {
136
+ cy.get('pre[class="microlight"]')
137
+ .eq(1)
138
+ .invoke('text')
139
+ .then((text) => {
140
+ // Parse the JSON from the DOM
141
+ const actualResponse = JSON.parse(text);
142
+
143
+ // Extract dynamic values from the parsed object
144
+ const { records, timestamp, next_token } = actualResponse.meta;
145
+ const test1Data = actualResponse.data.DataApiGetQuestionTest1[0];
146
+ const { dt_created, dt_updated, reference: ref1 } = test1Data;
147
+ const test2Data = actualResponse.data.DataApiGetQuestionTest2[0];
148
+ const { reference: ref2 } = test2Data;
149
+ questionRef1 = ref1;
150
+ questionRef2 = ref2;
151
+
152
+ // First, assert the status code is 200
153
+ cy.get('td[class="response-col_status"]')
154
+ .eq(0)
155
+ .should('have.text', '200');
156
+ cy.get('pre[class="microlight"]')
157
+ .eq(1)
158
+ .should('have.text', `{\n \"meta\": {\n \"status\": true,\n \"records\": ${records},\n \"next_token\": [\n ${next_token[0]},\n \"${next_token[1]}\"\n ],\n \"timestamp\": ${timestamp}\n },\n \"data\": {\n \"DataApiGetQuestionTest1\": [\n {\n \"reference\": \"${ref1}\",\n \"type\": \"multiple selection\",\n \"dt_created\": \"${dt_created}\",\n \"dt_updated\": \"${dt_updated}\",\n \"scoring_type\": \"Auto-scored\",\n \"points\": 2,\n \"penalty_points\": null,\n \"min_score_if_attempted\": null,\n \"min_score_type\": 1,\n \"penalty_point_type\": 1,\n \"is_auto_penalty_setting\": false,\n \"is_negative_rounded\": true,\n \"specific_penalty_type\": 1,\n \"penalty_points_for_each\": null,\n \"scoring_guidance\": \"\",\n \"sample_response\": \"\",\n \"data\": \"<assessmentItem xmlns=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xsi:schemaLocation=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\\\" identifier=\\\"choiceMultiple\\\" title=\\\"Welcome to Biodome\\\" timeDependent=\\\"false\\\"><responseDeclaration identifier=\\\"RESPONSE\\\" cardinality=\\\"multiple\\\" baseType=\\\"identifier\\\"><correctResponse><value>ChoiceA</value><value>ChoiceB</value></correctResponse></responseDeclaration><outcomeDeclaration identifier=\\\"SCORE\\\" cardinality=\\\"single\\\" baseType=\\\"float\\\"/><itemBody><choiceInteraction responseIdentifier=\\\"RESPONSE\\\" orientation=\\\"horizontal\\\"><prompt></prompt><simpleChoice identifier=\\\"ChoiceA\\\">1</simpleChoice><simpleChoice identifier=\\\"ChoiceB\\\">2</simpleChoice><simpleChoice identifier=\\\"ChoiceC\\\">3</simpleChoice><simpleChoice identifier=\\\"ChoiceD\\\">4</simpleChoice></choiceInteraction></itemBody><responseProcessing template=\\\"http://www.imsglobal.org/question/qti_v2p2/rptemplates/map_response\\\"/></assessmentItem>\"\n }\n ],\n \"DataApiGetQuestionTest2\": [\n {\n \"reference\": \"${ref2}\",\n \"type\": \"multiple selection\",\n \"dt_created\": \"${dt_created}\",\n \"dt_updated\": \"${dt_updated}\",\n \"scoring_type\": \"Auto-scored\",\n \"points\": 2,\n \"penalty_points\": null,\n \"min_score_if_attempted\": null,\n \"min_score_type\": 1,\n \"penalty_point_type\": 1,\n \"is_auto_penalty_setting\": false,\n \"is_negative_rounded\": true,\n \"specific_penalty_type\": 1,\n \"penalty_points_for_each\": null,\n \"scoring_guidance\": \"\",\n \"sample_response\": \"\",\n \"data\": \"<assessmentItem xmlns=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xsi:schemaLocation=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\\\" identifier=\\\"choiceMultiple\\\" title=\\\"Welcome to Biodome\\\" timeDependent=\\\"false\\\"><responseDeclaration identifier=\\\"RESPONSE\\\" cardinality=\\\"multiple\\\" baseType=\\\"identifier\\\"><correctResponse><value>ChoiceA</value><value>ChoiceB</value></correctResponse></responseDeclaration><outcomeDeclaration identifier=\\\"SCORE\\\" cardinality=\\\"single\\\" baseType=\\\"float\\\"/><itemBody><choiceInteraction responseIdentifier=\\\"RESPONSE\\\" orientation=\\\"horizontal\\\"><prompt></prompt><simpleChoice identifier=\\\"ChoiceA\\\">1</simpleChoice><simpleChoice identifier=\\\"ChoiceB\\\">2</simpleChoice><simpleChoice identifier=\\\"ChoiceC\\\">3</simpleChoice><simpleChoice identifier=\\\"ChoiceD\\\">4</simpleChoice></choiceInteraction></itemBody><responseProcessing template=\\\"http://www.imsglobal.org/question/qti_v2p2/rptemplates/map_response\\\"/></assessmentItem>\"\n }\n ]\n }\n}\n`);
159
+ });
160
+ });
161
+
162
+ it('Entering the request with multiple item references, filtered by type', () => {
163
+ cy.get('textarea[class="body-param__text"]')
164
+ .clear()
165
+ .fill(`{\n "item_references": ["DataApiGetQuestionTest1","DataApiGetQuestionTest2"],\n "references": [],\n "types": ["multiple selection"],\n "limit": 50,\n "sort_field": "created",\n "sort": "desc"\n}\n`);
166
+ cy.get('.execute')
167
+ .click();
168
+ cy.wait(2000);
169
+ cy.get('.loading-container')
170
+ .should('not.exist');
171
+ });
172
+
173
+ it('All the questions of the entered item reference, filtered by the entered type should be returned in the response, with a status code 200', () => {
174
+ cy.get('pre[class="microlight"]')
175
+ .eq(1)
176
+ .invoke('text')
177
+ .then((text) => {
178
+ // Parse the JSON from the DOM
179
+ const actualResponse = JSON.parse(text);
180
+
181
+ // Extract dynamic values from the parsed object
182
+ const { records, timestamp, next_token } = actualResponse.meta;
183
+ const test1Data = actualResponse.data.DataApiGetQuestionTest1[0];
184
+ const { dt_created, dt_updated, reference: ref1 } = test1Data;
185
+ const test2Data = actualResponse.data.DataApiGetQuestionTest2[0];
186
+ const { reference: ref2 } = test2Data;
187
+ questionRef1 = ref1;
188
+ questionRef2 = ref2;
189
+
190
+ // First, assert the status code is 200
191
+ cy.get('td[class="response-col_status"]')
192
+ .eq(0)
193
+ .should('have.text', '200');
194
+ cy.get('pre[class="microlight"]')
195
+ .eq(1)
196
+ .should('have.text', `{\n \"meta\": {\n \"status\": true,\n \"records\": ${records},\n \"next_token\": [\n ${next_token[0]},\n \"${next_token[1]}\"\n ],\n \"timestamp\": ${timestamp}\n },\n \"data\": {\n \"DataApiGetQuestionTest1\": [\n {\n \"reference\": \"${ref1}\",\n \"type\": \"multiple selection\",\n \"dt_created\": \"${dt_created}\",\n \"dt_updated\": \"${dt_updated}\",\n \"scoring_type\": \"Auto-scored\",\n \"points\": 2,\n \"penalty_points\": null,\n \"min_score_if_attempted\": null,\n \"min_score_type\": 1,\n \"penalty_point_type\": 1,\n \"is_auto_penalty_setting\": false,\n \"is_negative_rounded\": true,\n \"specific_penalty_type\": 1,\n \"penalty_points_for_each\": null,\n \"scoring_guidance\": \"\",\n \"sample_response\": \"\",\n \"data\": \"<assessmentItem xmlns=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xsi:schemaLocation=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\\\" identifier=\\\"choiceMultiple\\\" title=\\\"Welcome to Biodome\\\" timeDependent=\\\"false\\\"><responseDeclaration identifier=\\\"RESPONSE\\\" cardinality=\\\"multiple\\\" baseType=\\\"identifier\\\"><correctResponse><value>ChoiceA</value><value>ChoiceB</value></correctResponse></responseDeclaration><outcomeDeclaration identifier=\\\"SCORE\\\" cardinality=\\\"single\\\" baseType=\\\"float\\\"/><itemBody><choiceInteraction responseIdentifier=\\\"RESPONSE\\\" orientation=\\\"horizontal\\\"><prompt></prompt><simpleChoice identifier=\\\"ChoiceA\\\">1</simpleChoice><simpleChoice identifier=\\\"ChoiceB\\\">2</simpleChoice><simpleChoice identifier=\\\"ChoiceC\\\">3</simpleChoice><simpleChoice identifier=\\\"ChoiceD\\\">4</simpleChoice></choiceInteraction></itemBody><responseProcessing template=\\\"http://www.imsglobal.org/question/qti_v2p2/rptemplates/map_response\\\"/></assessmentItem>\"\n }\n ],\n \"DataApiGetQuestionTest2\": [\n {\n \"reference\": \"${ref2}\",\n \"type\": \"multiple selection\",\n \"dt_created\": \"${dt_created}\",\n \"dt_updated\": \"${dt_updated}\",\n \"scoring_type\": \"Auto-scored\",\n \"points\": 2,\n \"penalty_points\": null,\n \"min_score_if_attempted\": null,\n \"min_score_type\": 1,\n \"penalty_point_type\": 1,\n \"is_auto_penalty_setting\": false,\n \"is_negative_rounded\": true,\n \"specific_penalty_type\": 1,\n \"penalty_points_for_each\": null,\n \"scoring_guidance\": \"\",\n \"sample_response\": \"\",\n \"data\": \"<assessmentItem xmlns=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xsi:schemaLocation=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\\\" identifier=\\\"choiceMultiple\\\" title=\\\"Welcome to Biodome\\\" timeDependent=\\\"false\\\"><responseDeclaration identifier=\\\"RESPONSE\\\" cardinality=\\\"multiple\\\" baseType=\\\"identifier\\\"><correctResponse><value>ChoiceA</value><value>ChoiceB</value></correctResponse></responseDeclaration><outcomeDeclaration identifier=\\\"SCORE\\\" cardinality=\\\"single\\\" baseType=\\\"float\\\"/><itemBody><choiceInteraction responseIdentifier=\\\"RESPONSE\\\" orientation=\\\"horizontal\\\"><prompt></prompt><simpleChoice identifier=\\\"ChoiceA\\\">1</simpleChoice><simpleChoice identifier=\\\"ChoiceB\\\">2</simpleChoice><simpleChoice identifier=\\\"ChoiceC\\\">3</simpleChoice><simpleChoice identifier=\\\"ChoiceD\\\">4</simpleChoice></choiceInteraction></itemBody><responseProcessing template=\\\"http://www.imsglobal.org/question/qti_v2p2/rptemplates/map_response\\\"/></assessmentItem>\"\n }\n ]\n }\n}\n`);
197
+ });
198
+ });
199
+
200
+ it('Entering the request with multiple item references, filtered by type and sorted by item name ascending', () => {
201
+ cy.get('textarea[class="body-param__text"]')
202
+ .clear()
203
+ .fill(`{ \n "item_references": [\n "DataApiGetQuestionTest1", \n "DataApiGetQuestionTest2", \n "non existing reference"\n], \n "references": [], \n "types": ["multiple selection"], \n "limit": 50, \n "page": 0, \n "sort_field": "created", \n "sort": "asc"\n }\n`);
204
+ cy.get('.execute')
205
+ .click();
206
+ cy.wait(2000);
207
+ cy.get('.loading-container')
208
+ .should('not.exist');
209
+ //Storing the response text for assertion
210
+ });
211
+
212
+ it('All the questions of the entered item reference, filtered by the entered type should be returned in the response sorted by item name ascending', () => {
213
+ cy.get('pre[class="microlight"]')
214
+ .eq(1)
215
+ .invoke('text')
216
+ .then((text) => {
217
+ // Parse the JSON from the DOM
218
+ const actualResponse = JSON.parse(text);
219
+
220
+ // Extract dynamic values from the parsed object
221
+ const { records, timestamp, next_token } = actualResponse.meta;
222
+ const test1Data = actualResponse.data.DataApiGetQuestionTest1[0];
223
+ const { dt_created, dt_updated, reference: ref1 } = test1Data;
224
+ const test2Data = actualResponse.data.DataApiGetQuestionTest2[0];
225
+ const { reference: ref2 } = test2Data;
226
+ questionRef1 = ref1;
227
+ questionRef2 = ref2;
228
+
229
+ // First, assert the status code is 200
230
+ cy.get('td[class="response-col_status"]')
231
+ .eq(0)
232
+ .should('have.text', '200');
233
+ cy.get('pre[class="microlight"]')
234
+ .eq(1)
235
+ .should('have.text', `{\n \"meta\": {\n \"status\": true,\n \"records\": ${records},\n \"next_token\": [\n ${next_token[0]},\n \"${next_token[1]}\"\n ],\n \"timestamp\": ${timestamp}\n },\n \"data\": {\n \"DataApiGetQuestionTest1\": [\n {\n \"reference\": \"${ref1}\",\n \"type\": \"multiple selection\",\n \"dt_created\": \"${dt_created}\",\n \"dt_updated\": \"${dt_updated}\",\n \"scoring_type\": \"Auto-scored\",\n \"points\": 2,\n \"penalty_points\": null,\n \"min_score_if_attempted\": null,\n \"min_score_type\": 1,\n \"penalty_point_type\": 1,\n \"is_auto_penalty_setting\": false,\n \"is_negative_rounded\": true,\n \"specific_penalty_type\": 1,\n \"penalty_points_for_each\": null,\n \"scoring_guidance\": \"\",\n \"sample_response\": \"\",\n \"data\": \"<assessmentItem xmlns=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xsi:schemaLocation=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\\\" identifier=\\\"choiceMultiple\\\" title=\\\"Welcome to Biodome\\\" timeDependent=\\\"false\\\"><responseDeclaration identifier=\\\"RESPONSE\\\" cardinality=\\\"multiple\\\" baseType=\\\"identifier\\\"><correctResponse><value>ChoiceA</value><value>ChoiceB</value></correctResponse></responseDeclaration><outcomeDeclaration identifier=\\\"SCORE\\\" cardinality=\\\"single\\\" baseType=\\\"float\\\"/><itemBody><choiceInteraction responseIdentifier=\\\"RESPONSE\\\" orientation=\\\"horizontal\\\"><prompt></prompt><simpleChoice identifier=\\\"ChoiceA\\\">1</simpleChoice><simpleChoice identifier=\\\"ChoiceB\\\">2</simpleChoice><simpleChoice identifier=\\\"ChoiceC\\\">3</simpleChoice><simpleChoice identifier=\\\"ChoiceD\\\">4</simpleChoice></choiceInteraction></itemBody><responseProcessing template=\\\"http://www.imsglobal.org/question/qti_v2p2/rptemplates/map_response\\\"/></assessmentItem>\"\n }\n ],\n \"DataApiGetQuestionTest2\": [\n {\n \"reference\": \"${ref2}\",\n \"type\": \"multiple selection\",\n \"dt_created\": \"${dt_created}\",\n \"dt_updated\": \"${dt_updated}\",\n \"scoring_type\": \"Auto-scored\",\n \"points\": 2,\n \"penalty_points\": null,\n \"min_score_if_attempted\": null,\n \"min_score_type\": 1,\n \"penalty_point_type\": 1,\n \"is_auto_penalty_setting\": false,\n \"is_negative_rounded\": true,\n \"specific_penalty_type\": 1,\n \"penalty_points_for_each\": null,\n \"scoring_guidance\": \"\",\n \"sample_response\": \"\",\n \"data\": \"<assessmentItem xmlns=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xsi:schemaLocation=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\\\" identifier=\\\"choiceMultiple\\\" title=\\\"Welcome to Biodome\\\" timeDependent=\\\"false\\\"><responseDeclaration identifier=\\\"RESPONSE\\\" cardinality=\\\"multiple\\\" baseType=\\\"identifier\\\"><correctResponse><value>ChoiceA</value><value>ChoiceB</value></correctResponse></responseDeclaration><outcomeDeclaration identifier=\\\"SCORE\\\" cardinality=\\\"single\\\" baseType=\\\"float\\\"/><itemBody><choiceInteraction responseIdentifier=\\\"RESPONSE\\\" orientation=\\\"horizontal\\\"><prompt></prompt><simpleChoice identifier=\\\"ChoiceA\\\">1</simpleChoice><simpleChoice identifier=\\\"ChoiceB\\\">2</simpleChoice><simpleChoice identifier=\\\"ChoiceC\\\">3</simpleChoice><simpleChoice identifier=\\\"ChoiceD\\\">4</simpleChoice></choiceInteraction></itemBody><responseProcessing template=\\\"http://www.imsglobal.org/question/qti_v2p2/rptemplates/map_response\\\"/></assessmentItem>\"\n }\n ]\n }\n}\n`);
236
+ });
237
+ });
238
+
239
+ it('Entering the request with multiple item references, filtered by type and question reference id', () => {
240
+ cy.get('textarea[class="body-param__text"]')
241
+ .clear()
242
+ .fill(`{ \n "item_references": [\n "DataApiGetQuestionTest1", \n "DataApiGetQuestionTest2"], \n "references": ["${questionRef1}"], \n "types": ["multiple selection"], \n "limit": 50, \n "page": 0, \n "sort_field": "created", \n "sort": "asc"\n }\n`);
243
+ cy.get('.execute')
244
+ .click();
245
+ cy.wait(2000);
246
+ cy.get('.loading-container')
247
+ .should('not.exist');
248
+ //Getting the timestamp
249
+ cy.get('pre[class="microlight"]')
250
+ .eq(1)
251
+ .within(() => {
252
+ cy.contains('timestamp')
253
+ .next().next().then((currTimestamp) => {
254
+ timestamp = currTimestamp[0].innerText
255
+ });
256
+ });
257
+ });
258
+
259
+ it('All the questions of the entered item reference, filtered by the entered type and question reference should be returned in the response, with a status code 200', () => {
260
+ cy.get('pre[class="microlight"]')
261
+ .eq(1)
262
+ .invoke('text')
263
+ .then((text) => {
264
+ // Parse the JSON from the DOM
265
+ const actualResponse = JSON.parse(text);
266
+
267
+ // Extract dynamic values from the parsed object
268
+ const { records, timestamp, next_token } = actualResponse.meta;
269
+ const test1Data = actualResponse.data.DataApiGetQuestionTest1[0];
270
+ const { dt_created, dt_updated, reference: ref1 } = test1Data;
271
+ const test2Data = actualResponse.data.DataApiGetQuestionTest2[0];
272
+ const { reference: ref2 } = test2Data;
273
+
274
+ // First, assert the status code is 200
275
+ cy.get('td[class="response-col_status"]')
276
+ .eq(0)
277
+ .should('have.text', '200');
278
+ cy.get('pre[class="microlight"]')
279
+ .eq(1)
280
+ .should('have.text', `{\n \"meta\": {\n \"status\": true,\n \"records\": ${records},\n \"next_token\": [\n ${next_token[0]},\n \"${next_token[1]}\"\n ],\n \"timestamp\": ${timestamp}\n },\n \"data\": {\n \"DataApiGetQuestionTest1\": [\n {\n \"reference\": \"${ref1}\",\n \"type\": \"multiple selection\",\n \"dt_created\": \"${dt_created}\",\n \"dt_updated\": \"${dt_updated}\",\n \"scoring_type\": \"Auto-scored\",\n \"points\": 2,\n \"penalty_points\": null,\n \"min_score_if_attempted\": null,\n \"min_score_type\": 1,\n \"penalty_point_type\": 1,\n \"is_auto_penalty_setting\": false,\n \"is_negative_rounded\": true,\n \"specific_penalty_type\": 1,\n \"penalty_points_for_each\": null,\n \"scoring_guidance\": \"\",\n \"sample_response\": \"\",\n \"data\": \"<assessmentItem xmlns=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xsi:schemaLocation=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\\\" identifier=\\\"choiceMultiple\\\" title=\\\"Welcome to Biodome\\\" timeDependent=\\\"false\\\"><responseDeclaration identifier=\\\"RESPONSE\\\" cardinality=\\\"multiple\\\" baseType=\\\"identifier\\\"><correctResponse><value>ChoiceA</value><value>ChoiceB</value></correctResponse></responseDeclaration><outcomeDeclaration identifier=\\\"SCORE\\\" cardinality=\\\"single\\\" baseType=\\\"float\\\"/><itemBody><choiceInteraction responseIdentifier=\\\"RESPONSE\\\" orientation=\\\"horizontal\\\"><prompt></prompt><simpleChoice identifier=\\\"ChoiceA\\\">1</simpleChoice><simpleChoice identifier=\\\"ChoiceB\\\">2</simpleChoice><simpleChoice identifier=\\\"ChoiceC\\\">3</simpleChoice><simpleChoice identifier=\\\"ChoiceD\\\">4</simpleChoice></choiceInteraction></itemBody><responseProcessing template=\\\"http://www.imsglobal.org/question/qti_v2p2/rptemplates/map_response\\\"/></assessmentItem>\"\n }\n ],\n \"DataApiGetQuestionTest2\": [\n {\n \"reference\": \"${ref2}\",\n \"type\": \"multiple selection\",\n \"dt_created\": \"${dt_created}\",\n \"dt_updated\": \"${dt_updated}\",\n \"scoring_type\": \"Auto-scored\",\n \"points\": 2,\n \"penalty_points\": null,\n \"min_score_if_attempted\": null,\n \"min_score_type\": 1,\n \"penalty_point_type\": 1,\n \"is_auto_penalty_setting\": false,\n \"is_negative_rounded\": true,\n \"specific_penalty_type\": 1,\n \"penalty_points_for_each\": null,\n \"scoring_guidance\": \"\",\n \"sample_response\": \"\",\n \"data\": \"<assessmentItem xmlns=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xsi:schemaLocation=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\\\" identifier=\\\"choiceMultiple\\\" title=\\\"Welcome to Biodome\\\" timeDependent=\\\"false\\\"><responseDeclaration identifier=\\\"RESPONSE\\\" cardinality=\\\"multiple\\\" baseType=\\\"identifier\\\"><correctResponse><value>ChoiceA</value><value>ChoiceB</value></correctResponse></responseDeclaration><outcomeDeclaration identifier=\\\"SCORE\\\" cardinality=\\\"single\\\" baseType=\\\"float\\\"/><itemBody><choiceInteraction responseIdentifier=\\\"RESPONSE\\\" orientation=\\\"horizontal\\\"><prompt></prompt><simpleChoice identifier=\\\"ChoiceA\\\">1</simpleChoice><simpleChoice identifier=\\\"ChoiceB\\\">2</simpleChoice><simpleChoice identifier=\\\"ChoiceC\\\">3</simpleChoice><simpleChoice identifier=\\\"ChoiceD\\\">4</simpleChoice></choiceInteraction></itemBody><responseProcessing template=\\\"http://www.imsglobal.org/question/qti_v2p2/rptemplates/map_response\\\"/></assessmentItem>\"\n }\n ]\n }\n}\n`);
281
+ });
282
+ });
283
+
284
+ it('Entering request with an invalid question type', () => {
285
+ cy.get('textarea[class="body-param__text"]')
286
+ .clear()
287
+ .fill(`{ \n "item_references": [\n "DataApiGetQuestionTest1", \n "DataApiGetQuestionTest2", \n "non existing reference"\n], \n "references": [], \n "types": ["Passage"], \n "limit": 50, \n "page": 0, \n "sort_field": "created", \n "sort": "asc"\n }\n`);
288
+ cy.get('.execute')
289
+ .click();
290
+ cy.wait(2000);
291
+ cy.get('.loading-container')
292
+ .should('not.exist');
293
+ //Storing the timestamp for assertion
294
+ cy.get('pre[class="microlight"]')
295
+ .eq(1)
296
+ .within(() => {
297
+ cy.contains('timestamp')
298
+ .next().next().then((currTimestamp) => {
299
+ timestamp = currTimestamp[0].innerText
300
+ });
301
+ });
302
+ });
303
+
304
+ it('A blank data array should be received in the response, with a status code 200', () => {
305
+ cy.get('td[class="response-col_status"]')
306
+ .eq(0)
307
+ .should('have.text', '200');
308
+ cy.get('pre[class="microlight"]')
309
+ .eq(1)
310
+ .should('have.text', `{\n \"meta\": {\n \"message\": \"Please provide valid question types\",\n \"timestamp\": ${timestamp},\n \"status\": false\n },\n \"data\": []\n}\n`);
311
+ });
312
+
313
+ it('Entering request with a non existing question reference', () => {
314
+ cy.get('textarea[class="body-param__text"]')
315
+ .clear()
316
+ .fill(`{ \n "item_references": [\n "DataApiGetQuestionTest1", \n "DataApiGetQuestionTest2", \n "non existing reference"\n], \n "references": ["non existing question reference id"], \n "types": [], \n "limit": 50, \n "page": 0, \n "sort_field": "created", \n "sort": "asc"\n }\n`);
317
+ cy.get('.execute')
318
+ .click();
319
+ cy.wait(2000);
320
+ cy.get('.loading-container')
321
+ .should('not.exist');
322
+ //Storing the timestamp for assertion
323
+ cy.get('pre[class="microlight"]')
324
+ .eq(1)
325
+ .within(() => {
326
+ cy.contains('timestamp')
327
+ .next().next().then((currTimestamp) => {
328
+ timestamp = currTimestamp[0].innerText
329
+ });
330
+ });
331
+ });
332
+
333
+ it('A blank data array should be received in the response, with a status code 200', () => {
334
+ cy.get('td[class="response-col_status"]')
335
+ .eq(0)
336
+ .should('have.text', '200');
337
+ cy.get('pre[class="microlight"]')
338
+ .eq(1)
339
+ .should('have.text', `{\n \"meta\": {\n \"status\": true,\n \"records\": 0,\n \"next_token\": null,\n \"timestamp\": ${timestamp}\n },\n \"data\": []\n}\n`);
340
+ });
341
+
342
+ it('Entering request with an existing question reference', () => {
343
+ cy.get('textarea[class="body-param__text"]')
344
+ .clear()
345
+ .fill(`{ \n "item_references": [\n "DataApiGetQuestionTest1", \n "DataApiGetQuestionTest2"], \n "references": ["${questionRef1}"], \n "types": ["multiple selection"], \n "limit": 50, \n "page": 0, \n "sort_field": "created", \n "sort": "asc"\n }\n`);
346
+ cy.get('.execute')
347
+ .click();
348
+ cy.wait(2000);
349
+ cy.get('.loading-container')
350
+ .should('not.exist');
351
+ });
352
+
353
+ it('The question as per the entered question reference, should be returned in the response, with a status code 200', () => {
354
+ cy.get('pre[class="microlight"]')
355
+ .eq(1)
356
+ .invoke('text')
357
+ .then((text) => {
358
+ // Parse the JSON from the DOM
359
+ const actualResponse = JSON.parse(text);
360
+
361
+ // Extract dynamic values from the parsed object
362
+ const { records, timestamp, next_token } = actualResponse.meta;
363
+ const test1Data = actualResponse.data.DataApiGetQuestionTest1[0];
364
+ const { dt_created, dt_updated, reference: ref1 } = test1Data;
365
+ const test2Data = actualResponse.data.DataApiGetQuestionTest2[0];
366
+ const { reference: ref2 } = test2Data;
367
+ questionRef1 = ref1;
368
+ questionRef2 = ref2;
369
+
370
+ // First, assert the status code is 200
371
+ cy.get('td[class="response-col_status"]')
372
+ .eq(0)
373
+ .should('have.text', '200');
374
+ cy.get('pre[class="microlight"]')
375
+ .eq(1)
376
+ .should('have.text', `{\n \"meta\": {\n \"status\": true,\n \"records\": ${records},\n \"next_token\": [\n ${next_token[0]},\n \"${next_token[1]}\"\n ],\n \"timestamp\": ${timestamp}\n },\n \"data\": {\n \"DataApiGetQuestionTest1\": [\n {\n \"reference\": \"${ref1}\",\n \"type\": \"multiple selection\",\n \"dt_created\": \"${dt_created}\",\n \"dt_updated\": \"${dt_updated}\",\n \"scoring_type\": \"Auto-scored\",\n \"points\": 2,\n \"penalty_points\": null,\n \"min_score_if_attempted\": null,\n \"min_score_type\": 1,\n \"penalty_point_type\": 1,\n \"is_auto_penalty_setting\": false,\n \"is_negative_rounded\": true,\n \"specific_penalty_type\": 1,\n \"penalty_points_for_each\": null,\n \"scoring_guidance\": \"\",\n \"sample_response\": \"\",\n \"data\": \"<assessmentItem xmlns=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xsi:schemaLocation=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\\\" identifier=\\\"choiceMultiple\\\" title=\\\"Welcome to Biodome\\\" timeDependent=\\\"false\\\"><responseDeclaration identifier=\\\"RESPONSE\\\" cardinality=\\\"multiple\\\" baseType=\\\"identifier\\\"><correctResponse><value>ChoiceA</value><value>ChoiceB</value></correctResponse></responseDeclaration><outcomeDeclaration identifier=\\\"SCORE\\\" cardinality=\\\"single\\\" baseType=\\\"float\\\"/><itemBody><choiceInteraction responseIdentifier=\\\"RESPONSE\\\" orientation=\\\"horizontal\\\"><prompt></prompt><simpleChoice identifier=\\\"ChoiceA\\\">1</simpleChoice><simpleChoice identifier=\\\"ChoiceB\\\">2</simpleChoice><simpleChoice identifier=\\\"ChoiceC\\\">3</simpleChoice><simpleChoice identifier=\\\"ChoiceD\\\">4</simpleChoice></choiceInteraction></itemBody><responseProcessing template=\\\"http://www.imsglobal.org/question/qti_v2p2/rptemplates/map_response\\\"/></assessmentItem>\"\n }\n ],\n \"DataApiGetQuestionTest2\": [\n {\n \"reference\": \"${ref2}\",\n \"type\": \"multiple selection\",\n \"dt_created\": \"${dt_created}\",\n \"dt_updated\": \"${dt_updated}\",\n \"scoring_type\": \"Auto-scored\",\n \"points\": 2,\n \"penalty_points\": null,\n \"min_score_if_attempted\": null,\n \"min_score_type\": 1,\n \"penalty_point_type\": 1,\n \"is_auto_penalty_setting\": false,\n \"is_negative_rounded\": true,\n \"specific_penalty_type\": 1,\n \"penalty_points_for_each\": null,\n \"scoring_guidance\": \"\",\n \"sample_response\": \"\",\n \"data\": \"<assessmentItem xmlns=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xsi:schemaLocation=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\\\" identifier=\\\"choiceMultiple\\\" title=\\\"Welcome to Biodome\\\" timeDependent=\\\"false\\\"><responseDeclaration identifier=\\\"RESPONSE\\\" cardinality=\\\"multiple\\\" baseType=\\\"identifier\\\"><correctResponse><value>ChoiceA</value><value>ChoiceB</value></correctResponse></responseDeclaration><outcomeDeclaration identifier=\\\"SCORE\\\" cardinality=\\\"single\\\" baseType=\\\"float\\\"/><itemBody><choiceInteraction responseIdentifier=\\\"RESPONSE\\\" orientation=\\\"horizontal\\\"><prompt></prompt><simpleChoice identifier=\\\"ChoiceA\\\">1</simpleChoice><simpleChoice identifier=\\\"ChoiceB\\\">2</simpleChoice><simpleChoice identifier=\\\"ChoiceC\\\">3</simpleChoice><simpleChoice identifier=\\\"ChoiceD\\\">4</simpleChoice></choiceInteraction></itemBody><responseProcessing template=\\\"http://www.imsglobal.org/question/qti_v2p2/rptemplates/map_response\\\"/></assessmentItem>\"\n }\n ]\n }\n}\n`);
377
+ });
378
+ });
379
+
380
+ it('Entering request with an invalid combination of item and question reference', () => {
381
+ cy.get('textarea[class="body-param__text"]')
382
+ .clear()
383
+ .fill(`{ \n "item_references": [\n "DataApiGetQuestionTest2"], \n "references": ["${questionAndResourceReferenceIds[0][0]}"], \n "types": [], \n "limit": 50, \n "page": 0, \n "sort_field": "created", \n "sort": "asc"\n }\n`);
384
+ cy.get('.execute')
385
+ .click();
386
+ cy.wait(2000);
387
+ cy.get('.loading-container')
388
+ .should('not.exist');
389
+ //Storing the timestamp for assertion
390
+ cy.get('pre[class="microlight"]')
391
+ .eq(1)
392
+ .within(() => {
393
+ cy.contains('timestamp')
394
+ .next().next().then((currTimestamp) => {
395
+ timestamp = currTimestamp[0].innerText
396
+ });
397
+ });
398
+ });
399
+
400
+ it('A blank data array should be received in the response, with a status code 200', () => {
401
+ cy.get('td[class="response-col_status"]')
402
+ .eq(0)
403
+ .should('have.text', '200');
404
+ cy.get('pre[class="microlight"]')
405
+ .eq(1)
406
+ .should('have.text', `{\n \"meta\": {\n \"status\": true,\n \"records\": 0,\n \"next_token\": null,\n \"timestamp\": ${timestamp}\n },\n \"data\": []\n}\n`);
407
+ });
408
+ });