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.
@@ -0,0 +1,204 @@
1
+ import { createdAndUpdatedAtDate, questionAndResourceReferenceIds } from '../../support/helpers/createItem';
2
+ import { menuBarPage } from '../../pages/menuBarPage';
3
+ import utilities from "../../support/helpers/utilities";
4
+
5
+ //4fd8b6-e5c8-aa62-fab-5e0b6bbc4e1c - staging
6
+ describe('Get Item Data API cases', () => {
7
+ var timestamp;
8
+ var dt_updated;
9
+ before(() => {
10
+ cy.loginAs('admin');
11
+ cy.createItem('dataAPIFetchItem123');
12
+ cy.wait(5000);
13
+ cy.createItem('dataAPIFetchItem234');
14
+ cy.visit(`${Cypress.env('itemEngineHomePage')}`);
15
+ });
16
+
17
+ after(() => {
18
+ cy.deleteItem('dataAPIFetchItem123')
19
+ cy.deleteItems();
20
+ cy.logout();
21
+ });
22
+
23
+ it('When the user clicks on the Fetch Items option from the menu bar, user should be navigated to the Fetch Items page', () => {
24
+ menuBarPage.steps.expandItemBankDataApiAccordion();
25
+ menuBarPage.steps.clickFetchItemsButton();
26
+ });
27
+
28
+ it('Example Request should be displayed', () => {
29
+ utilities.verifyTextContent(menuBarPage.exampleRequestBody(), `{\n "references": [],\n "created_by": [],\n "questions": {\n "references": [],\n "types": []\n },\n "resources": {\n "references": [],\n "types": []\n },\n "metadata": [],\n "limit": 50,\n "sort_field": "created",\n "sort": "desc",\n "status": [],\n "organisation_id": "${Cypress.env('organisation_id')}",\n "next_token": [\n 1762144158723,\n "590a9b83-0e44-4c6f-bc4a-503e636b8580"\n ]\n}\n`)
30
+ //Getting the timestamp
31
+ utilities.getNthElement(menuBarPage.exampleResponseValue(), 0)
32
+ .within(() => {
33
+ cy.contains('timestamp')
34
+ .next().next().then((currTimestamp) => {
35
+ timestamp = currTimestamp[0].innerText
36
+ });
37
+ });
38
+ });
39
+
40
+ it('Example Response for status code 200 should be displayed', () => {
41
+ utilities.verifyInnerText(utilities.getNthElement(menuBarPage.exampleResponseValue(), 0), `{\n "meta": {\n "status": true,\n "records": 1,\n "timestamp": ${timestamp},\n "next_token": [\n 1762144158723,\n "590a9b83-0e44-4c6f-bc4a-503e636b8580"\n ]\n },\n "data": [\n {\n "title": "",\n "description": null,\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 "reference": "590a9b83-0e44-4c6f-bc4a-503e636b8580",\n "dt_created": "2022-04-18T11:03:12.000Z",\n "dt_updated": "2022-04-18T11:03:12.000Z",\n "status": "published",\n "item_scoring_type": "sum up all individual scores",\n "questions": [\n {\n "reference": "1ea4862b-488f-4a49-b48b-c7388fd9d610",\n "type": "drag and drop"\n },\n {\n "reference": "52ebb239-98ee-44f6-890e-c7c6576bc6bf",\n "type": "drag and drop"\n }\n ],\n "resources": [\n {\n "reference": "89b478be-cacb-4071-bd99-de552a407c03",\n "type": "passage"\n },\n {\n "reference": "6e84b590-e2ef-42ff-b59c-973361ea4ecc",\n "type": "passage"\n }\n ]\n }\n ]\n}\n`);
42
+ });
43
+
44
+ it('Example Response for status code 500 should be displayed', () => {
45
+ utilities.verifyInnerText(utilities.getNthElement(menuBarPage.responseStatus(), 3), '500')
46
+ utilities.verifyInnerText(utilities.getNthElement(menuBarPage.responseDescription(), 3), 'Internal Server Error')
47
+ utilities.verifyTextContent(utilities.getNthElement(menuBarPage.exampleResponseValue(), 3), '{\n "meta": {\n "status": false,\n "message": "Error occurred while fetching data",\n "timestamp": 1653650826764\n },\n "data": []\n}\n');
48
+ });
49
+
50
+ it('Entering request with a non existing item reference id', () => {
51
+ menuBarPage.steps.tryItOut();
52
+ menuBarPage.steps.enterTextInSampleRequestBody(`{\n "references": ["non existing item reference"],\n "created_by": [],\n "questions": {\n "references": [],\n "types": []\n },\n "resources": {\n "references": [],\n "types": []\n },\n "tags": [],\n "limit": 50,\n "page": 0,\n "sort_field": "created",\n "sort": "desc",\n "status": []\n}`);
53
+ menuBarPage.steps.execute();
54
+ cy.wait(2000);
55
+ utilities.verifyElementVisibilityState(menuBarPage.requestLoader(), 'notExist');
56
+ utilities.getNthElement(menuBarPage.exampleResponseBody(), 1)
57
+ .within(() => {
58
+ cy.contains('timestamp')
59
+ .next().next().then((currTimestamp) => {
60
+ timestamp = currTimestamp[0].innerText
61
+ });
62
+ });
63
+ });
64
+
65
+ it('A blank data array should be recieved in the response with status code 200', () => {
66
+ utilities.verifyInnerText(utilities.getNthElement(menuBarPage.responseStatus(), 0), '200')
67
+ utilities.verifyTextContent(utilities.getNthElement(menuBarPage.exampleResponseBody(), 1), `{\n "meta": {\n "status": true,\n "records": 0,\n "timestamp": ${timestamp},\n "next_token": null\n },\n "data": []\n}\n`);
68
+ });
69
+
70
+ it('Entering request to get single item data', () => {
71
+ menuBarPage.steps.enterTextInSampleRequestBody(`{\n "references": ["dataAPIFetchItem123"],\n "created_by": [],\n "questions": {\n "references": [],\n "types": []\n },\n "resources": {\n "references": [],\n "types": []\n },\n "tags": [],\n "limit": 50,\n "page": 0,\n "sort_field": "created",\n "sort": "desc",\n "status": []\n}`);
72
+ menuBarPage.steps.execute();
73
+ cy.wait(2000);
74
+ utilities.verifyElementVisibilityState(menuBarPage.requestLoader(), 'notExist');
75
+ utilities.getNthElement(menuBarPage.exampleResponseBody(), 1)
76
+ .within(() => {
77
+ cy.contains('timestamp')
78
+ .next().next().then((currTimestamp) => {
79
+ timestamp = currTimestamp[0].innerText
80
+ });
81
+ });
82
+ });
83
+
84
+ it('The item with the entered item reference should be returned in the response with status code 200', () => {
85
+ utilities.verifyTextContent(utilities.getNthElement(menuBarPage.exampleResponseValue(), 0), `{\n "meta": {\n "status": true,\n "records": 1,\n "timestamp": 1652114106011,\n "next_token": [\n 1762144158723,\n "590a9b83-0e44-4c6f-bc4a-503e636b8580"\n ]\n },\n "data": [\n {\n "title": "",\n "description": null,\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 "reference": "590a9b83-0e44-4c6f-bc4a-503e636b8580",\n "dt_created": "2022-04-18T11:03:12.000Z",\n "dt_updated": "2022-04-18T11:03:12.000Z",\n "status": "published",\n "item_scoring_type": "sum up all individual scores",\n "questions": [\n {\n "reference": "1ea4862b-488f-4a49-b48b-c7388fd9d610",\n "type": "drag and drop"\n },\n {\n "reference": "52ebb239-98ee-44f6-890e-c7c6576bc6bf",\n "type": "drag and drop"\n }\n ],\n "resources": [\n {\n "reference": "89b478be-cacb-4071-bd99-de552a407c03",\n "type": "passage"\n },\n {\n "reference": "6e84b590-e2ef-42ff-b59c-973361ea4ecc",\n "type": "passage"\n }\n ]\n }\n ]\n}\n`);
86
+ });
87
+
88
+ it('Entering request to get multiple items data', () => {
89
+ menuBarPage.steps.enterTextInSampleRequestBody(`{\n "references": ["dataAPIFetchItem123", "dataAPIFetchItem234"],\n "created_by": [],\n "questions": {\n "references": [],\n "types": []\n },\n "resources": {\n "references": [],\n "types": []\n },\n "tags": [],\n "limit": 50,\n "page": 0,\n "sort_field": "created",\n "sort": "desc",\n "status": []\n}`);
90
+ menuBarPage.steps.execute();
91
+ cy.wait(2000);
92
+ utilities.verifyElementVisibilityState(menuBarPage.requestLoader(), 'notExist');
93
+ //Getting the timestamp
94
+ utilities.getNthElement(menuBarPage.exampleResponseBody(), 1)
95
+ .within(() => {
96
+ cy.contains('timestamp')
97
+ .next().next().then((currTimestamp) => {
98
+ timestamp = currTimestamp[0].innerText
99
+ });
100
+ });
101
+ });
102
+
103
+ it('All the items of the entered item references should be returned in the response with status code 200', () => {
104
+ utilities.verifyTextContent(utilities.getNthElement(menuBarPage.exampleResponseValue(), 0), `{\n "meta": {\n "status": true,\n "records": 1,\n "timestamp": 1652114106011,\n "next_token": [\n 1762144158723,\n "590a9b83-0e44-4c6f-bc4a-503e636b8580"\n ]\n },\n "data": [\n {\n "title": "",\n "description": null,\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 "reference": "590a9b83-0e44-4c6f-bc4a-503e636b8580",\n "dt_created": "2022-04-18T11:03:12.000Z",\n "dt_updated": "2022-04-18T11:03:12.000Z",\n "status": "published",\n "item_scoring_type": "sum up all individual scores",\n "questions": [\n {\n "reference": "1ea4862b-488f-4a49-b48b-c7388fd9d610",\n "type": "drag and drop"\n },\n {\n "reference": "52ebb239-98ee-44f6-890e-c7c6576bc6bf",\n "type": "drag and drop"\n }\n ],\n "resources": [\n {\n "reference": "89b478be-cacb-4071-bd99-de552a407c03",\n "type": "passage"\n },\n {\n "reference": "6e84b590-e2ef-42ff-b59c-973361ea4ecc",\n "type": "passage"\n }\n ]\n }\n ]\n}\n`);
105
+ });
106
+
107
+ it('Entering request to get multiple items data, filtered by question type filter', () => {
108
+ menuBarPage.steps.enterTextInSampleRequestBody(`{\n "references": ["dataAPIFetchItem123", "dataAPIFetchItem234"],\n "created_by": [],\n "questions": {\n "references": [],\n "types": ["Multiple Selection"]\n },\n "resources": {\n "references": [],\n "types": []\n },\n "tags": [],\n "limit": 50,\n "page": 0,\n "sort_field": "created",\n "sort": "desc",\n "status": []\n}`);
109
+ menuBarPage.steps.execute();
110
+ cy.wait(2000);
111
+ utilities.verifyElementVisibilityState(menuBarPage.requestLoader(), 'notExist');
112
+ //Getting the timestamp
113
+ utilities.getNthElement(menuBarPage.exampleResponseBody(), 1)
114
+ .within(() => {
115
+ cy.contains('timestamp')
116
+ .next().next().then((currTimestamp) => {
117
+ timestamp = currTimestamp[0].innerText
118
+ });
119
+ });
120
+ });
121
+
122
+ it('All the items of the entered item references containing the entered question type should be returned in the response with status code 200', () => {
123
+ utilities.verifyTextContent(utilities.getNthElement(menuBarPage.exampleResponseValue(), 0), `{\n "meta": {\n "status": true,\n "records": 1,\n "timestamp": 1652114106011,\n "next_token": [\n 1762144158723,\n "590a9b83-0e44-4c6f-bc4a-503e636b8580"\n ]\n },\n "data": [\n {\n "title": "",\n "description": null,\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 "reference": "590a9b83-0e44-4c6f-bc4a-503e636b8580",\n "dt_created": "2022-04-18T11:03:12.000Z",\n "dt_updated": "2022-04-18T11:03:12.000Z",\n "status": "published",\n "item_scoring_type": "sum up all individual scores",\n "questions": [\n {\n "reference": "1ea4862b-488f-4a49-b48b-c7388fd9d610",\n "type": "drag and drop"\n },\n {\n "reference": "52ebb239-98ee-44f6-890e-c7c6576bc6bf",\n "type": "drag and drop"\n }\n ],\n "resources": [\n {\n "reference": "89b478be-cacb-4071-bd99-de552a407c03",\n "type": "passage"\n },\n {\n "reference": "6e84b590-e2ef-42ff-b59c-973361ea4ecc",\n "type": "passage"\n }\n ]\n }\n ]\n}\n`);
124
+ });
125
+
126
+
127
+ it('Entering request to get multiple items data, filtered by status', () => {
128
+ menuBarPage.steps.enterTextInSampleRequestBody(`{\n "references": ["dataAPIFetchItem123", "dataAPIFetchItem234"],\n "created_by": [],\n "questions": {\n "references": [],\n "types": []\n },\n "resources": {\n "references": [],\n "types": []\n },\n "tags": [],\n "limit": 50,\n "page": 0,\n "sort_field": "created",\n "sort": "desc",\n "status": ["locked"]\n}`);
129
+ menuBarPage.steps.execute();
130
+ cy.wait(2000);
131
+ utilities.verifyElementVisibilityState(menuBarPage.requestLoader(), 'notExist');
132
+ //Getting the timestamp
133
+ utilities.getNthElement(menuBarPage.exampleResponseBody(), 1)
134
+ .within(() => {
135
+ cy.contains('timestamp')
136
+ .next().next().then((currTimestamp) => {
137
+ timestamp = currTimestamp[0].innerText
138
+ });
139
+ });
140
+ });
141
+
142
+
143
+ it('A blank data array should be recieved in the response with status code 200 as the items are in published state', () => {
144
+ utilities.verifyTextContent(utilities.getNthElement(menuBarPage.exampleResponseBody(), 1), `{\n "meta": {\n "status": true,\n "records": 0,\n "timestamp": ${timestamp},\n "next_token": null\n },\n "data": []\n}\n`);
145
+ });
146
+
147
+ it('Entering request to get multiple items data, filtered by question type, resource type & tags and sorted by created field ascending', () => {
148
+ menuBarPage.steps.enterTextInSampleRequestBody(`{\n "references": ["dataAPIFetchItem123", "dataAPIFetchItem234"],\n "created_by": [],\n "questions": {\n "references": [],\n "types": ["Multiple Selection"]\n },\n "resources": {\n "references": [],\n "types": ["Passage"]\n },\n "tags": [],\n "limit": 50,\n "page": 0,\n "sort_field": "created",\n "sort": "asc",\n "status": []\n}`);
149
+ menuBarPage.steps.execute();
150
+ cy.wait(2000);
151
+ utilities.verifyElementVisibilityState(menuBarPage.requestLoader(), 'notExist');
152
+ //Getting the timestamp
153
+ utilities.getNthElement(menuBarPage.exampleResponseBody(), 1)
154
+ .within(() => {
155
+ cy.contains('timestamp')
156
+ .next().next().then((currTimestamp) => {
157
+ timestamp = currTimestamp[0].innerText
158
+ });
159
+ });
160
+ });
161
+
162
+ it('All the items of the entered item references containing the entered question type, resource type and tags and sorted by created field ascending should be returned in the response with status code 200', () => {
163
+ cy.get('.response-col_status')
164
+ .eq(1)
165
+ .should('have.text', '200');
166
+ menuBarPage.exampleResponseBody()
167
+ .eq(1)
168
+ .should('have.text', `{\n "meta": {\n "status": true,\n "records": 0,\n "timestamp": ${timestamp},\n "next_token": null\n },\n "data": []\n}\n`);
169
+ });
170
+
171
+ it('Updating \'dataAPIFetchItem123\' item to update its last updated time', () => {
172
+ menuBarPage.steps.navigateToBrowseItems();
173
+ menuBarPage.steps.navigateToQuestionUsingReferenceId('dataAPIFetchItem123')
174
+ menuBarPage.steps.enterTitle('dataAPIFetchItem123 edited');
175
+ });
176
+
177
+ it('Entering request to get multiple items data, filtered by question type, resource type & tags and sorted by updated descending', () => {
178
+ menuBarPage.steps.expandItemBankDataApiAccordion();
179
+ menuBarPage.steps.clickFetchItemsButton();
180
+ menuBarPage.steps.tryItOut();
181
+ menuBarPage.steps.enterTextInSampleRequestBody(`{\n "references": ["dataAPIFetchItem123 edited"],\n "created_by": [],\n "questions": {\n "references": [],\n "types": ["multiple selection"]\n },\n "resources": {\n "references": [],\n "types": []\n },\n "tags": ["beta"],\n "limit": 50,\n "page": 0,\n "sort_field": "updated",\n "sort": "desc",\n "status": []\n}`);
182
+ menuBarPage.steps.execute();
183
+ cy.wait(2000);
184
+ utilities.verifyElementVisibilityState(menuBarPage.requestLoader(), 'notExist');
185
+ //Getting the timestamp and new dt_updated
186
+ utilities.getNthElement(menuBarPage.exampleResponseValue(), 0)
187
+ .within(() => {
188
+ cy.contains('timestamp')
189
+ .next().next().then((currTimestamp) => {
190
+ timestamp = currTimestamp[0].innerText
191
+ });
192
+ cy.contains('dt_updated')
193
+ .eq(0)
194
+ .next().next().then((currdt_updated) => {
195
+ dt_updated = currdt_updated[0].innerText
196
+ });
197
+ });
198
+ });
199
+
200
+ it('All the items of the entered item references containing the entered question type, resource type and tags sorted by updated ascending should be returned in the response with status code 200', () => {
201
+ utilities.getNthElement(menuBarPage.exampleResponseBody(), 1)
202
+ .should('have.text', `{\n "meta": {\n "status": true,\n "records": 0,\n "timestamp": ${timestamp},\n "next_token": null\n },\n "data": []\n}\n`);
203
+ });
204
+ });