@getjones/test-infra 1.7.2 → 1.7.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getjones/test-infra",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -6,7 +6,8 @@ const Endpoints = {
6
6
  delete: projectId => `${backendUrl}/saas/project/${projectId}`,
7
7
  getByAccountId: `${backendUrl}/saas/project/list`,
8
8
  update: `${backendUrl}/saas/project`,
9
- getProjectByProjectId: projectId => `${backendUrl}/saas/project/${projectId}`
9
+ getProjectByProjectId: projectId => `${backendUrl}/saas/project/${projectId}`,
10
+ getProjectServiceAreaByProjectId: projectId => `${backendUrl}/saas/integration-tests/project/${projectId}/service-area`
10
11
  };
11
12
 
12
13
  const create = (project, context) => {
@@ -31,4 +32,8 @@ const update = (project, context) => {
31
32
  return requests.postRequestHandler(Endpoints.update, project, context);
32
33
  };
33
34
 
34
- module.exports = { create, getProjectsByAccountId, deleteProjectById, update, getProjectByProjectId };
35
+ const getProjectServiceAreaByProjectId = (projectId, context) => {
36
+ return requests.getRequestHandler(Endpoints.getProjectServiceAreaByProjectId(projectId), {}, context);
37
+ };
38
+
39
+ module.exports = { create, getProjectsByAccountId, deleteProjectById, update, getProjectByProjectId, getProjectServiceAreaByProjectId };
@@ -17,6 +17,10 @@ const getProjectByName = async (accountId, projectName, context) => {
17
17
  return requestedProject ? requestedProject : null;
18
18
  };
19
19
 
20
+ const getProjectServiceArea = (projectId, context) => {
21
+ return projectsApi.getProjectServiceAreaByProjectId(projectId, context);
22
+ };
23
+
20
24
  const deleteProjectByName = async (accountId, projectName, context) => {
21
25
  const { data: projects } = await getProjectsByAccountId(accountId, context);
22
26
  const filteredProjects = projects.filter(project => project.projectName === projectName);
@@ -56,5 +60,6 @@ module.exports = {
56
60
  getProjectByName,
57
61
  createProject,
58
62
  deleteProjectByName,
59
- updateProject
63
+ updateProject,
64
+ getProjectServiceArea
60
65
  };
@@ -1,13 +1,13 @@
1
1
  const tabsAPI = require('./tabs.api');
2
+ const { CreateTabModel, UpdateTabModel } = require('../models/tabs.model');
2
3
 
3
4
  const createTab = async (projectId, tabName, tabType, context) => {
4
- const tabModel = { projectId, tabName, type: tabType };
5
+ const tabModel = new CreateTabModel(projectId, tabName, tabType);
5
6
  return tabsAPI.createTab(tabModel, context);
6
7
  };
7
8
 
8
- const updateTab = async (projectId, tabName, tabType, tabId, context) => {
9
- const tabModel = { projectId, tabName, type: tabType, tabId };
10
- return tabsAPI.updateTab(tabModel, context);
9
+ const getTabById = async (tabId, context) => {
10
+ return tabsAPI.getTabByTabId(tabId, context);
11
11
  };
12
12
 
13
13
  const getTabsByProjectId = async (projectId, context) => {
@@ -15,21 +15,13 @@ const getTabsByProjectId = async (projectId, context) => {
15
15
  };
16
16
 
17
17
  const getTabsByName = async (projectId, tabName, context, { tabType } = {}) => {
18
- const { data: tabs } = await tabsAPI.getTabsByProjectId(projectId, context);
18
+ const { data: tabs } = await getTabsByProjectId(projectId, context);
19
19
  const requestedTab = tabType ?
20
20
  tabs.find(tab => tab.tabName === tabName && tab.type === tabType) :
21
21
  tabs.find(tab => tab.tabName === tabName);
22
22
  return requestedTab;
23
23
  };
24
24
 
25
- const getTabById = async (tabId, context) => {
26
- return tabsAPI.getTabByTabId(tabId, context);
27
- };
28
-
29
- const deleteTabById = async (tabId, context) => {
30
- return tabsAPI.deleteTab(tabId, context);
31
- };
32
-
33
25
  const getOrCreateTab = async (projectId, tabName, tabType, context) => {
34
26
  const { data: tabs } = await getTabsByProjectId(projectId, context);
35
27
  const existingTab = tabs.find(tab => tab.tabName === tabName && tab.type === tabType);
@@ -42,12 +34,21 @@ const getOrCreateTab = async (projectId, tabName, tabType, context) => {
42
34
  return createResponse.data;
43
35
  };
44
36
 
37
+ const updateTab = async (projectId, tabName, tabType, tabId, context) => {
38
+ const tabModel = new UpdateTabModel(projectId, tabName, tabType, tabId);
39
+ return tabsAPI.updateTab(tabModel, context);
40
+ };
41
+
42
+ const deleteTabById = async (tabId, context) => {
43
+ return tabsAPI.deleteTab(tabId, context);
44
+ };
45
+
45
46
  module.exports = {
47
+ createTab,
46
48
  getTabById,
47
49
  getTabsByProjectId,
48
- createTab,
49
- updateTab,
50
- deleteTabById,
50
+ getTabsByName,
51
51
  getOrCreateTab,
52
- getTabsByName
52
+ updateTab,
53
+ deleteTabById
53
54
  };
@@ -0,0 +1,18 @@
1
+ class CreateTabModel {
2
+ constructor(projectId, tabName, tabType) {
3
+ this.projectId = projectId;
4
+ this.tabName = tabName;
5
+ this.type = tabType;
6
+ }
7
+ }
8
+
9
+ class UpdateTabModel {
10
+ constructor(projectId, tabName, tabType, tabId) {
11
+ this.projectId = projectId;
12
+ this.tabName = tabName;
13
+ this.type = tabType;
14
+ this.tabId = tabId;
15
+ }
16
+ }
17
+
18
+ module.exports = { CreateTabModel, UpdateTabModel };
package/README.md DELETED
@@ -1,329 +0,0 @@
1
- # Package Name: @getjones/test-infra
2
-
3
- ## Package Goal
4
-
5
- - Providing an easy and reusable interface for the backend system. Means, both by the OpenAPI, and the internal API.
6
-
7
- ## Interface
8
-
9
- ### init
10
-
11
- - require the package with settled up configuration json
12
-
13
- ```node
14
- const { internalAPI } = require("@getjones/test-infra")(conf);
15
- ```
16
-
17
- - configuration example
18
-
19
- ```node
20
- const dotenv = require("dotenv");
21
-
22
- dotenv.config();
23
-
24
- module.exports = {
25
- backendUrl: process.env.BACKEND_URL,
26
- credentials: {
27
- superUser: process.env.CREDENTIALS_SUPER_USER,
28
- superUserPassword: process.env.CREDENTIALS_SUPER_USER_PASSWORD,
29
- strongPassword: process.env.CREDENTIALS_STRONG_PASSWORD,
30
- },
31
- accountCreationSecret: process.env.ACCOUNT_CREATION_SECRET,
32
- environment: process.env.ENVIRONMENT,
33
- email: process.env.EMAIL,
34
- };
35
- ```
36
-
37
- ### internalAPI
38
-
39
- - internalAPI contains the next services:
40
- - auth
41
- - accounts
42
- - accountSettings
43
- - projects
44
- - projectSettings
45
-
46
- ```node
47
- const { auth, accounts, accountSettings, projects } = internalAPI;
48
- ```
49
-
50
- ### auth
51
-
52
- ```node
53
- /**
54
- *
55
- * @param email (string)
56
- * @param password (string)
57
- * @return Auth cookie (string) with given email privileges.
58
- */
59
- const getAuthCookie = async (email, password) => {};
60
-
61
- /**
62
- *
63
- * Required Configuration: {
64
- * credentials.superUser,
65
- * credentials.superUserPassword
66
- * }
67
- * @return ICS cookie (String)
68
- */
69
- const getIcsCookie = async () => {};
70
-
71
- /**
72
- *
73
- * Required Configuration: {
74
- * credentials.auditorUser,
75
- * credentials.auditorPassword
76
- * }
77
- * @return Auditor cookie (String)
78
- */
79
- const getAuditorCookie = async () => {};
80
-
81
- /**
82
- *
83
- * Required Configuration: {
84
- * credentials.operatorUser,
85
- * credentials.operatorPassword
86
- * }
87
- * @return Operator cookie (String)
88
- */
89
- const getOperatorCookie = async () => {};
90
- ```
91
-
92
- ### accounts
93
-
94
- ```node
95
- /**
96
- *
97
- * Required Configuration: {
98
- * accountCreationSecret: accountCreationSecret,
99
- * }
100
- *
101
- * If you want to use default password so
102
- * 'credentials.strongPassword' is needed
103
- * to be a part of the configuration.
104
- *
105
- * @param email (string)
106
- * @param accountName (string)
107
- * @param context (string): Should contain ICS cookie
108
- * @return Account (object)
109
- */
110
-
111
- const createAccount = async (
112
- email,
113
- accountName,
114
- context,
115
- password = credentials.strongPassword,
116
- propertyType = PROPERTY_TYPE
117
- ) => {};
118
-
119
- /**
120
- *
121
- * @param accountName (string)
122
- * @param context (string): Should contains ICS cookie
123
- * @return Account (object)
124
- */
125
- const getAccount = async (accountName, context) => {};
126
-
127
- /**
128
- *
129
- * @param email (string)
130
- * @param accountName (string)
131
- * @param context (string): Should contain ICS cookie
132
- * @param password (string)
133
- * @return Account (object)
134
- */
135
- const getOrCreateAccount = async (
136
- email,
137
- accountName,
138
- context,
139
- password = credentials.strongPassword
140
- ) => {};
141
-
142
- /**
143
- *
144
- * @param accountName (string)
145
- * @param context (string): Should contain ICS cookie
146
- * @return Account ID (String)
147
- */
148
- const getAccountId = async (accountName, context) => {};
149
-
150
- /**
151
- *
152
- * @param accountName (string)
153
- * @param context (string): Should contains ICS cookie
154
- * @return Http Response
155
- */
156
- const deleteAccountByName = async (accountName, context) => {};
157
-
158
- /**
159
- *
160
- * @param accountId (string)
161
- * @param context (string): Should contain ICS cookie
162
- * @return Http Response
163
- */
164
- const deleteAccountById = async (accountId, context) => {};
165
- ```
166
-
167
- ### accountSettings
168
-
169
- ```node
170
- /**
171
- *
172
- * @param accountId (string)
173
- * @param context (string): Should contain ICS cookie
174
- * @return Account Settings (object)
175
- */
176
- const getAccountSettings = async (accountId, context) => {};
177
-
178
- /**
179
- *
180
- * @param accountId (string)
181
- * @param AccountSettings (object) Should Contain:
182
- * isMultiPropertyTenants (boolean)
183
- * isHighPriority (boolean)
184
- * @param context (string): Should contain ICS cookie
185
- * @return Http Response
186
- */
187
- const updateAccountSettings = async (
188
- accountId,
189
- isMultiPropertyTenants,
190
- isHighPriority,
191
- context
192
- ) => {};
193
-
194
- /**
195
- * Summary: Change account settings to default
196
- * Description:
197
- * Update The Next Account Settings:
198
- * isMultiPropertyTenants: false
199
- * isHighPriority: false
200
- * @param accountId (string)
201
- * @param context (string): Should Contain ICS cookie
202
- * @return Http Response
203
- */
204
- const restoreAccountSettings = async (accountId, context) => {};
205
- ```
206
-
207
- ### projects
208
-
209
- ```node
210
- /**
211
- *
212
- * @param accountName (string)
213
- * @param context (string): Should contain cookie
214
- * User's cookie that is related to this account or ICS cookie
215
- * @return List of projects ([objects])
216
- */
217
- const getProjectsByAccountName = async (accountName, context) => {};
218
-
219
- /**
220
- *
221
- * @param accountId (String)
222
- * @param context (string): Should contain cookie
223
- * User's cookie that is related to this account or ICS cookie
224
- * @return List of projects ([objects])
225
- */
226
- const getProjectsByAccountId = async (accountId, context) => {};
227
-
228
- /**
229
- *
230
- * @param accountId (string)
231
- * @param projectName (string)
232
- * @param context (string): Should contain cookie
233
- * User's cookie that is related to this account or ICS cookie
234
- * @return List of projects ([objects])
235
- */
236
- const getProjectsByName = async (accountId, projectName, context) => {};
237
-
238
- /**
239
- * Summary: Delete project by given details
240
- * @param accountId (string)
241
- * @param projectName (string)
242
- * @param context (string): Should contain cookie
243
- * User's cookie that is related to this account or ICS cookie
244
- * @return List of projects ([objects])
245
- */
246
- const deleteProjectByName = async (accountId, projectName, context) => {};
247
-
248
- /**
249
- *
250
- * @param project (object)
251
- * @param accountName (string)
252
- * @param context (string): Should contain cookie
253
- * User's cookie that is related to this account or ICS cookie
254
- * @return object contains generated projectId
255
- */
256
-
257
- // Example for project input (Not all of them are required):
258
- const createProjectInput = {
259
- projectName: project.name,
260
- userId: "",
261
- regionOrDivision: project.description,
262
- address: project.address,
263
- projectNumber: project.number,
264
- projectStartDate: project.startDate,
265
- projectEndDate: project.endDate,
266
- city: project.city,
267
- state: project.state,
268
- zipCode: project.zipCode,
269
- companyNameForProject: project.companyNameForProject,
270
- certificateHolder: "",
271
- additionalInsured: "",
272
- tenantSolutionEnabled: "",
273
- onboardingEnabled: "",
274
- automaticRenewalEnabled: "",
275
- };
276
-
277
- const createProject = async (project, accountName, context) => {};
278
- ```
279
-
280
- ### projectSettings
281
-
282
- ```node
283
- /**
284
- *
285
- * @param accountName (string)
286
- * @param context (string): Should contain cookie
287
- */
288
-
289
- const getProjectsByAccountName = async (accountName, context) => {};
290
-
291
- /**
292
- *
293
- * @param settings (object)
294
- * @param context (string): Should contain cookie
295
- */
296
-
297
- const updateProjectSettingsByProjectId = async (settings, context) => {};
298
-
299
- // Example for settings input (Not all of them are required):
300
- const updateProjectSettingsInput = {
301
- autoGaps: {
302
- Guests: false,
303
- Tenants: false,
304
- Vendors: false,
305
- },
306
- autoRenewals: false,
307
- marketplace: {
308
- marketplaceEnabled: false,
309
- marketplacePreApproved: false,
310
- marketplacePublicLink: false,
311
- },
312
- ocrEnabled: false,
313
- onboardingPhase: false,
314
- projectId: null,
315
- qrEnabled: false,
316
- tenantSolution: false,
317
- };
318
- ```
319
- ### serviceArea
320
-
321
- ```node
322
- /**
323
- * @param city (string)
324
- * @param state (string)
325
- * @param context (string): Should contain cookie
326
- */
327
-
328
- const getCoordinatesByAddress = (city, state, context) => {}
329
- ```