-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcypress.config.ts
265 lines (249 loc) · 7.99 KB
/
cypress.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
import { defineConfig } from 'cypress';
import * as dayjs from 'dayjs';
import {
TEST_V1_EXTERNAL_GRANT,
TEST_V1_INTERNAL_GRANT,
TEST_V2_EXTERNAL_GRANT,
TEST_V2_INTERNAL_GRANT,
EXPORT_BATCH,
} from './cypress/common/constants';
import {
addAdminInTechSupportTable,
addSpotlightBatch,
addToRecentBatch,
cleanupTestSpotlightSubmissions,
createApiKeysData,
createApiKeysInApiGatewayForTechnicalSupport,
createApplyData,
deleteAPIKeysFromAwsForTechSupport,
deleteApiKeysData,
deleteApplySchemes,
deleteSpotlightBatch,
deleteSpotlightSubmission,
getExportedSubmissionUrlAndLocation,
insertSubmissionAndExport,
insertSubmissionsAndMQs,
updateSpotlightSubmission,
simulateMultipleApplicationFormEditors,
deleteApplyData,
} from './cypress/seed/apply/service';
import { deleteFindData } from './cypress/seed/find';
import {
addFailedOauthAudit,
addSuccessOauthAudit,
addTechSupportRoleToAdmin,
createTestUsers,
deleteTestUsers,
removeTechSupportRoleFromAdmin,
} from './cypress/seed/user';
import {
publishGrantAdverts,
removeAdvertByName,
unpublishAdvertByName,
waitForAdvertToPublish,
} from './cypress/seed/contentful';
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const decompress = require('decompress');
require('dotenv').config();
export default defineConfig({
taskTimeout: 120000,
e2e: {
setupNodeEvents(on) {
// implement node event listeners here
on('task', {
async addFailedOauthAudit() {
await addFailedOauthAudit();
return null;
},
async addSuccessOauthAudit() {
await addSuccessOauthAudit();
return null;
},
async addSpotlightBatch() {
await deleteSpotlightBatch().then(async () => {
await addSpotlightBatch();
});
return null;
},
async addSubmissionToMostRecentBatch() {
await addToRecentBatch();
return null;
},
async updateSpotlightSubmissionStatus(status) {
await updateSpotlightSubmission(status);
return null;
},
async cleanupTestSpotlightSubmissions() {
await deleteSpotlightSubmission();
await deleteSpotlightBatch();
await cleanupTestSpotlightSubmissions();
return null;
},
async setUpUser() {
await deleteTestUsers().then(async () => {
await createTestUsers();
});
return null;
},
async setUpApplyData() {
await deleteApplyData();
await createApplyData({ publishedAds: true });
return null;
},
async setUpApplyDataWithAds() {
await deleteApplyData();
await createApplyData({ publishedAds: false });
await publishGrantAdverts();
return null;
},
async waitForAdvertToPublish(name) {
await waitForAdvertToPublish(name);
return null;
},
async removeAdvertByName(name) {
await removeAdvertByName(name);
return null;
},
async unpublishAdvert(advertName) {
await unpublishAdvertByName(advertName);
return null;
},
async deleteSchemes() {
await deleteApplySchemes();
return null;
},
async simulateMultipleApplicationFormEditors() {
await simulateMultipleApplicationFormEditors();
return null;
},
async addTechSupportRoleToAdmin() {
// we remove the tech support user in apply db in deleteApplyData
await removeTechSupportRoleFromAdmin().then(async () => {
await addTechSupportRoleToAdmin();
await addAdminInTechSupportTable();
});
return null;
},
async setUpFindData() {
await deleteFindData();
return null;
},
async create11ApiKeys() {
await deleteApiKeysData().then(async () => {
await createApiKeysData();
});
return null;
},
async deleteAPIKeysFromAwsForTechSupport() {
await deleteAPIKeysFromAwsForTechSupport();
return null;
},
async createApiKeysInApiGatewayForTechnicalSupport() {
await createApiKeysInApiGatewayForTechnicalSupport(1, 2);
return null;
},
async insertSubmissionsAndMQs() {
await insertSubmissionsAndMQs();
return null;
},
async insertSubmissionAndExport() {
await insertSubmissionAndExport();
return null;
},
async parseXlsx({ filePath }) {
try {
return xlsx.parse(fs.readFileSync(__dirname + filePath));
} catch (e) {
console.error(e);
return null;
}
},
unzip({ path, file }) {
return decompress(
path + file,
path + 'unzip/' + file.replace('.zip', ''),
);
},
async getExportedSubmissionUrlAndLocation(schemeId: string) {
return await getExportedSubmissionUrlAndLocation(schemeId);
},
log(message) {
console.log(dayjs().format() + ' | ' + message);
return null;
},
async ls(filePath = '/cypress/downloads') {
const list = fs.readdirSync(__dirname + filePath);
console.log(list);
return `ls ${filePath}: ${JSON.stringify(list)}`;
},
table(message) {
console.table(message);
return null;
},
});
require('cypress-mochawesome-reporter/plugin')(on);
},
env: {
oneLoginSandboxBaseUrl: process.env.ONE_LOGIN_BASE_URL,
oneLoginSandboxUsername: process.env.ONE_LOGIN_USERNAME,
oneLoginSandboxPassword: process.env.ONE_LOGIN_PASSWORD,
oneLoginApplicantEmail: process.env.ONE_LOGIN_APPLICANT_EMAIL,
oneLoginApplicantPassword: process.env.ONE_LOGIN_APPLICANT_PASSWORD,
oneLoginAdminEmail: process.env.ONE_LOGIN_ADMIN_EMAIL,
oneLoginAdminPassword: process.env.ONE_LOGIN_ADMIN_PASSWORD,
oneLoginSuperAdminEmail: process.env.ONE_LOGIN_SUPER_ADMIN_EMAIL,
oneLoginSuperAdminPassword: process.env.ONE_LOGIN_SUPER_ADMIN_PASSWORD,
oneLoginTechnicalSupportEmail:
process.env.ONE_LOGIN_TECHNICAL_SUPPORT_EMAIL,
oneLoginTechnicalSupportPassword:
process.env.ONE_LOGIN_TECHNICAL_SUPPORT_PASSWORD,
userDbUrl: process.env.USERS_DATABASE_URL,
userDbName: process.env.USERS_DATABASE_NAME,
applyDbUrl: process.env.APPLY_DATABASE_URL,
applyDbName: process.env.APPLY_DATABASE_NAME,
applicationBaseUrl: process.env.APPLICATION_BASE_URL,
postLoginBaseUrl: process.env.POST_LOGIN_BASE_URL,
firstUserId: process.env.FIRST_USER_ID,
testV1InternalGrant: {
...TEST_V1_INTERNAL_GRANT,
},
testV1ExternalGrant: {
...TEST_V1_EXTERNAL_GRANT,
},
testV2InternalGrant: {
...TEST_V2_INTERNAL_GRANT,
},
testV2ExternalGrant: {
...TEST_V2_EXTERNAL_GRANT,
},
exportBatch: {
...EXPORT_BATCH,
},
awsRegion: process.env.AWS_API_GATEWAY_REGION,
awsAccessKey: process.env.AWS_API_GATEWAY_ACCESS_KEY,
awsSecretKey: process.env.AWS_API_GATEWAY_SECRET_KEY,
awsApiGatewayUsagePlanId: process.env.AWS_API_GATEWAY_USAGE_PLAN_ID,
awsEnvironment: process.env.AWS_ENVIRONMENT,
},
reporter: 'cypress-mochawesome-reporter',
reporterOptions: {
reportDir: 'mochawesome-report',
reportFilename: '[status]_[datetime]_report',
timestamp: 'yyyy-mm-ddTHH:MM:ssZ',
charts: true,
reportPageTitle: 'Find a Grant',
embeddedScreenshots: true,
inlineAssets: true,
saveAllAttempts: false,
debug: true,
html: true,
json: false,
overwrite: false,
},
baseUrl: process.env.APPLICATION_BASE_URL,
viewportWidth: 1000,
viewportHeight: process.env.HEADFUL_MODE === 'true' ? 1000 : 2000,
experimentalRunAllSpecs: true,
},
});