itemengine-cypress-automation 1.0.323-updateBumpVersion-82a2c50.0 → 1.0.324-updateBumpVersion-bbf003e.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.
- package/cypress/e2e/dataApi/fetchItems.js +204 -0
- package/cypress/e2e/dataApi/fetchQuestion.js +408 -0
- package/cypress/e2e/dataApi/saveItems.js +216 -0
- package/cypress/e2e/dataApi/saveQuestions.js +214 -0
- package/cypress/e2e/dataApi/saveQuestionsMCQAlternateAnswers.js +145 -0
- package/cypress/e2e/dataApi/saveResourcesAndTools.js +186 -0
- package/package.json +1 -1
@@ -0,0 +1,145 @@
|
|
1
|
+
import uuid from 'react-uuid';
|
2
|
+
|
3
|
+
describe('Save MCQ Question with Alternate Answers API cases', () => {
|
4
|
+
var timestamp;
|
5
|
+
before(() => {
|
6
|
+
cy.loginAs('admin');
|
7
|
+
cy.visit('/item-engine/data-api/item-bank/save-questions');
|
8
|
+
});
|
9
|
+
|
10
|
+
after(() => {
|
11
|
+
cy.logout();
|
12
|
+
});
|
13
|
+
|
14
|
+
it('If the user selects \'example-2-alternateAnswer\' option from the Examples dropdown then example request for MCQ Question should be displayed', () => {
|
15
|
+
cy.get('[class="examples-select-element"]')
|
16
|
+
.eq(0)
|
17
|
+
.select('example-2-alternateAnswer');
|
18
|
+
|
19
|
+
cy.get('[class="body-param__example microlight"]')
|
20
|
+
.eq(0)
|
21
|
+
.should('have.text', "{\n \"questions\": [\n {\n \"reference\": \"1ed861b-7dd3-1a1-0abc-7158cf8d4a7-dataAPiTest\",\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 \"validation\": {\n \"alt_responses\": [\n [\n {\n \"score\": 1,\n \"value\": \"ChoiceA\"\n },\n {\n \"score\": 3,\n \"value\": \"ChoiceE\"\n }\n ],\n [\n {\n \"score\": 2,\n \"value\": \"ChoiceB\"\n },\n {\n \"score\": 2,\n \"value\": \"ChoiceD\"\n }\n ]\n ]\n }\n },\n {\n \"reference\": \"1ed861b-7dd3-1a1-0abc-7158cf8d4a7-dataAPiTest\",\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 </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 \"validation\": {\n \"alt_responses\": [\n {\n \"score\": 4,\n \"values\": [\n \"ChoiceA\",\n \"ChoiceE\"\n ]\n },\n {\n \"score\": 4,\n \"values\": [\n \"ChoiceB\",\n \"ChoiceD\"\n ]\n }\n ]\n }\n }\n ]\n}\n")
|
22
|
+
});
|
23
|
+
|
24
|
+
it('Entering request without the reference property', () => {
|
25
|
+
cy.get('.try-out__btn')
|
26
|
+
.click();
|
27
|
+
cy.get('textarea[class="body-param__text"]')
|
28
|
+
.clear()
|
29
|
+
.fill(`{\n "questions": [\n {\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 "validation": {\n "alt_responses": [\n [\n {\n "score": 1,\n "value": "ChoiceA"\n },\n {\n "score": 3,\n "value": "ChoiceE"\n }\n ],\n [\n {\n "score": 2,\n "value": "ChoiceB"\n },\n {\n "score": 2,\n "value": "ChoiceD"\n }\n ]\n ]\n }\n }\n ]\n}`);
|
30
|
+
cy.get('.execute')
|
31
|
+
.click();
|
32
|
+
cy.wait(2000);
|
33
|
+
cy.get('.loading-container')
|
34
|
+
.should('not.exist');
|
35
|
+
});
|
36
|
+
|
37
|
+
it('Reference property is required message should be received in the response, with status code 422', () => {
|
38
|
+
cy.get('td[class="response-col_status"]')
|
39
|
+
.eq(0)
|
40
|
+
.should('have.text', '200');
|
41
|
+
cy.get('pre[class="microlight"]')
|
42
|
+
.eq(1)
|
43
|
+
.find('span')
|
44
|
+
.eq(7)
|
45
|
+
.should('have.text', "\"\\\"questions[0].reference\\\" is required\"");
|
46
|
+
});
|
47
|
+
|
48
|
+
it('Entering request with incorrect question_XML', () => {
|
49
|
+
cy.get('textarea[class="body-param__text"]')
|
50
|
+
.clear()
|
51
|
+
.fill(`{\n "questions": [\n {\n "reference": "1ed861b-7dd3-1a1-0abc-7158cf8d4a7-dataAPiTest",\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 "validation": {\n "alt_responses": [\n [\n {\n "score": 1,\n "value": "ChoiceA"\n },\n {\n "score": 3,\n "value": "ChoiceE"\n }\n ],\n [\n {\n "score": 2,\n "value": "ChoiceB"\n },\n {\n "score": 2,\n "value": "ChoiceD"\n }\n ]\n ]\n }\n }\n ]\n}`);
|
52
|
+
cy.get('.execute')
|
53
|
+
.click();
|
54
|
+
cy.wait(2000);
|
55
|
+
cy.get('.loading-container')
|
56
|
+
.should('not.exist');
|
57
|
+
cy.get('pre[class="microlight"]')
|
58
|
+
.eq(1)
|
59
|
+
.within(() => {
|
60
|
+
cy.contains('timestamp')
|
61
|
+
.next().next().then((currTimestamp) => {
|
62
|
+
timestamp = currTimestamp[0].innerText
|
63
|
+
});
|
64
|
+
});
|
65
|
+
});
|
66
|
+
|
67
|
+
it('\'Error occurred while saving data\' message should be received in the response, with status code 500', () => {
|
68
|
+
cy.get('td[class="response-col_status"]')
|
69
|
+
.eq(0)
|
70
|
+
.should('have.text', '200');
|
71
|
+
cy.get('pre[class="microlight"]')
|
72
|
+
.eq(1)
|
73
|
+
.should('have.text', `{\n \"meta\": {\n \"message\": \"Error occurred while saving data\",\n \"timestamp\": ${timestamp},\n \"status\": false\n },\n \"data\": []\n}\n`);
|
74
|
+
});
|
75
|
+
|
76
|
+
it('Entering request with empty question_XML', () => {
|
77
|
+
cy.get('textarea[class="body-param__text"]')
|
78
|
+
.clear()
|
79
|
+
.fill(`{\n "questions": [\n {\n "reference": "1ed861b-7dd3-1a1-0abc-7158cf8d4a7-dataAPiTest",\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 "validation": {\n "alt_responses": [\n [\n {\n "score": 1,\n "value": "ChoiceA"\n },\n {\n "score": 3,\n "value": "ChoiceE"\n }\n ],\n [\n {\n "score": 2,\n "value": "ChoiceB"\n },\n {\n "score": 2,\n "value": "ChoiceD"\n }\n ]\n ]\n }\n }\n ]\n}`);
|
80
|
+
cy.get('.execute')
|
81
|
+
.click();
|
82
|
+
cy.wait(2000);
|
83
|
+
cy.get('.loading-container')
|
84
|
+
.should('not.exist');
|
85
|
+
});
|
86
|
+
|
87
|
+
it('XML is not allowed to be empty message should be received in the response, with status code 422', () => {
|
88
|
+
cy.get('td[class="response-col_status"]')
|
89
|
+
.eq(0)
|
90
|
+
.should('have.text', '200');
|
91
|
+
cy.get('pre[class="microlight"]')
|
92
|
+
.eq(1)
|
93
|
+
.find('span')
|
94
|
+
.eq(7)
|
95
|
+
.should('have.text', "\"\\\"questions[0].questionXml\\\" is not allowed to be empty\"");
|
96
|
+
});
|
97
|
+
|
98
|
+
it('Entering request with already existing question reference', () => {
|
99
|
+
cy.get('textarea[class="body-param__text"]')
|
100
|
+
.clear()
|
101
|
+
.fill('{\n "questions": [\n {\n "reference": "1ed861b-7dd3-1a1-0abc-7158cf8d4a7-dataAPiTest",\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 "validation": {\n "alt_responses": [\n [\n {\n "score": 1,\n "value": "ChoiceA"\n },\n {\n "score": 3,\n "value": "ChoiceE"\n }\n ],\n [\n {\n "score": 2,\n "value": "ChoiceB"\n },\n {\n "score": 2,\n "value": "ChoiceD"\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
|
+
it('Reference id already exists message should be received in the response, with status code 422', () => {
|
110
|
+
cy.get('pre[class="microlight"]')
|
111
|
+
.eq(1)
|
112
|
+
.find('span')
|
113
|
+
.eq(7)
|
114
|
+
.should('have.text', "\"Key (reference_id, organisation_id)=(1ed861b-7dd3-1a1-0abc-7158cf8d4a7-dataAPiTest, 7e15466c-30cb-4fdf-b160-6e6fc3660d0e) already exists.\"");
|
115
|
+
});
|
116
|
+
|
117
|
+
it('Entering request to create 2 questions with valid reference ids', () => {
|
118
|
+
cy.get('textarea[class="body-param__text"]')
|
119
|
+
.clear()
|
120
|
+
.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 "validation": {\n "alt_responses": [\n [\n {\n "score": 1,\n "value": "ChoiceA"\n },\n {\n "score": 3,\n "value": "ChoiceE"\n }\n ],\n [\n {\n "score": 2,\n "value": "ChoiceB"\n },\n {\n "score": 2,\n "value": "ChoiceD"\n }\n ]\n ]\n }\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 </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 "validation": {\n "alt_responses": [\n {\n "score": 4,\n "values": [\n "ChoiceA",\n "ChoiceE"\n ]\n },\n {\n "score": 4,\n "values": [\n "ChoiceB",\n "ChoiceD"\n ]\n }\n ]\n }\n }\n ]\n}`);
|
121
|
+
cy.get('.execute')
|
122
|
+
.click();
|
123
|
+
cy.wait(2000);
|
124
|
+
cy.get('.loading-container')
|
125
|
+
.should('not.exist');
|
126
|
+
//Getting the timestamp
|
127
|
+
cy.get('pre[class="microlight"]')
|
128
|
+
.eq(1)
|
129
|
+
.within(() => {
|
130
|
+
cy.contains('timestamp')
|
131
|
+
.next().next().then((currTimestamp) => {
|
132
|
+
timestamp = currTimestamp[0].innerText
|
133
|
+
});
|
134
|
+
});
|
135
|
+
});
|
136
|
+
|
137
|
+
it('Status:true message should be received in the response, with status code 200', () => {
|
138
|
+
cy.get('td[class="response-col_status"]')
|
139
|
+
.eq(0)
|
140
|
+
.should('have.text', '200');
|
141
|
+
cy.get('pre[class="microlight"]')
|
142
|
+
.eq(1)
|
143
|
+
.should('have.text', `{\n "meta": {\n "status": true,\n "timestamp": ${timestamp}\n },\n "data": []\n}\n`);
|
144
|
+
});
|
145
|
+
});
|
@@ -0,0 +1,186 @@
|
|
1
|
+
import uuid from 'react-uuid';
|
2
|
+
|
3
|
+
describe('Set Resource and tool 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 Resources and Tools option from the menu bar, user should be navigated to the Save Resources and Tools page', () => {
|
15
|
+
cy.contains('Item Bank')
|
16
|
+
.click();
|
17
|
+
cy.contains('Save Resources and Tools')
|
18
|
+
.click();
|
19
|
+
cy.contains('Save Resources and Tools')
|
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-resources');
|
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 "resources": [\n {\n "type": 1,\n "data": {\n "type": "Passage",\n "heading": "This is passage heading",\n "content": "This is content of the passage",\n "instructor_stimulus": "",\n "lexile": "",\n "flesch_kincaid": ""\n },\n "reference": "myPassageRef01"\n },\n {\n "type": 1,\n "data": {\n "type": "Passage",\n "heading": "This is passage heading",\n "content": [\n "content_page_1",\n "content_page_2"\n ],\n "instructor_stimulus": "",\n "lexile": "",\n "flesch_kincaid": ""\n },\n "reference": "myPassageRef02"\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`);
|
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\": 1651829657792\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');
|
73
|
+
cy.get('pre[class="example microlight"]')
|
74
|
+
.eq(2)
|
75
|
+
.should('have.text', "{\n \"meta\": {\n \"status\": false,\n \"message\": \"Invalid Request\",\n \"timestamp\": 1705577441132\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\": \"Key (reference_id)=(myPassageRef01) already exists.\",\n \"timestamp\": 1705577441132\n },\n \"data\": []\n}\n");
|
88
|
+
});
|
89
|
+
|
90
|
+
it('Entering request without the type property', () => {
|
91
|
+
cy.get('.try-out__btn')
|
92
|
+
.click();
|
93
|
+
cy.get('textarea[class="body-param__text"]')
|
94
|
+
.clear()
|
95
|
+
.fill(`{\n "resources": [\n {\n "type": 1,\n "data": {\n "heading": "This is passage heading",\n "content": "This is content of the passage"\n },\n "reference": "myPassageRef01"\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('Type 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',"\"\\\"resources[0].data.type\\\" is required\"");
|
112
|
+
});
|
113
|
+
|
114
|
+
it('Entering request with empty resource reference id', () => {
|
115
|
+
cy.get('textarea[class="body-param__text"]')
|
116
|
+
.clear()
|
117
|
+
.fill(`{\n "resources": [\n {\n "type": 1,\n "data": {\n "type": "Passage",\n "heading": "This is passage heading",\n "content": "This is content of the passage"\n },\n "reference": ""\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}`);
|
118
|
+
cy.get('.execute')
|
119
|
+
.click();
|
120
|
+
cy.wait(2000);
|
121
|
+
cy.get('.loading-container')
|
122
|
+
.should('not.exist');
|
123
|
+
});
|
124
|
+
|
125
|
+
it('Reference is not allowed to be empty message should be received in the response, with status code 422', () => {
|
126
|
+
cy.get('td[class="response-col_status"]')
|
127
|
+
.eq(0)
|
128
|
+
.should('have.text', '200');
|
129
|
+
cy.get('pre[class="microlight"]')
|
130
|
+
.eq(1)
|
131
|
+
.find('span')
|
132
|
+
.eq(7)
|
133
|
+
.should('have.text',"\"\\\"resources[0].reference\\\" is not allowed to be empty\"");
|
134
|
+
});
|
135
|
+
|
136
|
+
it('Entering request with an already existing resource reference', () => {
|
137
|
+
cy.get('textarea[class="body-param__text"]')
|
138
|
+
.clear()
|
139
|
+
.fill(`{\n "resources": [\n {\n "type": 1,\n "data": {\n "type": "Passage",\n "heading": "This is passage heading",\n "content": "This is content of the passage"\n },\n "reference": "myPassageRef01"\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}`);
|
140
|
+
cy.get('.execute')
|
141
|
+
.click();
|
142
|
+
cy.wait(2000);
|
143
|
+
cy.get('.loading-container')
|
144
|
+
.should('not.exist');
|
145
|
+
});
|
146
|
+
|
147
|
+
it('Reference id already exists message should be received in the response, with status code 500', () => {
|
148
|
+
cy.get('td[class="response-col_status"]')
|
149
|
+
.eq(0)
|
150
|
+
.should('have.text', '200');
|
151
|
+
cy.get('pre[class="microlight"]')
|
152
|
+
.eq(1)
|
153
|
+
.find('span')
|
154
|
+
.eq(7)
|
155
|
+
.should('have.text',"\"Key (reference_id, organisation_id)=(myPassageRef01, 7e15466c-30cb-4fdf-b160-6e6fc3660d0e) already exists.\"");
|
156
|
+
});
|
157
|
+
|
158
|
+
it('Entering request to create multiple resources with valid reference id', () => {
|
159
|
+
cy.get('textarea[class="body-param__text"]')
|
160
|
+
.clear()
|
161
|
+
.fill(`{\n "resources": [\n {\n "type": 1,\n "data": {\n "type": "Passage",\n "heading": "This is passage heading",\n "content": "This is content of the passage"\n },\n "reference": "${uuid()}"\n },\n {\n "type": 1,\n "data": {\n "type": "Passage",\n "heading": "This is passage heading",\n "content": "This is content of the passage"\n },\n "reference": "${uuid()}"\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}`);
|
162
|
+
cy.get('.execute')
|
163
|
+
.click();
|
164
|
+
cy.wait(2000);
|
165
|
+
cy.get('.loading-container')
|
166
|
+
.should('not.exist');
|
167
|
+
//Getting the timestamp
|
168
|
+
cy.get('pre[class="microlight"]')
|
169
|
+
.eq(1)
|
170
|
+
.within(() => {
|
171
|
+
cy.contains('timestamp')
|
172
|
+
.next().next().then((currTimestamp) => {
|
173
|
+
timestamp = currTimestamp[0].innerText
|
174
|
+
});
|
175
|
+
});
|
176
|
+
});
|
177
|
+
|
178
|
+
it('Status:true message should be received in the response', () => {
|
179
|
+
cy.get('td[class="response-col_status"]')
|
180
|
+
.eq(0)
|
181
|
+
.should('have.text', '200');
|
182
|
+
cy.get('pre[class="microlight"]')
|
183
|
+
.eq(1)
|
184
|
+
.should('have.text', `{\n "meta": {\n "status": true,\n "timestamp": ${timestamp}\n },\n "data": []\n}\n`);
|
185
|
+
});
|
186
|
+
});
|