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,216 @@
1
+ import { getShortDate } from '../../support/commands';
2
+ import { createdAndUpdatedAtDate, questionAndResourceReferenceIds } from '../../support/helpers/createItem';
3
+ import uuid from 'react-uuid';
4
+ import utilities from '../../support/helpers/utilities';
5
+ var dataApiQuestionAndResourceIds = [];
6
+ for (var i = 0; i < 2; i++) {
7
+ dataApiQuestionAndResourceIds.push(uuid());
8
+ };
9
+ //93f228f9-d4f7-8c36-effd-cd6b6e87b329
10
+ //36e2967e-4260-a739-97e4-33ece5b39b3b
11
+ var timestamp
12
+
13
+
14
+ describe('Save Item Data API cases', () => {
15
+ before(() => {
16
+ cy.loginAs('admin');
17
+ cy.createItem('DataAPITest11');
18
+ cy.createItem('DataAPITest22');
19
+ cy.createItem('ItemCreatedWithSetItemDataAPI');
20
+ cy.visit(`${Cypress.env('itemEngineHomePage')}`);
21
+ });
22
+
23
+ after(() => {
24
+ cy.deleteItem('ItemCreatedWithSetItemDataAPI');
25
+ cy.deleteItems();
26
+ cy.logout();
27
+ });
28
+
29
+ it('Creating question and resource from save API, to be used in the item', () => {
30
+ cy.visit('/item-engine/data-api/item-bank/save-questions')
31
+ cy.get('.try-out__btn')
32
+ .click();
33
+ cy.get('textarea[class="body-param__text"]')
34
+ .clear()
35
+ .fill(`{"questions":[{"reference":'${dataApiQuestionAndResourceIds[0]}',"instruction":"question instructions","points":20,"is_auto_scored":false,"type":6,"question_xml":"<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=\\"\\"><prompt>Please write a short essay in the response field displayed below</prompt></extendedTextInteraction></itemBody></assessmentItem>","scoring_type_id":2,"teacher_guideline":"guidelines for this questions if any","penalty_points":"0","min_score_if_attempted":"0","min_score_type":1,"penalty_point_type":1,"is_auto_penalty_setting":false,"is_negative_rounded":true,"specific_penalty_type":1,"penalty_points_for_each":"0"}]}'`);
36
+ cy.get('.execute')
37
+ .click();
38
+ cy.wait(2000);
39
+ cy.get('.loading-container')
40
+ .should('not.exist');
41
+ cy.visit('/item-engine/data-api/item-bank/save-resources')
42
+ cy.get('.try-out__btn')
43
+ .click();
44
+ //Need to update below code of resource
45
+ cy.get('textarea[class="body-param__text"]')
46
+ .clear()
47
+ .fill(`{\n "resources": [\n {\n "type": 1,\n "data": {\n "type": "Passage",\n "heading": "Passage created via save resources data API",\n "content": "This is content of the passage"\n },\n "reference": "${dataApiQuestionAndResourceIds[1]}"\n }\n ],\n "organisation_id": "${Cypress.env('organisation_id')}",\n "meta": {\n "user": {\n "id": "dfbb6366-d88d-416d-9d9c-7ee6420817b3",\n "first_name": "fname",\n "last_name": "lname",\n "email": "user@demo.com"\n }\n }\n}\n`);
48
+ cy.get('.execute')
49
+ .click();
50
+ cy.wait(2000);
51
+ cy.get('.loading-container')
52
+ .should('not.exist');
53
+ });
54
+
55
+ it('If the user clicks on the Save Items option from the menu bar, user should be navigated to the Save Items page', () => {
56
+ cy.contains('Save Items')
57
+ .click();
58
+ cy.contains('Save Items')
59
+ .parent()
60
+ .parent()
61
+ .should('have.class', 'Mui-selected');
62
+ cy.url()
63
+ .should('eq', Cypress.config().baseUrl + '/item-engine/data-api/item-bank/save-items');
64
+ });
65
+
66
+ it('Example Request should be displayed', () => {
67
+ cy.get('pre[class="body-param__example microlight"]')
68
+ .eq(0)
69
+ .then((text) => {
70
+ console.log(text[0].innerText)
71
+ });
72
+ cy.get('pre[class="body-param__example microlight"]')
73
+ .eq(0)
74
+ .should('have.text', `{\n "items": [\n {\n "reference": "dataApiRef01",\n "status": 1,\n "metadata": [\n {\n "meta_key_value": "metadata1",\n "meta_key": "metadata-type"\n },\n {\n "meta_key_value": "metadata2",\n "meta_key": "metadata-type"\n }\n ],\n "title": "title for this item",\n "instruction": "instruction for this item",\n "description": "description data for this item",\n "resources": [\n {\n "reference": "myPassageRef03",\n "serial_no": 1\n }\n ],\n "questions": [\n {\n "reference": "question ref 034",\n "serial_no": 2\n },\n {\n "reference": "question ref 037",\n "serial_no": 3\n }\n ]\n }\n ],\n "organisation_id": "eb7d4a20-c96c-4852-9b34-7e3231016315",\n "meta": {\n "user": {\n "id": "dfbb6366-d88d-416d-9d9c-7ee6420817b3",\n "first_name": "fname",\n "last_name": "lname",\n "email": "user@demo.com"\n }\n }\n}\n`);
75
+ //Getting the timestamp
76
+ cy.get('pre[class="example microlight"]')
77
+ .eq(0)
78
+ .within(() => {
79
+ cy.contains('timestamp')
80
+ .next().next().then((currTimestamp) => {
81
+ timestamp = currTimestamp[0].innerText
82
+ });
83
+ });
84
+ });
85
+
86
+ it('Example Response for status code 200 should be displayed', () => {
87
+ cy.get('td[class="response-col_status"]')
88
+ .eq(0)
89
+ .should('have.text', '200');
90
+ cy.get('.response-col_description__inner')
91
+ .eq(0)
92
+ .should('have.text', 'OK');
93
+ cy.get('pre[class="example microlight"]')
94
+ .eq(0)
95
+ .should('have.text', `{\n "meta": {\n "status": true,\n "timestamp": ${timestamp}\n },\n "data": []\n}\n`);
96
+ });
97
+
98
+ it('Example Response for status code 422 should be displayed', () => {
99
+ cy.get('td[class="response-col_status"]')
100
+ .eq(2)
101
+ .should('have.text', '422');
102
+ cy.get('.response-col_description__inner')
103
+ .eq(2)
104
+ .should('have.text', 'Invalid Request');
105
+ cy.get('pre[class="example microlight"]')
106
+ .eq(2)
107
+ .should('have.text', '{\n "meta": {\n "status": false,\n "message": "\\"[0].reference\\" is required",\n "timestamp": 1653650826764\n },\n "data": []\n}\n');
108
+ });
109
+
110
+ it('Entering request with empty item reference', () => {
111
+ cy.get('.try-out__btn')
112
+ .click();
113
+ cy.get('textarea[class="body-param__text"]')
114
+ .clear()
115
+ .fill(`{\n "items": [\n {\n "reference": "",\n "status": 1,\n "tags": [\n "tag-test-1"\n ],\n "title": "title for this item",\n "instruction": "instruction for this item",\n "description": "description data for this item",\n "resources": [\n {\n "reference": "${dataApiQuestionAndResourceIds[3]}",\n "serial_no": 1\n }\n ],\n "questions": [\n {\n "reference": "${dataApiQuestionAndResourceIds[4]}",\n "serial_no": 2\n },\n {\n "reference": "${dataApiQuestionAndResourceIds[5]}",\n "serial_no": 3\n }\n ]\n }\n ],\n "meta": {\n "user": {\n "id": "dfbb6366-d88d-416d-9d9c-7ee6420817b3",\n "first_name": "fname",\n "last_name": "lname",\n "email": "user@demo.com"\n }\n }\n}`);
116
+ cy.get('.execute')
117
+ .click();
118
+ cy.wait(50000);
119
+ cy.get('.loading-container')
120
+ .should('not.exist');
121
+ });
122
+
123
+ it('Reference not allowed to be empty message should be received in the response, with status code 422', () => {
124
+ cy.get('td[class="response-col_status"]')
125
+ .eq(0)
126
+ .should('have.text', '504 Undocumented ');
127
+ cy.get('.response-col_description')
128
+ .eq(1)
129
+ .find('span')
130
+ .eq(0)
131
+ .should('have.text', '<!DOCTYPE ');
132
+ ///Need to revisit
133
+ // cy.get('pre[class="microlight"]')
134
+ // .eq(0)
135
+ // .should('have.text', '{\n "message": "\\"items[0].reference\\" is not allowed to be empty",\n "success": false\n}\n');
136
+ });
137
+
138
+ it('Entering request with a question/resource reference id which does not exist', () => {
139
+ cy.get('textarea[class="body-param__text"]')
140
+ .clear()
141
+ .fill(`{\n "items": [\n {\n "reference": "does not exist",\n "status": 1,\n "metadata": [\n {\n "meta_key_value": "metadata1",\n "meta_key": "metadata-type"\n },\n {\n "meta_key_value": "metadata2",\n "meta_key": "metadata-type"\n }\n ],\n "title": "title for this item",\n "instruction": "instruction for this item",\n "description": "description data for this item",\n "resources": [\n {\n "reference": "myPassageRef03",\n "serial_no": 1\n }\n ],\n "questions": [\n {\n "reference": "question ref 034",\n "serial_no": 2\n },\n {\n "reference": "question ref 037",\n "serial_no": 3\n }\n ]\n }\n ],\n "meta": {\n "user": {\n "id": "dfbb6366-d88d-416d-9d9c-7ee6420817b3",\n "first_name": "fname",\n "last_name": "lname",\n "email": "user@demo.com"\n }\n }\n}`);
142
+ cy.get('.execute')
143
+ .click();
144
+ });
145
+
146
+ it('The question/ resources with the given reference does not exist message should be recieved in the response with status code 200', () => {
147
+ cy.get('td[class="response-col_status"]')
148
+ .eq(0)
149
+ .should('have.text', '200');
150
+ cy.get('.response-col_description')
151
+ .eq(1)
152
+ .contains('The questions/resources with given reference does not exists');
153
+ });
154
+
155
+ it('Entering request with a valid item reference id and valid question and resource reference ids', () => {
156
+ cy.get('textarea[class="body-param__text"]')
157
+ .clear()
158
+ .fill(`{\n "items": [\n {\n "reference": "ItemCreatedWithSetItemDataAPI"\n }\n ]\n}\n`);
159
+ cy.get('.execute')
160
+ .click();
161
+ cy.wait(2000);
162
+ cy.get('.loading-container')
163
+ .should('not.exist');
164
+ //Getting the timestamp
165
+ cy.get('pre[class="microlight"]')
166
+ .eq(1)
167
+ .within(() => {
168
+ cy.contains('timestamp')
169
+ .next().next().then((currTimestamp) => {
170
+ timestamp = currTimestamp[0].innerText
171
+ });
172
+ });
173
+ });
174
+
175
+ it('Status:true message should be received in the response, with status code 200', () => {
176
+ cy.get('td[class="response-col_status"]')
177
+ .eq(0)
178
+ .should('have.text', '200');
179
+ cy.get('pre[class="microlight"]')
180
+ .eq(1)
181
+ .should('have.text', `{\n "meta": {\n "status": true,\n "timestamp": ${timestamp}\n },\n "data": []\n}\n`);
182
+ });
183
+
184
+ it('The created item should be available on the browse items page', () => {
185
+ cy.visit('/item-engine/demo/browse-items');
186
+ cy.get('td[data-testid="MuiDataTableBodyCell-0-0"]')
187
+ .within(() => {
188
+ cy.get('button')
189
+ .eq(0)
190
+ .should('have.text', 'ItemCreatedWithSetItemDataAPI');
191
+ cy.get('div[class*="ItemTitleCellstyles__QuestionTextContainer"]')
192
+ .eq(1)
193
+ .should('have.text', 'Questions:\u00a0')
194
+ .next()
195
+ .should('have.text', '1');
196
+ cy.get('span[class*="DynamicLengthItemListstyles__LabelText"]')
197
+ .should('have.text', 'Type: ')
198
+ .next()
199
+ .should('have.text', 'multiple selection');
200
+ });
201
+ cy.get('td[data-testid="MuiDataTableBodyCell-1-0"]')
202
+ .find('time')
203
+ .contains(getShortDate(0).completeShortDate);
204
+ });
205
+
206
+ it('The questions and resources added in the item should be present on the edit item page', () => {
207
+ cy.visit(`/item-engine/demo/edit-item/${utilities.base64Encoding('ItemCreatedWithSetItemDataAPI')}`);
208
+ cy.lazyLoadingWait(4, 8);
209
+ cy.get('[data-rbd-draggable-context-id="0"]')
210
+ .eq(0)
211
+ .within(() => {
212
+ cy.get('div[class*="Widgetstyles__QuestionTypeText"]')
213
+ .should('have.text', 'multiple selection');
214
+ });
215
+ });
216
+ });
@@ -0,0 +1,214 @@
1
+ import uuid from 'react-uuid';
2
+
3
+ describe('Set Question Data API cases', () => {
4
+ var timestamp;
5
+ before(() => {
6
+ cy.loginAs('admin');
7
+ cy.visit(`${Cypress.env('itemEngineHomePage')}`);
8
+ });
9
+
10
+ after(() => {
11
+ cy.logout();
12
+ });
13
+
14
+ it('If the user clicks on the Save Questions option from the menu bar, user should be navigated to the Save Questions page', () => {
15
+ cy.contains('Item Bank')
16
+ .click();
17
+ cy.contains('Save Questions')
18
+ .click();
19
+ cy.contains('Save Questions')
20
+ .parent()
21
+ .parent()
22
+ .should('have.class', 'Mui-selected');
23
+ cy.url()
24
+ .should('eq', Cypress.config().baseUrl + '/item-engine/data-api/item-bank/save-questions');
25
+ });
26
+
27
+ it('Example Request should be displayed', () => {
28
+ cy.get('pre[class="body-param__example microlight"]')
29
+ .eq(0)
30
+ .should('have.text', "{\n \"questions\": [\n {\n \"reference\": \"uniq ques ref 001\",\n \"instruction\": \"question instructions\",\n \"points\": 10,\n \"is_auto_scored\": true,\n \"type\": 5,\n \"question_xml\": \"<assessmentItem \\r\\n xmlns=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2\\\"\\r\\n xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\"\\r\\n xsi:schemaLocation=\\\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\\\"\\r\\n identifier=\\\"choiceMultiple\\\" \\r\\n title=\\\"Welcome to Biodome\\\" \\r\\n timeDependent=\\\"false\\\"\\r\\n>\\r\\n <responseDeclaration identifier=\\\"RESPONSE\\\" cardinality=\\\"multiple\\\" baseType=\\\"identifier\\\">\\r\\n <correctResponse>\\r\\n <value>ChoiceA</value>\\r\\n <value>ChoiceE</value>\\r\\n </correctResponse>\\r\\n <mapping>\\r\\n <mapEntry mapKey=\\\"ChoiceA\\\" mappedValue=\\\"1\\\"/>\\r\\n <mapEntry mapKey=\\\"ChoiceE\\\" mappedValue=\\\"3\\\"/>\\r\\n </mapping>\\r\\n </responseDeclaration>\\r\\n <outcomeDeclaration identifier=\\\"SCORE\\\" cardinality=\\\"single\\\" baseType=\\\"float\\\"/>\\r\\n <itemBody>\\r\\n <choiceInteraction responseIdentifier=\\\"RESPONSE\\\">\\r\\n <prompt> \\r\\n Zebras having stripes is a trait that might help them to survive. \\r\\n Which of the statements below are possible advantages of stripes. \\r\\n Select all that apply\\r\\n </prompt>\\r\\n <simpleChoice identifier=\\\"ChoiceA\\\" >Stripes help to confuse predators.</simpleChoice>\\r\\n <simpleChoice identifier=\\\"ChoiceB\\\" >Stripes help to attract predators.</simpleChoice>\\r\\n <simpleChoice identifier=\\\"ChoiceC\\\" >Stripes help human hunters to see zebras more easily.</simpleChoice>\\r\\n <simpleChoice identifier=\\\"ChoiceD\\\" >Stripes help zebras attract biting insects.</simpleChoice>\\r\\n <simpleChoice identifier=\\\"ChoiceE\\\" >Stripes help zebras to find mates to reproduce with.</simpleChoice>\\r\\n </choiceInteraction>\\r\\n </itemBody>\\r\\n <responseProcessing template=\\\"http://www.imsglobal.org/question/qti_v2p2/rptemplates/map_response\\\"/>\\r\\n</assessmentItem>\\r\\n\",\n \"scoring_type_id\": 1,\n \"teacher_guideline\": \"guidelines for this questions if any\",\n \"penalty_points\": \"0\",\n \"min_score_if_attempted\": \"0\",\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\": \"0\"\n }\n ],\n \"organisation_id\": \"eb7d4a20-c96c-4852-9b34-7e3231016315\",\n \"meta\": {\n \"user\": {\n \"id\": \"dfbb6366-d88d-416d-9d9c-7ee6420817b3\",\n \"first_name\": \"fname\",\n \"last_name\": \"lname\",\n \"email\": \"user@demo.com\"\n }\n }\n}\n")
31
+ //Storing the timestamp for assertion
32
+ cy.get('pre[class="example microlight"]')
33
+ .eq(0)
34
+ .within(() => {
35
+ cy.contains('timestamp')
36
+ .next().next().then((currTimestamp) => {
37
+ timestamp = currTimestamp[0].innerText
38
+ });
39
+ });
40
+ });
41
+
42
+ it('Example Response for status code 200 should be displayed', () => {
43
+ cy.get('td[class="response-col_status"]')
44
+ .eq(0)
45
+ .should('have.text', '200');
46
+ cy.get('.response-col_description__inner')
47
+ .eq(0)
48
+ .should('have.text', 'OK');
49
+ cy.get('pre[class="example microlight"]')
50
+ .eq(0)
51
+ .should('have.text', `{\n \"meta\": {\n \"status\": true,\n \"timestamp\": 1652111372008\n },\n \"data\": []\n}\n`);
52
+ });
53
+
54
+ it('Example Response for status code 401 should be displayed', () => {
55
+ cy.get('td[class="response-col_status"]')
56
+ .eq(1)
57
+ .should('have.text', '401');
58
+ cy.get('.response-col_description__inner')
59
+ .eq(1)
60
+ .should('have.text', 'Unauthorized');
61
+ cy.get('pre[class="example microlight"]')
62
+ .eq(1)
63
+ .should('have.text', "{\n \"meta\": {\n \"status\": false,\n \"message\": \"Invalid Signature\",\n \"timestamp\": 1653650826764\n },\n \"data\": []\n}\n");
64
+ });
65
+
66
+ it('Example Response for status code 422 should be displayed', () => {
67
+ cy.get('td[class="response-col_status"]')
68
+ .eq(2)
69
+ .should('have.text', '422');
70
+ cy.get('.response-col_description__inner')
71
+ .eq(2)
72
+ .should('have.text', 'Unprocessable Entity (WebDAV)');
73
+ cy.get('pre[class="example microlight"]')
74
+ .eq(2)
75
+ .should('have.text', "{\n \"meta\": {\n \"status\": false,\n \"message\": \"\\\"[0].question_xml\\\" is required\",\n \"timestamp\": 1653650826764\n },\n \"data\": []\n}\n");
76
+ });
77
+
78
+ it('Example Response for status code 500 should be displayed', () => {
79
+ cy.get('td[class="response-col_status"]')
80
+ .eq(3)
81
+ .should('have.text', '500');
82
+ cy.get('.response-col_description__inner')
83
+ .eq(3)
84
+ .should('have.text', 'Internal Server Error');
85
+ cy.get('pre[class="example microlight"]')
86
+ .eq(3)
87
+ .should('have.text', "{\n \"meta\": {\n \"status\": false,\n \"message\": \"Error occurred while saving data\",\n \"timestamp\": 1653650826764\n },\n \"data\": []\n}\n");
88
+ });
89
+
90
+ it('Entering request without the reference property', () => {
91
+ cy.get('.try-out__btn')
92
+ .click();
93
+ cy.get('textarea[class="body-param__text"]')
94
+ .clear()
95
+ .fill(`{\n "questions": [\n {\n "instruction": "question instructions",\n "points": 10,\n "is_auto_scored": true,\n "type": 5,\n "question_xml": "Random XML",\n "scoring_type_id": 1,\n "teacher_guideline": "guidelines for this questions if any",\n "penalty_points": "0",\n "min_score_if_attempted": "0"\n }\n ],\n "meta": {\n "user": {\n "id": "dfbb6366-d88d-416d-9d9c-7ee6420817b3",\n "first_name": "fname",\n "last_name": "lname",\n "email": "user@demo.com"\n }\n }\n}`);
96
+ cy.get('.execute')
97
+ .click();
98
+ cy.wait(2000);
99
+ cy.get('.loading-container')
100
+ .should('not.exist');
101
+ });
102
+
103
+ it('Reference property is required message should be received in the response, with status code 422', () => {
104
+ cy.get('td[class="response-col_status"]')
105
+ .eq(0)
106
+ .should('have.text', '200');
107
+ cy.get('pre[class="microlight"]')
108
+ .eq(1)
109
+ .find('span')
110
+ .eq(7)
111
+ .should('have.text', "\"\\\"questions[0].reference\\\" is required\"");
112
+ });
113
+
114
+ it('Entering request with incorrect question_XML', () => {
115
+ cy.get('textarea[class="body-param__text"]')
116
+ .clear()
117
+ .fill(`{\n "questions": [\n {\n "reference": "uniq ques ref 002",\n "instruction": "question instructions",\n "points": 10,\n "is_auto_scored": true,\n "type": 5,\n "question_xml": "Random XML",\n "scoring_type_id": 1,\n "teacher_guideline": "guidelines for this questions if any",\n "penalty_points": "0",\n "min_score_if_attempted": "0"\n }\n ],\n "meta": {\n "user": {\n "id": "f8888c-f3fe-4642-440a-a32d47cd20be",\n "first_name": "fname",\n "last_name": "lname",\n "email": "user@demo.com"\n }\n }\n}`);
118
+ cy.get('.execute')
119
+ .click();
120
+ cy.wait(2000);
121
+ cy.get('.loading-container')
122
+ .should('not.exist');
123
+ cy.get('pre[class="microlight"]')
124
+ .eq(1)
125
+ .within(() => {
126
+ cy.contains('timestamp')
127
+ .next().next().then((currTimestamp) => {
128
+ timestamp = currTimestamp[0].innerText
129
+ });
130
+ });
131
+ });
132
+
133
+ //need to check the status code
134
+ it('Invalid XML message should be received in the response, with status code 200', () => {
135
+ cy.get('td[class="response-col_status"]')
136
+ .eq(0)
137
+ .should('have.text', '200');
138
+ cy.get('pre[class="microlight"]')
139
+ .eq(1)
140
+ .should('have.text', `{\n \"meta\": {\n \"message\": \"Error occurred while saving data\",\n \"timestamp\": ${timestamp},\n \"status\": false\n },\n \"data\": []\n}\n`);
141
+ });
142
+
143
+ it('Entering request with empty question_XML', () => {
144
+ cy.get('textarea[class="body-param__text"]')
145
+ .clear()
146
+ .fill(`{\n "questions": [\n {\n "reference": "uniq ques ref 001",\n "instruction": "question instructions",\n "points": 10,\n "is_auto_scored": true,\n "type": 5,\n "question_xml": "",\n "scoring_type_id": 1,\n "teacher_guideline": "guidelines for this questions if any",\n "penalty_points": "0",\n "min_score_if_attempted": "0"\n }\n ],\n "meta": {\n "user": {\n "id": "dfbb6366-d88d-416d-9d9c-7ee6420817b3",\n "first_name": "fname",\n "last_name": "lname",\n "email": "user@demo.com"\n }\n }\n}`);
147
+ cy.get('.execute')
148
+ .click();
149
+ cy.wait(2000);
150
+ cy.get('.loading-container')
151
+ .should('not.exist');
152
+ });
153
+
154
+ //need to check the status code
155
+ it('XML is not allowed to be empty message should be received in the response, with status code 422', () => {
156
+ cy.get('td[class="response-col_status"]')
157
+ .eq(0)
158
+ .should('have.text', '200');
159
+ cy.get('pre[class="microlight"]')
160
+ .eq(1)
161
+ .find('span')
162
+ .eq(7)
163
+ .should('have.text',"\"\\\"questions[0].questionXml\\\" is not allowed to be empty\"");
164
+ });
165
+
166
+ it('Entering request with already existing question reference', () => {
167
+ cy.get('textarea[class="body-param__text"]')
168
+ .clear()
169
+ .fill('{\n "questions": [\n {\n "reference": "uniq ques ref 001",\n "instruction": "question instructions",\n "points": 10,\n "is_auto_scored": true,\n "type": 5,\n "question_xml": "<assessmentItem \\r\\n xmlns=\\"http://www.imsglobal.org/xsd/imsqti_v2p2\\"\\r\\n xmlns:xsi=\\"http://www.w3.org/2001/XMLSchema-instance\\"\\r\\n xsi:schemaLocation=\\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\\"\\r\\n identifier=\\"choiceMultiple\\" \\r\\n title=\\"Welcome to Biodome\\" \\r\\n timeDependent=\\"false\\"\\r\\n>\\r\\n <responseDeclaration identifier=\\"RESPONSE\\" cardinality=\\"multiple\\" baseType=\\"identifier\\">\\r\\n <correctResponse>\\r\\n <value>ChoiceA</value>\\r\\n <value>ChoiceE</value>\\r\\n </correctResponse>\\r\\n <mapping>\\r\\n <mapEntry mapKey=\\"ChoiceA\\" mappedValue=\\"1\\"/>\\r\\n <mapEntry mapKey=\\"ChoiceE\\" mappedValue=\\"3\\"/>\\r\\n </mapping>\\r\\n </responseDeclaration>\\r\\n <outcomeDeclaration identifier=\\"SCORE\\" cardinality=\\"single\\" baseType=\\"float\\"/>\\r\\n <itemBody>\\r\\n <choiceInteraction responseIdentifier=\\"RESPONSE\\">\\r\\n <prompt> \\r\\n Zebras having stripes is a trait that might help them to survive. \\r\\n Which of the statements below are possible advantages of stripes. \\r\\n Select all that apply\\r\\n </prompt>\\r\\n <simpleChoice identifier=\\"ChoiceA\\" >Stripes help to confuse predators.</simpleChoice>\\r\\n <simpleChoice identifier=\\"ChoiceB\\" >Stripes help to attract predators.</simpleChoice>\\r\\n <simpleChoice identifier=\\"ChoiceC\\" >Stripes help human hunters to see zebras more easily.</simpleChoice>\\r\\n <simpleChoice identifier=\\"ChoiceD\\" >Stripes help zebras attract biting insects.</simpleChoice>\\r\\n <simpleChoice identifier=\\"ChoiceE\\" >Stripes help zebras to find mates to reproduce with.</simpleChoice>\\r\\n </choiceInteraction>\\r\\n </itemBody>\\r\\n <responseProcessing template=\\"http://www.imsglobal.org/question/qti_v2p2/rptemplates/map_response\\"/>\\r\\n</assessmentItem>\\r\\n",\n "scoring_type_id": 1,\n "teacher_guideline": "guidelines for this questions if any",\n "penalty_points": "0",\n "min_score_if_attempted": "0"\n }\n ]\n}\n');
170
+ cy.get('.execute')
171
+ .click();
172
+ cy.wait(2000);
173
+ cy.get('.loading-container')
174
+ .should('not.exist');
175
+ });
176
+
177
+ it('Reference id already exists message should be received in the response, with status code 422', () => {
178
+ cy.get('pre[class="microlight"]')
179
+ .eq(1)
180
+ cy.get('pre[class="microlight"]')
181
+ .eq(1)
182
+ .find('span')
183
+ .eq(7)
184
+ .should('have.text',"\"Key (reference_id, organisation_id)=(uniq ques ref 001, 7e15466c-30cb-4fdf-b160-6e6fc3660d0e) already exists.\"");
185
+ });
186
+
187
+ it('Entering request to create 2 questions with valid reference ids', () => {
188
+ cy.get('textarea[class="body-param__text"]')
189
+ .clear()
190
+ .fill(`{\n "questions": [\n {\n "reference": "${uuid()}",\n "instruction": "question instructions",\n "points": 10,\n "is_auto_scored": true,\n "type": 5,\n "question_xml": "<assessmentItem \\r\\n xmlns=\\"http://www.imsglobal.org/xsd/imsqti_v2p2\\"\\r\\n xmlns:xsi=\\"http://www.w3.org/2001/XMLSchema-instance\\"\\r\\n xsi:schemaLocation=\\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\\"\\r\\n identifier=\\"choiceMultiple\\" \\r\\n title=\\"Welcome to Biodome\\" \\r\\n timeDependent=\\"false\\"\\r\\n>\\r\\n <responseDeclaration identifier=\\"RESPONSE\\" cardinality=\\"multiple\\" baseType=\\"identifier\\">\\r\\n <correctResponse>\\r\\n <value>ChoiceA</value>\\r\\n <value>ChoiceE</value>\\r\\n </correctResponse>\\r\\n <mapping>\\r\\n <mapEntry mapKey=\\"ChoiceA\\" mappedValue=\\"1\\"/>\\r\\n <mapEntry mapKey=\\"ChoiceE\\" mappedValue=\\"3\\"/>\\r\\n </mapping>\\r\\n </responseDeclaration>\\r\\n <outcomeDeclaration identifier=\\"SCORE\\" cardinality=\\"single\\" baseType=\\"float\\"/>\\r\\n <itemBody>\\r\\n <choiceInteraction responseIdentifier=\\"RESPONSE\\">\\r\\n <prompt> \\r\\n Zebras having stripes is a trait that might help them to survive. \\r\\n Which of the statements below are possible advantages of stripes. \\r\\n Select all that apply\\r\\n </prompt>\\r\\n <simpleChoice identifier=\\"ChoiceA\\" >Stripes help to confuse predators.</simpleChoice>\\r\\n <simpleChoice identifier=\\"ChoiceB\\" >Stripes help to attract predators.</simpleChoice>\\r\\n <simpleChoice identifier=\\"ChoiceC\\" >Stripes help human hunters to see zebras more easily.</simpleChoice>\\r\\n <simpleChoice identifier=\\"ChoiceD\\" >Stripes help zebras attract biting insects.</simpleChoice>\\r\\n <simpleChoice identifier=\\"ChoiceE\\" >Stripes help zebras to find mates to reproduce with.</simpleChoice>\\r\\n </choiceInteraction>\\r\\n </itemBody>\\r\\n <responseProcessing template=\\"http://www.imsglobal.org/question/qti_v2p2/rptemplates/map_response\\"/>\\r\\n</assessmentItem>\\r\\n",\n "scoring_type_id": 1,\n "teacher_guideline": "guidelines for this questions if any",\n "penalty_points": "0",\n "min_score_if_attempted": "0"\n },\n {\n "reference": "${uuid()}",\n "instruction": "question instructions",\n "points": 10,\n "is_auto_scored": true,\n "type": 5,\n "question_xml": "<assessmentItem \\r\\n xmlns=\\"http://www.imsglobal.org/xsd/imsqti_v2p2\\"\\r\\n xmlns:xsi=\\"http://www.w3.org/2001/XMLSchema-instance\\"\\r\\n xsi:schemaLocation=\\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\\"\\r\\n identifier=\\"choiceMultiple\\" \\r\\n title=\\"Welcome to Biodome\\" \\r\\n timeDependent=\\"false\\"\\r\\n>\\r\\n <responseDeclaration identifier=\\"RESPONSE\\" cardinality=\\"multiple\\" baseType=\\"identifier\\">\\r\\n <correctResponse>\\r\\n <value>ChoiceA</value>\\r\\n <value>ChoiceE</value>\\r\\n </correctResponse>\\r\\n <mapping>\\r\\n <mapEntry mapKey=\\"ChoiceA\\" mappedValue=\\"1\\"/>\\r\\n <mapEntry mapKey=\\"ChoiceE\\" mappedValue=\\"3\\"/>\\r\\n </mapping>\\r\\n </responseDeclaration>\\r\\n <outcomeDeclaration identifier=\\"SCORE\\" cardinality=\\"single\\" baseType=\\"float\\"/>\\r\\n <itemBody>\\r\\n <choiceInteraction responseIdentifier=\\"RESPONSE\\">\\r\\n <prompt> \\r\\n Zebras having stripes is a trait that might help them to survive. \\r\\n Which of the statements below are possible advantages of stripes. \\r\\n Select all that apply\\r\\n </prompt>\\r\\n <simpleChoice identifier=\\"ChoiceA\\" >Stripes help to confuse predators.</simpleChoice>\\r\\n <simpleChoice identifier=\\"ChoiceB\\" >Stripes help to attract predators.</simpleChoice>\\r\\n <simpleChoice identifier=\\"ChoiceC\\" >Stripes help human hunters to see zebras more easily.</simpleChoice>\\r\\n <simpleChoice identifier=\\"ChoiceD\\" >Stripes help zebras attract biting insects.</simpleChoice>\\r\\n <simpleChoice identifier=\\"ChoiceE\\" >Stripes help zebras to find mates to reproduce with.</simpleChoice>\\r\\n </choiceInteraction>\\r\\n </itemBody>\\r\\n <responseProcessing template=\\"http://www.imsglobal.org/question/qti_v2p2/rptemplates/map_response\\"/>\\r\\n</assessmentItem>\\r\\n",\n "scoring_type_id": 1,\n "teacher_guideline": "guidelines for this questions if any",\n "penalty_points": "0",\n "min_score_if_attempted": "0"\n }\n ]\n}\n`);
191
+ cy.get('.execute')
192
+ .click();
193
+ cy.wait(2000);
194
+ cy.get('.loading-container')
195
+ .should('not.exist');
196
+ cy.get('pre[class="microlight"]')
197
+ .eq(1)
198
+ .within(() => {
199
+ cy.contains('timestamp')
200
+ .next().next().then((currTimestamp) => {
201
+ timestamp = currTimestamp[0].innerText
202
+ });
203
+ });
204
+ });
205
+
206
+ it('Status:true message should be received in the response, with status code 200', () => {
207
+ cy.get('td[class="response-col_status"]')
208
+ .eq(0)
209
+ .should('have.text', '200');
210
+ cy.get('pre[class="microlight"]')
211
+ .eq(1)
212
+ .should('have.text', `{\n "meta": {\n "status": true,\n "timestamp": ${timestamp}\n },\n "data": []\n}\n`);
213
+ });
214
+ });