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,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": "Key (reference_id, organisation_id)=(1ed861b-7dd3-1a1-0abc-7158cf8d4a7-dataAPiTest, 7e15466c-30cb-4fdf-b160-6e6fc3660d0e) already exists.",\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
+ });
@@ -9,6 +9,7 @@ const selectors = {
9
9
  searchInputField: () => cy.get('.ngie-search input'),
10
10
  sortArrow: () => cy.get('.table-header-sort-arrow'),
11
11
  browseItemsLabel: () => cy.get('.browse-title-wrapper'),
12
+ browseItemsItem: () => cy.get('tr[id*="MUIDataTableBodyRow"]'),
12
13
  browseItemPageReferenceId: () => cy.get('[class*="ItemTitleCellstyles__ReferenceId"]'),
13
14
  }
14
15
 
@@ -51,6 +52,16 @@ const steps = {
51
52
  .type(`${value}{enter}`);
52
53
  },
53
54
 
55
+ /**
56
+ * This function navigates to the question using the referenceId
57
+ * @param {string} referenceId The referenceId of the item that needs to be navigated to
58
+ */
59
+ navigateToQuestionUsingReferenceId: (referenceId) => {
60
+ browseItemsPage.browseItemsItem()
61
+ .contains(referenceId)
62
+ .click();
63
+ },
64
+
54
65
  /**
55
66
  * This function verifies the warning icon in browse item save as you go
56
67
  * @param {string} referenceID reference id of the saved question
@@ -31,6 +31,7 @@ const selectors = {
31
31
  sectionsNumber1Label: () => cy.get('.tablist-numbered-label').eq(0),
32
32
  sectionsNumber2Label: () => cy.get('.tablist-numbered-label').eq(1),
33
33
  noPreviewText: () => cy.get('[class*="__NoPreview"]'),
34
+ buttonEditItemTitle: () => cy.get('[data-at="edit-button"]'),
34
35
  editItemButton: () => cy.get('.column-component-column .icon-pencil'),
35
36
  pointsValue: () => cy.get('[class*="PreviewTabstyles__PointsValue"]'),
36
37
  moreActionsButton: () => cy.get('[class*="MoreActionMenuButton"] [type="button"]'),
@@ -148,6 +149,8 @@ const steps = {
148
149
  enterTitle: (value) => {
149
150
  createItemPage.titleInputField()
150
151
  .type(value);
152
+ createItemPage.titleInputField()
153
+ .blur();
151
154
  },
152
155
 
153
156
  clickOnSubmitButton: () => {
@@ -583,6 +586,10 @@ const steps = {
583
586
  });
584
587
  },
585
588
 
589
+ editItemTitle: () => {
590
+ createItemPage.buttonEditItemTitle()
591
+ },
592
+
586
593
  /**
587
594
  * @param {number} index of the question
588
595
  * @description this function is used to click on edit item button
@@ -50,4 +50,5 @@ export * from './chartsLinePage';
50
50
  export * from './numberLineLabelPage';
51
51
  export * from './chartsDotPlotPage';
52
52
  export * from './imageHighlightPage';
53
- export * from './compassPage';
53
+ export * from './compassPage';
54
+ export * from './menuBarPage';
@@ -0,0 +1,66 @@
1
+ import { browseItemsPage, createQuestionBasePage } from "./components";
2
+ import { createItemPage } from "./createItemPage";
3
+
4
+ const selectors = {
5
+ ...browseItemsPage,
6
+ ...createItemPage,
7
+ itemBankDataApiAccordion: () => cy.get('[role="button"]').contains('Item Bank'),
8
+ fetchItemsButton: () => cy.get('[role="button"]').contains('Fetch Items'),
9
+ browseItemsButton: () => cy.get('[role="button"]').contains('Browse Items'),
10
+ exampleRequestBody: () => cy.get('pre[class="body-param__example microlight"]'),
11
+ exampleResponseValue: () => cy.get('pre[class="example microlight"]'),
12
+ exampleResponseBody: () => cy.get('pre[class="microlight"]'),
13
+ responseStatus: () => cy.get('[class="response-col_status"]'),
14
+ responseDescription: () => cy.get('.response-col_description__inner'),
15
+ buttonTryItOut: () => cy.get('[class="btn try-out__btn"]'),
16
+ responseTextArea: () => cy.get('textarea[class="body-param__text"]'),
17
+ buttonExecute: () => cy.get('.execute'),
18
+ requestLoader: () => cy.get('.loading-container')
19
+ }
20
+
21
+ const steps = {
22
+ ...browseItemsPage.steps,
23
+ ...createItemPage.steps,
24
+ ...createQuestionBasePage.steps,
25
+ expandItemBankDataApiAccordion: () => {
26
+ menuBarPage.itemBankDataApiAccordion()
27
+ .click()
28
+ .parents('[role="button"]')
29
+ .should('have.attr', 'aria-expanded', 'true');
30
+ },
31
+
32
+ clickFetchItemsButton: () => {
33
+ menuBarPage.fetchItemsButton()
34
+ .click()
35
+ .parents('[role="button"]')
36
+ .should('have.class', 'Mui-selected');
37
+ cy.url()
38
+ .should('eq', Cypress.config().baseUrl + '/item-engine/data-api/item-bank/fetch-items');
39
+ },
40
+
41
+ tryItOut: () => {
42
+ menuBarPage.buttonTryItOut()
43
+ .click();
44
+ },
45
+
46
+ enterTextInSampleRequestBody: (text) => {
47
+ menuBarPage.responseTextArea()
48
+ .clear()
49
+ .fill(text);
50
+ },
51
+
52
+ execute: () => {
53
+ menuBarPage.buttonExecute()
54
+ .click();
55
+ },
56
+
57
+ navigateToBrowseItems: () => {
58
+ menuBarPage.browseItemsButton()
59
+ .click()
60
+ }
61
+ }
62
+
63
+ export const menuBarPage = {
64
+ ...selectors,
65
+ steps
66
+ }
@@ -186,4 +186,42 @@ Cypress.Commands.add('startApplitools', () => {
186
186
  testName: Cypress.currentTest.title,
187
187
  isDisabled: applitoolsConfig.APPLITOOLS_IS_DISABLED
188
188
  });
189
+ });
190
+
191
+ export function getShortDate(previous, dayFormat = 'oneDigitFormat') {
192
+
193
+ var date = new Date();
194
+ date.setDate(date.getDate() - previous);
195
+ var month = date.toLocaleString("en-us", { month: "short" });
196
+ var day = date.getDate();
197
+ var year = date.getFullYear();
198
+ var dateObject = {};
199
+ dateObject["shortMonth"] = month
200
+ dateObject["longMonth"] = date.toLocaleString("en-us", { month: "long" });
201
+ dateObject["year"] = year
202
+ if (dayFormat == 'oneDigitFormat') {
203
+ dateObject["completeShortDate"] = (month + ' ' + day + ', ' + year)
204
+ dateObject["day"] = day
205
+ } else if (dayFormat == 'twoDigitFormat') {
206
+ day = ('0' + day).slice(-2);
207
+ dateObject["completeShortDate"] = (month + ' ' + day + ', ' + year)
208
+ dateObject["day"] = day
209
+ }
210
+ return dateObject
211
+ }
212
+
213
+ Cypress.Commands.add('lazyLoadingWait', (count, retries) => {
214
+ cy.get('[data-testid="question-instruction-element"]')
215
+ .then((elem) => {
216
+ if (retries <= 0) {
217
+ throw new Error('Element did not load in time')
218
+ };
219
+ if (elem.length < count) {
220
+ cy.get('[data-testid="question-instruction-element"]')
221
+ .last()
222
+ .scrollIntoView()
223
+ .wait(1000);
224
+ cy.lazyLoadingWait(count, retries - 1)
225
+ };
226
+ });
189
227
  });