itemengine-cypress-automation 1.0.324-updateBumpVersion-bbf003e.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.
- package/cypress/e2e/dataApi/fetchItems.js +1 -1
- package/cypress/e2e/dataApi/saveQuestionsMCQAlternateAnswers.js +1 -1
- package/cypress/pages/components/browseItemsPage.js +11 -0
- package/cypress/pages/createItemPage.js +7 -0
- package/cypress/pages/index.js +2 -1
- package/cypress/pages/menuBarPage.js +66 -0
- package/cypress/support/commands.js +38 -0
- package/cypress/support/helpers/createItem.js +428 -0
- package/package.json +1 -1
@@ -197,7 +197,7 @@ describe('Get Item Data API cases', () => {
|
|
197
197
|
});
|
198
198
|
});
|
199
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', () => {
|
200
|
+
it.skip('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
201
|
utilities.getNthElement(menuBarPage.exampleResponseBody(), 1)
|
202
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
203
|
});
|
@@ -70,7 +70,7 @@ describe('Save MCQ Question with Alternate Answers API cases', () => {
|
|
70
70
|
.should('have.text', '200');
|
71
71
|
cy.get('pre[class="microlight"]')
|
72
72
|
.eq(1)
|
73
|
-
.should('have.text', `{\n
|
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
74
|
});
|
75
75
|
|
76
76
|
it('Entering request with empty question_XML', () => {
|
@@ -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
|
package/cypress/pages/index.js
CHANGED
@@ -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
|
});
|
@@ -0,0 +1,428 @@
|
|
1
|
+
import uuid from 'react-uuid';
|
2
|
+
export var itemReferenceIds = [];
|
3
|
+
export var questionAndResourceReferenceIds = [];
|
4
|
+
export var createdAndUpdatedAtDate = [];
|
5
|
+
|
6
|
+
const domainName = `${Cypress.env('SANDBOX_SERVICES_URL')}`.slice(8);
|
7
|
+
const referenceIdsItem = ["f72bdb8-e6ad-64f-617b-fe40d2b0a7"];
|
8
|
+
|
9
|
+
Cypress.Commands.add('createItem', (itemName) => {
|
10
|
+
const token = window.localStorage.getItem('ngie_accessToken');
|
11
|
+
const firstName = window.localStorage.getItem('ngie_firstName');
|
12
|
+
const lastName = window.localStorage.getItem('ngie_lastName');
|
13
|
+
const userID = window.localStorage.getItem('ngie_userId');
|
14
|
+
var currentReferenceIds = [];
|
15
|
+
for (var i = 0; i < 42; i++) {
|
16
|
+
currentReferenceIds.push(uuid());
|
17
|
+
};
|
18
|
+
console.log(currentReferenceIds)
|
19
|
+
|
20
|
+
cy.request({
|
21
|
+
headers: {
|
22
|
+
Authorization: `${token}`,
|
23
|
+
'content-type': 'application/json',
|
24
|
+
},
|
25
|
+
method: 'POST',
|
26
|
+
url: `${Cypress.env('SANDBOX_GRAPHQL_SERVICES_URL')}/`,
|
27
|
+
body: [
|
28
|
+
{
|
29
|
+
"operationName": "generateSignedRequest",
|
30
|
+
"variables": {
|
31
|
+
"input": {
|
32
|
+
"service": "author",
|
33
|
+
"requestPacket": {
|
34
|
+
"mode": "itemEdit",
|
35
|
+
"config": {
|
36
|
+
"theme": "theme1",
|
37
|
+
"itemWidgetTemplates": {
|
38
|
+
"save": {
|
39
|
+
"show": true
|
40
|
+
}
|
41
|
+
},
|
42
|
+
"itemEdit": {
|
43
|
+
"item": {
|
44
|
+
"back": false,
|
45
|
+
"save": {
|
46
|
+
"show": false,
|
47
|
+
"autoSave": true
|
48
|
+
},
|
49
|
+
"reference": {
|
50
|
+
"edit": true,
|
51
|
+
"show": false
|
52
|
+
},
|
53
|
+
"duplicate": {
|
54
|
+
"show": false
|
55
|
+
},
|
56
|
+
"responseMode": "all",
|
57
|
+
"title": {
|
58
|
+
"edit": true,
|
59
|
+
"show": true
|
60
|
+
},
|
61
|
+
"settings": {
|
62
|
+
"show": true,
|
63
|
+
"showPrintPreview": true,
|
64
|
+
"showScoring": true,
|
65
|
+
"showTags": true
|
66
|
+
}
|
67
|
+
},
|
68
|
+
"widget": {
|
69
|
+
"showPreviewRadioButtonsAndScore": true
|
70
|
+
}
|
71
|
+
},
|
72
|
+
"loaderType": "full-screen",
|
73
|
+
"isCustomLoader": true,
|
74
|
+
"customLoaderId": "globalLoader"
|
75
|
+
},
|
76
|
+
"user": {
|
77
|
+
"firstName": firstName,
|
78
|
+
"lastName": lastName,
|
79
|
+
"id": userID
|
80
|
+
},
|
81
|
+
"systemGeneratedItems": {
|
82
|
+
"referenceIds": [
|
83
|
+
referenceIdsItem
|
84
|
+
]
|
85
|
+
}
|
86
|
+
},
|
87
|
+
"type": "item",
|
88
|
+
"userId": userID,
|
89
|
+
"domain": "sandbox.itemengine-staging.il-apps.com"
|
90
|
+
}
|
91
|
+
},
|
92
|
+
"query": "query generateSignedRequest($input: GenerateSignedRequest) {\n generateSignedRequest(input: $input) {\n success\n signedRequest {\n authentication {\n timestamp\n domain\n consumerKey\n signature\n userId\n __typename\n }\n request\n __typename\n }\n __typename\n }\n}\n"
|
93
|
+
}
|
94
|
+
]
|
95
|
+
}).then((resp) => {
|
96
|
+
if (resp.status.toString().startsWith('5') && retries > 0) {
|
97
|
+
cy.log('ENCOUNTERED A 5xx ERROR');
|
98
|
+
}
|
99
|
+
const request = resp.body[0].data.generateSignedRequest.signedRequest.request;
|
100
|
+
const authentication = {
|
101
|
+
consumerKey: resp.body[0].data.generateSignedRequest.signedRequest.authentication.consumerKey,
|
102
|
+
domain: domainName,
|
103
|
+
signature: resp.body[0].data.generateSignedRequest.signedRequest.authentication.signature,
|
104
|
+
timestamp: resp.body[0].data.generateSignedRequest.signedRequest.authentication.timestamp
|
105
|
+
};
|
106
|
+
delete authentication.userId;
|
107
|
+
delete authentication.__typename;
|
108
|
+
delete request.__typename;
|
109
|
+
cy.request({
|
110
|
+
headers: {
|
111
|
+
Authorization: `${token}`,
|
112
|
+
'content-type': 'application/json',
|
113
|
+
Origin: `${Cypress.env('SANDBOX_SERVICES_URL')}`
|
114
|
+
},
|
115
|
+
method: 'POST',
|
116
|
+
url: `${Cypress.env('SERVICES_URL')}${Cypress.env('GRAPHQL_URL')}/`,
|
117
|
+
body: {
|
118
|
+
"operationName": "setItem",
|
119
|
+
"variables": {
|
120
|
+
"input": {
|
121
|
+
"authentication": authentication,
|
122
|
+
"request": request,
|
123
|
+
"service": "author",
|
124
|
+
"userRequest": {
|
125
|
+
"referenceId": itemName,
|
126
|
+
"metadata": [],
|
127
|
+
"version": 1,
|
128
|
+
"questions": [
|
129
|
+
{
|
130
|
+
"serialNo": 1,
|
131
|
+
"referenceId": referenceIdsItem[0],
|
132
|
+
"correctResponse": [
|
133
|
+
{
|
134
|
+
"xmlIdentifier": "RESPONSE",
|
135
|
+
"mappedKey": "ChoiceA",
|
136
|
+
"isCaseSensitive": false,
|
137
|
+
"answerSetId": 0
|
138
|
+
},
|
139
|
+
{
|
140
|
+
"xmlIdentifier": "RESPONSE",
|
141
|
+
"mappedKey": "ChoiceB",
|
142
|
+
"isCaseSensitive": false,
|
143
|
+
"answerSetId": 0
|
144
|
+
}
|
145
|
+
],
|
146
|
+
"instruction": "",
|
147
|
+
"isAutoScored": true,
|
148
|
+
"mappedCorrectResponse": [],
|
149
|
+
"defaultResponse": [],
|
150
|
+
"points": 2,
|
151
|
+
"scoringTypeId": 1,
|
152
|
+
"questionXml": "<assessmentItem xmlns=\"http://www.imsglobal.org/xsd/imsqti_v2p2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\" identifier=\"choiceMultiple\" title=\"Welcome to Biodome\" timeDependent=\"false\"><responseDeclaration identifier=\"RESPONSE\" cardinality=\"multiple\" baseType=\"identifier\"><correctResponse><value>ChoiceA</value><value>ChoiceB</value></correctResponse></responseDeclaration><outcomeDeclaration identifier=\"SCORE\" cardinality=\"single\" baseType=\"float\"/><itemBody><choiceInteraction responseIdentifier=\"RESPONSE\" orientation=\"horizontal\"><prompt></prompt><simpleChoice identifier=\"ChoiceA\">1</simpleChoice><simpleChoice identifier=\"ChoiceB\">2</simpleChoice><simpleChoice identifier=\"ChoiceC\">3</simpleChoice><simpleChoice identifier=\"ChoiceD\">4</simpleChoice></choiceInteraction></itemBody><responseProcessing template=\"http://www.imsglobal.org/question/qti_v2p2/rptemplates/map_response\"/></assessmentItem>",
|
153
|
+
"typeId": 5,
|
154
|
+
"metadata": {
|
155
|
+
"acknowledgements": "",
|
156
|
+
"sampleAnswer": "",
|
157
|
+
"toolSettingsResourcesOrder": [
|
158
|
+
{
|
159
|
+
"resourceTypeId": 2,
|
160
|
+
"toolOrder": 3
|
161
|
+
},
|
162
|
+
{
|
163
|
+
"resourceTypeId": 3,
|
164
|
+
"toolOrder": 0
|
165
|
+
},
|
166
|
+
{
|
167
|
+
"resourceTypeId": 6,
|
168
|
+
"toolOrder": 2
|
169
|
+
},
|
170
|
+
{
|
171
|
+
"resourceTypeId": 7,
|
172
|
+
"toolOrder": 1
|
173
|
+
},
|
174
|
+
{
|
175
|
+
"resourceTypeId": 10,
|
176
|
+
"toolOrder": 4
|
177
|
+
},
|
178
|
+
{
|
179
|
+
"resourceTypeId": 21,
|
180
|
+
"toolOrder": 5
|
181
|
+
}
|
182
|
+
]
|
183
|
+
},
|
184
|
+
"settings": {
|
185
|
+
"optionStyleType": 1,
|
186
|
+
"optionNumeration": 2,
|
187
|
+
"optionOrientation": 2,
|
188
|
+
"optionColumns": 1,
|
189
|
+
"isCheckAnswerEnabled": false,
|
190
|
+
"nonAccessible": false,
|
191
|
+
"maxCheckAnswerAllowed": 0,
|
192
|
+
"minAnswersAllowed": null,
|
193
|
+
"maxAnswersAllowed": null,
|
194
|
+
"shuffleOption": false,
|
195
|
+
"positionLock": false,
|
196
|
+
"isRoundingEnabled": true,
|
197
|
+
"optionFontSize": 1,
|
198
|
+
"autoScoredViewMode": "defaultScoring",
|
199
|
+
"excludeFromPrint": false,
|
200
|
+
"disablePrevIncorrect": false,
|
201
|
+
"roundingType": 1,
|
202
|
+
"isMultipleColumns": false,
|
203
|
+
"optionAlignment": 1
|
204
|
+
},
|
205
|
+
"content": {
|
206
|
+
"correctResponses": [
|
207
|
+
{
|
208
|
+
"answerSetId": 0,
|
209
|
+
"correctAnswers": [
|
210
|
+
"ChoiceA",
|
211
|
+
"ChoiceB"
|
212
|
+
]
|
213
|
+
}
|
214
|
+
],
|
215
|
+
"instructionsForPrint": "",
|
216
|
+
"answerSets": [
|
217
|
+
{
|
218
|
+
"id": 0,
|
219
|
+
"points": 2
|
220
|
+
}
|
221
|
+
]
|
222
|
+
},
|
223
|
+
"penaltyPoints": null,
|
224
|
+
"minScoreIfAttempted": null,
|
225
|
+
"minScoreType": null,
|
226
|
+
"penaltyPointType": null,
|
227
|
+
"isAutoPenaltySetting": false,
|
228
|
+
"isNegativeRounded": true,
|
229
|
+
"specificPenaltyType": null,
|
230
|
+
"penaltyPointsForEach": null,
|
231
|
+
"teacherGuideline": "",
|
232
|
+
"scoringGuidance": "",
|
233
|
+
"sampleResponse": "",
|
234
|
+
"resources": [],
|
235
|
+
"answerSets": [
|
236
|
+
{
|
237
|
+
"id": 0,
|
238
|
+
"points": 2
|
239
|
+
}
|
240
|
+
]
|
241
|
+
}
|
242
|
+
],
|
243
|
+
"resources": [],
|
244
|
+
"statusId": 1,
|
245
|
+
"isNewVersion": false,
|
246
|
+
"settings": {
|
247
|
+
"selectedColumn": 1,
|
248
|
+
"tab1": false,
|
249
|
+
"enableScroll": false,
|
250
|
+
"itemScoringType": 1,
|
251
|
+
"verticalDivider": false,
|
252
|
+
"columns": [
|
253
|
+
{
|
254
|
+
"widgets": [
|
255
|
+
{
|
256
|
+
"referenceId": referenceIdsItem[0],
|
257
|
+
"itemType": 1
|
258
|
+
}
|
259
|
+
],
|
260
|
+
"id": referenceIdsItem[1]
|
261
|
+
}
|
262
|
+
],
|
263
|
+
"sections": {
|
264
|
+
"navigationOrientation": 1,
|
265
|
+
"navigationStyle": 1,
|
266
|
+
"navigationAlignment": 1
|
267
|
+
},
|
268
|
+
"spacingOptions": 1,
|
269
|
+
"enableMultiLanguage": false,
|
270
|
+
"enableNonAccessible": false,
|
271
|
+
"horizontalSeparatorLine": false,
|
272
|
+
"separatorStyle": 1,
|
273
|
+
"disableCutCopyPaste": false,
|
274
|
+
"enableRandomizeQuestions": false,
|
275
|
+
"alternateAccessibleItemId": "",
|
276
|
+
"enableSections": false,
|
277
|
+
"roundNegativeToZero": false
|
278
|
+
}
|
279
|
+
}
|
280
|
+
}
|
281
|
+
},
|
282
|
+
"query": "mutation setItem($input: SetItemInput) {\n setItem(input: $input) {\n success\n statusCode\n message\n data {\n settings\n id\n version\n contentVersion\n contentId\n title\n statusId\n instruction\n description\n authorName\n createdAt\n updatedAt\n createdBy\n referenceId\n questionId\n questionTags {\n id\n name\n type\n __typename\n }\n metadata {\n id\n metaKey\n metaKeyValue\n __typename\n }\n questions {\n id\n instruction\n points\n typeId\n questionXml\n referenceId\n updatedAt\n createdBy\n scoringTypeId\n teacherGuideline\n penaltyPoints\n minScoreIfAttempted\n minScoreType\n penaltyPointType\n isAutoPenaltySetting\n isNegativeRounded\n specificPenaltyType\n penaltyPointsForEach\n isAutoScored\n createdAt\n scoringGuidance\n sampleResponse\n resources {\n id\n name\n referenceId\n resourceTypeId\n metadata\n settings\n content\n type\n isCustomResource\n __typename\n }\n type {\n id\n name\n __typename\n }\n serialNo\n metadata\n correctResponse {\n id\n questionPartId\n xmlIdentifier\n mappedKey\n isCaseSensitive\n answerSetId\n alternateId\n __typename\n }\n mappedCorrectResponse {\n id\n questionPartId\n mappedKey\n mappedValue\n xmlIdentifier\n answerSetId\n alternateId\n __typename\n }\n defaultResponse {\n id\n questionPartId\n xmlIdentifier\n responseText\n __typename\n }\n answerSets {\n id\n points\n cellFillCount\n matchPositionOfSelectedCells\n __typename\n }\n __typename\n }\n resources {\n id\n name\n referenceId\n resourceTypeId\n serialNo\n metadata\n createdAt\n updatedAt\n createdBy\n resourceList {\n id\n name\n referenceId\n resourceTypeId\n metadata\n settings\n content\n type\n isCustomResource\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n}\n"
|
283
|
+
}
|
284
|
+
}).then((resp) => {
|
285
|
+
if (resp.status.toString().startsWith('5') && retries > 0) {
|
286
|
+
cy.log('ENCOUNTERED A 5xx ERROR');
|
287
|
+
}
|
288
|
+
var currCreatedAndUpdatedAtDate = [];
|
289
|
+
currCreatedAndUpdatedAtDate.push(resp.body.data.setItem.data.createdAt);
|
290
|
+
currCreatedAndUpdatedAtDate.push(resp.body.data.setItem.data.updatedAt);
|
291
|
+
createdAndUpdatedAtDate.push(currCreatedAndUpdatedAtDate);
|
292
|
+
questionAndResourceReferenceIds.push(currentReferenceIds);
|
293
|
+
itemReferenceIds.push(itemName);
|
294
|
+
console.log(createdAndUpdatedAtDate);
|
295
|
+
console.log(questionAndResourceReferenceIds);
|
296
|
+
console.log(itemReferenceIds);
|
297
|
+
});
|
298
|
+
});
|
299
|
+
});
|
300
|
+
|
301
|
+
Cypress.Commands.add('deleteItem', (itemReference) => {
|
302
|
+
const token = window.localStorage.getItem('ngie_accessToken');
|
303
|
+
const firstName = window.localStorage.getItem('ngie_firstName');
|
304
|
+
const lastName = window.localStorage.getItem('ngie_lastName');
|
305
|
+
const userID = window.localStorage.getItem('ngie_userId');
|
306
|
+
cy.request({
|
307
|
+
headers: {
|
308
|
+
Authorization: `${token}`,
|
309
|
+
'content-type': 'application/json',
|
310
|
+
},
|
311
|
+
method: 'POST',
|
312
|
+
url: `${Cypress.env('SANDBOX_GRAPHQL_SERVICES_URL')}/`,
|
313
|
+
body: [
|
314
|
+
{
|
315
|
+
"operationName": "generateSignedRequest",
|
316
|
+
"variables": {
|
317
|
+
"input": {
|
318
|
+
"service": "author",
|
319
|
+
"requestPacket": {
|
320
|
+
"mode": "itemList",
|
321
|
+
"config": {
|
322
|
+
"loaderType": "full-screen",
|
323
|
+
"itemList": {
|
324
|
+
"limit": 20,
|
325
|
+
"toolbar": {
|
326
|
+
"add": true
|
327
|
+
},
|
328
|
+
"filter": {
|
329
|
+
"enableFilter": true,
|
330
|
+
"filterBackdrop": "div"
|
331
|
+
},
|
332
|
+
"actions": {
|
333
|
+
"options": [
|
334
|
+
{
|
335
|
+
"id": "student",
|
336
|
+
"label": "Student View"
|
337
|
+
},
|
338
|
+
{
|
339
|
+
"id": "correct",
|
340
|
+
"label": "Correct Answer View"
|
341
|
+
},
|
342
|
+
{
|
343
|
+
"id": "grading",
|
344
|
+
"label": "Grading View"
|
345
|
+
},
|
346
|
+
{
|
347
|
+
"id": "delete",
|
348
|
+
"label": "Delete"
|
349
|
+
},
|
350
|
+
{
|
351
|
+
"id": "duplicate",
|
352
|
+
"label": "Duplicate/New Version"
|
353
|
+
},
|
354
|
+
{
|
355
|
+
"id": "live",
|
356
|
+
"label": "Live Item Demo"
|
357
|
+
}
|
358
|
+
]
|
359
|
+
}
|
360
|
+
},
|
361
|
+
"isCustomLoader": true,
|
362
|
+
"customLoaderId": "globalLoader"
|
363
|
+
},
|
364
|
+
"systemGeneratedItems": {
|
365
|
+
"referenceIds": [
|
366
|
+
referenceIdsItem
|
367
|
+
]
|
368
|
+
},
|
369
|
+
"user": {
|
370
|
+
"firstName": firstName,
|
371
|
+
"lastName": lastName,
|
372
|
+
"id": userID
|
373
|
+
}
|
374
|
+
},
|
375
|
+
"domain": domainName
|
376
|
+
}
|
377
|
+
},
|
378
|
+
"query": "query generateSignedRequest($input: GenerateSignedRequest) {\n generateSignedRequest(input: $input) {\n success\n signedRequest {\n authentication {\n timestamp\n domain\n consumerKey\n signature\n userId\n __typename\n }\n request\n __typename\n }\n __typename\n }\n}\n"
|
379
|
+
}
|
380
|
+
]
|
381
|
+
}).then((resp) => {
|
382
|
+
if (resp.status.toString().startsWith('5') && retries > 0) {
|
383
|
+
cy.log('ENCOUNTERED A 5xx ERROR');
|
384
|
+
}
|
385
|
+
const currRequest = resp.body[0].data.generateSignedRequest.signedRequest.request;
|
386
|
+
const currAuthentication = {
|
387
|
+
consumerKey: resp.body[0].data.generateSignedRequest.signedRequest.authentication.consumerKey,
|
388
|
+
domain: domainName,
|
389
|
+
signature: resp.body[0].data.generateSignedRequest.signedRequest.authentication.signature,
|
390
|
+
timestamp: resp.body[0].data.generateSignedRequest.signedRequest.authentication.timestamp
|
391
|
+
};
|
392
|
+
delete currAuthentication.userId;
|
393
|
+
delete currAuthentication.__typename;
|
394
|
+
delete currRequest.__typename;
|
395
|
+
cy.request({
|
396
|
+
headers: {
|
397
|
+
'content-type': "application/json",
|
398
|
+
Origin: `${Cypress.env('SANDBOX_SERVICES_URL')}`,
|
399
|
+
},
|
400
|
+
method: 'POST',
|
401
|
+
url: `${Cypress.env('SERVICES_URL')}${Cypress.env('GRAPHQL_URL')}/`,
|
402
|
+
body: {
|
403
|
+
"operationName": "deleteItem",
|
404
|
+
"variables": {
|
405
|
+
"input": {
|
406
|
+
"authentication": currAuthentication,
|
407
|
+
"request": currRequest,
|
408
|
+
"service": "author",
|
409
|
+
"userRequest": {
|
410
|
+
"itemReference": `${itemReference}`
|
411
|
+
}
|
412
|
+
}
|
413
|
+
},
|
414
|
+
"query": "mutation deleteItem($input: DeleteItemInput) {\n deleteItem(input: $input) {\n message\n success\n __typename\n }\n}\n"
|
415
|
+
},
|
416
|
+
}).then((resp) => {
|
417
|
+
if (resp.status.toString().startsWith('5') && retries > 0) {
|
418
|
+
cy.log('ENCOUNTERED A 5xx ERROR');
|
419
|
+
}
|
420
|
+
});
|
421
|
+
});
|
422
|
+
});
|
423
|
+
|
424
|
+
Cypress.Commands.add('deleteItems', () => {
|
425
|
+
itemReferenceIds.forEach((i) => {
|
426
|
+
cy.deleteItem(i);
|
427
|
+
});
|
428
|
+
});
|