@symbo.ls/sdk 3.2.3 → 3.2.7
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/README.md +141 -0
- package/dist/cjs/config/environment.js +94 -10
- package/dist/cjs/index.js +152 -12
- package/dist/cjs/services/AdminService.js +351 -0
- package/dist/cjs/services/AuthService.js +738 -305
- package/dist/cjs/services/BaseService.js +158 -6
- package/dist/cjs/services/BranchService.js +484 -0
- package/dist/cjs/services/CollabService.js +439 -116
- package/dist/cjs/services/DnsService.js +340 -0
- package/dist/cjs/services/FeatureFlagService.js +175 -0
- package/dist/cjs/services/FileService.js +201 -0
- package/dist/cjs/services/IntegrationService.js +538 -0
- package/dist/cjs/services/MetricsService.js +62 -0
- package/dist/cjs/services/PaymentService.js +271 -0
- package/dist/cjs/services/PlanService.js +426 -0
- package/dist/cjs/services/ProjectService.js +1207 -0
- package/dist/cjs/services/PullRequestService.js +503 -0
- package/dist/cjs/services/ScreenshotService.js +304 -0
- package/dist/cjs/services/SubscriptionService.js +396 -0
- package/dist/cjs/services/TrackingService.js +661 -0
- package/dist/cjs/services/WaitlistService.js +148 -0
- package/dist/cjs/services/index.js +60 -4
- package/dist/cjs/state/RootStateManager.js +2 -23
- package/dist/cjs/state/rootEventBus.js +9 -0
- package/dist/cjs/utils/CollabClient.js +78 -12
- package/dist/cjs/utils/TokenManager.js +16 -3
- package/dist/cjs/utils/changePreprocessor.js +199 -0
- package/dist/cjs/utils/jsonDiff.js +46 -4
- package/dist/cjs/utils/ordering.js +309 -0
- package/dist/cjs/utils/services.js +285 -128
- package/dist/cjs/utils/validation.js +0 -3
- package/dist/esm/config/environment.js +94 -10
- package/dist/esm/index.js +47862 -18248
- package/dist/esm/services/AdminService.js +1132 -0
- package/dist/esm/services/AuthService.js +1493 -386
- package/dist/esm/services/BaseService.js +757 -6
- package/dist/esm/services/BranchService.js +1265 -0
- package/dist/esm/services/CollabService.js +24956 -16089
- package/dist/esm/services/DnsService.js +1121 -0
- package/dist/esm/services/FeatureFlagService.js +956 -0
- package/dist/esm/services/FileService.js +982 -0
- package/dist/esm/services/IntegrationService.js +1319 -0
- package/dist/esm/services/MetricsService.js +843 -0
- package/dist/esm/services/PaymentService.js +1052 -0
- package/dist/esm/services/PlanService.js +1207 -0
- package/dist/esm/services/ProjectService.js +2526 -0
- package/dist/esm/services/PullRequestService.js +1284 -0
- package/dist/esm/services/ScreenshotService.js +1085 -0
- package/dist/esm/services/SubscriptionService.js +1177 -0
- package/dist/esm/services/TrackingService.js +18454 -0
- package/dist/esm/services/WaitlistService.js +929 -0
- package/dist/esm/services/index.js +47373 -18027
- package/dist/esm/state/RootStateManager.js +11 -23
- package/dist/esm/state/rootEventBus.js +9 -0
- package/dist/esm/utils/CollabClient.js +17526 -16120
- package/dist/esm/utils/TokenManager.js +16 -3
- package/dist/esm/utils/changePreprocessor.js +542 -0
- package/dist/esm/utils/jsonDiff.js +958 -43
- package/dist/esm/utils/ordering.js +291 -0
- package/dist/esm/utils/services.js +285 -128
- package/dist/esm/utils/validation.js +116 -50
- package/dist/node/config/environment.js +94 -10
- package/dist/node/index.js +183 -16
- package/dist/node/services/AdminService.js +332 -0
- package/dist/node/services/AuthService.js +742 -310
- package/dist/node/services/BaseService.js +148 -6
- package/dist/node/services/BranchService.js +465 -0
- package/dist/node/services/CollabService.js +439 -116
- package/dist/node/services/DnsService.js +321 -0
- package/dist/node/services/FeatureFlagService.js +156 -0
- package/dist/node/services/FileService.js +182 -0
- package/dist/node/services/IntegrationService.js +519 -0
- package/dist/node/services/MetricsService.js +43 -0
- package/dist/node/services/PaymentService.js +252 -0
- package/dist/node/services/PlanService.js +407 -0
- package/dist/node/services/ProjectService.js +1188 -0
- package/dist/node/services/PullRequestService.js +484 -0
- package/dist/node/services/ScreenshotService.js +285 -0
- package/dist/node/services/SubscriptionService.js +377 -0
- package/dist/node/services/TrackingService.js +632 -0
- package/dist/node/services/WaitlistService.js +129 -0
- package/dist/node/services/index.js +60 -4
- package/dist/node/state/RootStateManager.js +2 -23
- package/dist/node/state/rootEventBus.js +9 -0
- package/dist/node/utils/CollabClient.js +77 -11
- package/dist/node/utils/TokenManager.js +16 -3
- package/dist/node/utils/changePreprocessor.js +180 -0
- package/dist/node/utils/jsonDiff.js +46 -4
- package/dist/node/utils/ordering.js +290 -0
- package/dist/node/utils/services.js +285 -128
- package/dist/node/utils/validation.js +0 -3
- package/package.json +30 -18
- package/src/config/environment.js +95 -10
- package/src/index.js +190 -23
- package/src/services/AdminService.js +374 -0
- package/src/services/AuthService.js +874 -328
- package/src/services/BaseService.js +166 -6
- package/src/services/BranchService.js +536 -0
- package/src/services/CollabService.js +557 -148
- package/src/services/DnsService.js +366 -0
- package/src/services/FeatureFlagService.js +174 -0
- package/src/services/FileService.js +213 -0
- package/src/services/IntegrationService.js +548 -0
- package/src/services/MetricsService.js +40 -0
- package/src/services/PaymentService.js +287 -0
- package/src/services/PlanService.js +468 -0
- package/src/services/ProjectService.js +1366 -0
- package/src/services/PullRequestService.js +537 -0
- package/src/services/ScreenshotService.js +258 -0
- package/src/services/SubscriptionService.js +425 -0
- package/src/services/TrackingService.js +853 -0
- package/src/services/WaitlistService.js +130 -0
- package/src/services/index.js +79 -5
- package/src/services/tests/BranchService/createBranch.test.js +153 -0
- package/src/services/tests/BranchService/deleteBranch.test.js +173 -0
- package/src/services/tests/BranchService/getBranchChanges.test.js +146 -0
- package/src/services/tests/BranchService/listBranches.test.js +87 -0
- package/src/services/tests/BranchService/mergeBranch.test.js +210 -0
- package/src/services/tests/BranchService/publishVersion.test.js +183 -0
- package/src/services/tests/BranchService/renameBranch.test.js +240 -0
- package/src/services/tests/BranchService/resetBranch.test.js +152 -0
- package/src/services/tests/FeatureFlagService/adminFeatureFlags.test.js +67 -0
- package/src/services/tests/FeatureFlagService/getFeatureFlags.test.js +75 -0
- package/src/services/tests/FileService/createFileFormData.test.js +74 -0
- package/src/services/tests/FileService/getFileUrl.test.js +69 -0
- package/src/services/tests/FileService/updateProjectIcon.test.js +109 -0
- package/src/services/tests/FileService/uploadDocument.test.js +36 -0
- package/src/services/tests/FileService/uploadFile.test.js +78 -0
- package/src/services/tests/FileService/uploadFileWithValidation.test.js +114 -0
- package/src/services/tests/FileService/uploadImage.test.js +36 -0
- package/src/services/tests/FileService/uploadMultipleFiles.test.js +111 -0
- package/src/services/tests/FileService/validateFile.test.js +63 -0
- package/src/services/tests/PlanService/createPlan.test.js +104 -0
- package/src/services/tests/PlanService/createPlanWithValidation.test.js +523 -0
- package/src/services/tests/PlanService/deletePlan.test.js +92 -0
- package/src/services/tests/PlanService/getActivePlans.test.js +123 -0
- package/src/services/tests/PlanService/getAdminPlans.test.js +84 -0
- package/src/services/tests/PlanService/getPlan.test.js +50 -0
- package/src/services/tests/PlanService/getPlanByKey.test.js +109 -0
- package/src/services/tests/PlanService/getPlanWithValidation.test.js +85 -0
- package/src/services/tests/PlanService/getPlans.test.js +53 -0
- package/src/services/tests/PlanService/getPlansByPriceRange.test.js +109 -0
- package/src/services/tests/PlanService/getPlansWithValidation.test.js +48 -0
- package/src/services/tests/PlanService/initializePlans.test.js +75 -0
- package/src/services/tests/PlanService/updatePlan.test.js +111 -0
- package/src/services/tests/PlanService/updatePlanWithValidation.test.js +556 -0
- package/src/state/RootStateManager.js +37 -32
- package/src/state/rootEventBus.js +19 -0
- package/src/utils/CollabClient.js +99 -12
- package/src/utils/TokenManager.js +20 -3
- package/src/utils/changePreprocessor.js +239 -0
- package/src/utils/jsonDiff.js +40 -5
- package/src/utils/ordering.js +271 -0
- package/src/utils/services.js +306 -139
- package/src/utils/validation.js +0 -3
- package/dist/cjs/services/AIService.js +0 -155
- package/dist/cjs/services/BasedService.js +0 -1185
- package/dist/cjs/services/CoreService.js +0 -2295
- package/dist/cjs/services/SocketService.js +0 -309
- package/dist/cjs/services/SymstoryService.js +0 -571
- package/dist/cjs/utils/basedQuerys.js +0 -181
- package/dist/cjs/utils/symstoryClient.js +0 -259
- package/dist/esm/services/AIService.js +0 -185
- package/dist/esm/services/BasedService.js +0 -5262
- package/dist/esm/services/CoreService.js +0 -2827
- package/dist/esm/services/SocketService.js +0 -456
- package/dist/esm/services/SymstoryService.js +0 -7025
- package/dist/esm/utils/basedQuerys.js +0 -163
- package/dist/esm/utils/symstoryClient.js +0 -354
- package/dist/node/services/AIService.js +0 -136
- package/dist/node/services/BasedService.js +0 -1156
- package/dist/node/services/CoreService.js +0 -2266
- package/dist/node/services/SocketService.js +0 -280
- package/dist/node/services/SymstoryService.js +0 -542
- package/dist/node/utils/basedQuerys.js +0 -162
- package/dist/node/utils/symstoryClient.js +0 -230
- package/src/services/AIService.js +0 -150
- package/src/services/BasedService.js +0 -1302
- package/src/services/CoreService.js +0 -2548
- package/src/services/SocketService.js +0 -336
- package/src/services/SymstoryService.js +0 -649
- package/src/utils/basedQuerys.js +0 -164
- package/src/utils/symstoryClient.js +0 -252
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { BaseService } from './BaseService.js'
|
|
2
|
+
|
|
3
|
+
export class WaitlistService extends BaseService {
|
|
4
|
+
// ==================== WAITLIST METHODS ====================
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Join a waitlist campaign (public).
|
|
8
|
+
*
|
|
9
|
+
* Mirrors: POST /waitlist (WaitlistController.join)
|
|
10
|
+
*/
|
|
11
|
+
async joinWaitlist (data = {}) {
|
|
12
|
+
this._requireReady('joinWaitlist')
|
|
13
|
+
if (!data || typeof data !== 'object') {
|
|
14
|
+
throw new Error('Waitlist join payload is required')
|
|
15
|
+
}
|
|
16
|
+
if (!data.email) {
|
|
17
|
+
throw new Error('Email is required')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const response = await this._request('/waitlist', {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
body: JSON.stringify(data),
|
|
24
|
+
methodName: 'joinWaitlist'
|
|
25
|
+
})
|
|
26
|
+
if (response.success) {
|
|
27
|
+
return response.data
|
|
28
|
+
}
|
|
29
|
+
throw new Error(response.message)
|
|
30
|
+
} catch (error) {
|
|
31
|
+
throw new Error(`Failed to join waitlist: ${error.message}`, { cause: error })
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* List waitlist entries (admin).
|
|
37
|
+
*
|
|
38
|
+
* Mirrors: GET /waitlist (WaitlistController.list)
|
|
39
|
+
*/
|
|
40
|
+
async listWaitlistEntries (options = {}) {
|
|
41
|
+
this._requireReady('listWaitlistEntries')
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
campaignKey,
|
|
45
|
+
status,
|
|
46
|
+
search,
|
|
47
|
+
page,
|
|
48
|
+
limit
|
|
49
|
+
} = options || {}
|
|
50
|
+
|
|
51
|
+
const queryParams = new URLSearchParams()
|
|
52
|
+
if (campaignKey != null) { queryParams.append('campaignKey', String(campaignKey)) }
|
|
53
|
+
if (status != null) { queryParams.append('status', String(status)) }
|
|
54
|
+
if (search != null) { queryParams.append('search', String(search)) }
|
|
55
|
+
if (page != null) { queryParams.append('page', String(page)) }
|
|
56
|
+
if (limit != null) { queryParams.append('limit', String(limit)) }
|
|
57
|
+
|
|
58
|
+
const queryString = queryParams.toString()
|
|
59
|
+
const url = `/waitlist${queryString ? `?${queryString}` : ''}`
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
const response = await this._request(url, {
|
|
63
|
+
method: 'GET',
|
|
64
|
+
methodName: 'listWaitlistEntries'
|
|
65
|
+
})
|
|
66
|
+
if (response.success) {
|
|
67
|
+
return response.data
|
|
68
|
+
}
|
|
69
|
+
throw new Error(response.message)
|
|
70
|
+
} catch (error) {
|
|
71
|
+
throw new Error(`Failed to list waitlist entries: ${error.message}`, { cause: error })
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Update a waitlist entry (admin).
|
|
77
|
+
*
|
|
78
|
+
* Mirrors: PATCH /waitlist/:id (WaitlistController.update)
|
|
79
|
+
*/
|
|
80
|
+
async updateWaitlistEntry (id, update = {}) {
|
|
81
|
+
this._requireReady('updateWaitlistEntry')
|
|
82
|
+
if (!id) {
|
|
83
|
+
throw new Error('Waitlist entry ID is required')
|
|
84
|
+
}
|
|
85
|
+
if (!update || typeof update !== 'object') {
|
|
86
|
+
throw new Error('Update payload is required')
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
const response = await this._request(`/waitlist/${id}`, {
|
|
91
|
+
method: 'PATCH',
|
|
92
|
+
body: JSON.stringify(update),
|
|
93
|
+
methodName: 'updateWaitlistEntry'
|
|
94
|
+
})
|
|
95
|
+
if (response.success) {
|
|
96
|
+
return response.data
|
|
97
|
+
}
|
|
98
|
+
throw new Error(response.message)
|
|
99
|
+
} catch (error) {
|
|
100
|
+
throw new Error(`Failed to update waitlist entry: ${error.message}`, { cause: error })
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Send an invitation email for a waitlist entry (admin).
|
|
106
|
+
*
|
|
107
|
+
* Mirrors: POST /waitlist/:id/invite (WaitlistController.invite)
|
|
108
|
+
*/
|
|
109
|
+
async inviteWaitlistEntry (id) {
|
|
110
|
+
this._requireReady('inviteWaitlistEntry')
|
|
111
|
+
if (!id) {
|
|
112
|
+
throw new Error('Waitlist entry ID is required')
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
const response = await this._request(`/waitlist/${id}/invite`, {
|
|
117
|
+
method: 'POST',
|
|
118
|
+
methodName: 'inviteWaitlistEntry'
|
|
119
|
+
})
|
|
120
|
+
if (response.success) {
|
|
121
|
+
return response.data
|
|
122
|
+
}
|
|
123
|
+
throw new Error(response.message)
|
|
124
|
+
} catch (error) {
|
|
125
|
+
throw new Error(`Failed to invite waitlist entry: ${error.message}`, { cause: error })
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// End
|
package/src/services/index.js
CHANGED
|
@@ -1,16 +1,90 @@
|
|
|
1
|
-
|
|
2
1
|
import { AuthService } from './AuthService.js'
|
|
3
|
-
import { CoreService } from './CoreService.js'
|
|
4
2
|
import { CollabService } from './CollabService.js'
|
|
3
|
+
import { ProjectService } from './ProjectService.js'
|
|
4
|
+
import { PlanService } from './PlanService.js'
|
|
5
|
+
import { SubscriptionService } from './SubscriptionService.js'
|
|
6
|
+
import { FileService } from './FileService.js'
|
|
7
|
+
import { PaymentService } from './PaymentService.js'
|
|
8
|
+
import { DnsService } from './DnsService.js'
|
|
9
|
+
import { BranchService } from './BranchService.js'
|
|
10
|
+
import { PullRequestService } from './PullRequestService.js'
|
|
11
|
+
import { AdminService } from './AdminService.js'
|
|
12
|
+
import { ScreenshotService } from './ScreenshotService.js'
|
|
13
|
+
import { TrackingService } from './TrackingService.js'
|
|
14
|
+
import { WaitlistService } from './WaitlistService.js'
|
|
15
|
+
import { MetricsService } from './MetricsService.js'
|
|
16
|
+
import { IntegrationService } from './IntegrationService.js'
|
|
17
|
+
import { FeatureFlagService } from './FeatureFlagService.js'
|
|
5
18
|
|
|
6
19
|
const createService = (ServiceClass, config) => new ServiceClass(config)
|
|
7
20
|
|
|
8
21
|
// Export service creators
|
|
9
22
|
export const createAuthService = config => createService(AuthService, config)
|
|
10
23
|
|
|
11
|
-
export const createCoreService = config => createService(CoreService, config)
|
|
12
|
-
|
|
13
24
|
export const createCollabService = config =>
|
|
14
25
|
createService(CollabService, config)
|
|
15
26
|
|
|
16
|
-
export
|
|
27
|
+
export const createProjectService = config =>
|
|
28
|
+
createService(ProjectService, config)
|
|
29
|
+
|
|
30
|
+
export const createPlanService = config =>
|
|
31
|
+
createService(PlanService, config)
|
|
32
|
+
|
|
33
|
+
export const createSubscriptionService = config =>
|
|
34
|
+
createService(SubscriptionService, config)
|
|
35
|
+
|
|
36
|
+
export const createFileService = config =>
|
|
37
|
+
createService(FileService, config)
|
|
38
|
+
|
|
39
|
+
export const createPaymentService = config =>
|
|
40
|
+
createService(PaymentService, config)
|
|
41
|
+
|
|
42
|
+
export const createDnsService = config =>
|
|
43
|
+
createService(DnsService, config)
|
|
44
|
+
|
|
45
|
+
export const createBranchService = config =>
|
|
46
|
+
createService(BranchService, config)
|
|
47
|
+
|
|
48
|
+
export const createPullRequestService = config =>
|
|
49
|
+
createService(PullRequestService, config)
|
|
50
|
+
|
|
51
|
+
export const createAdminService = config =>
|
|
52
|
+
createService(AdminService, config)
|
|
53
|
+
|
|
54
|
+
export const createScreenshotService = config =>
|
|
55
|
+
createService(ScreenshotService, config)
|
|
56
|
+
|
|
57
|
+
export const createTrackingService = config =>
|
|
58
|
+
createService(TrackingService, config)
|
|
59
|
+
|
|
60
|
+
export const createWaitlistService = config =>
|
|
61
|
+
createService(WaitlistService, config)
|
|
62
|
+
|
|
63
|
+
export const createMetricsService = config =>
|
|
64
|
+
createService(MetricsService, config)
|
|
65
|
+
|
|
66
|
+
export const createIntegrationService = config =>
|
|
67
|
+
createService(IntegrationService, config)
|
|
68
|
+
|
|
69
|
+
export const createFeatureFlagService = config =>
|
|
70
|
+
createService(FeatureFlagService, config)
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
AuthService,
|
|
74
|
+
CollabService,
|
|
75
|
+
ProjectService,
|
|
76
|
+
PlanService,
|
|
77
|
+
SubscriptionService,
|
|
78
|
+
FileService,
|
|
79
|
+
PaymentService,
|
|
80
|
+
DnsService,
|
|
81
|
+
BranchService,
|
|
82
|
+
PullRequestService,
|
|
83
|
+
AdminService,
|
|
84
|
+
ScreenshotService,
|
|
85
|
+
TrackingService,
|
|
86
|
+
WaitlistService,
|
|
87
|
+
MetricsService,
|
|
88
|
+
IntegrationService,
|
|
89
|
+
FeatureFlagService
|
|
90
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/* eslint-disable no-undefined */
|
|
2
|
+
import test from 'tape'
|
|
3
|
+
import sinon from 'sinon'
|
|
4
|
+
import { BranchService } from '../../BranchService.js'
|
|
5
|
+
|
|
6
|
+
// #region Setup
|
|
7
|
+
const sandbox = sinon.createSandbox()
|
|
8
|
+
// #endregion
|
|
9
|
+
|
|
10
|
+
// #region Tests
|
|
11
|
+
test('createBranch should return response data', async t => {
|
|
12
|
+
t.plan(1)
|
|
13
|
+
const responseStub = {
|
|
14
|
+
success: true,
|
|
15
|
+
data: 'Test data response'
|
|
16
|
+
}
|
|
17
|
+
const branchDataMock = {
|
|
18
|
+
name: 'Test_Branch_Name',
|
|
19
|
+
source: 'main'
|
|
20
|
+
}
|
|
21
|
+
const testProjectId = 'Test Project ID'
|
|
22
|
+
const branchServiceStub = new BranchService()
|
|
23
|
+
sandbox.stub(branchServiceStub, '_requireReady').resolves()
|
|
24
|
+
sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
|
|
25
|
+
const response = await branchServiceStub.createBranch(
|
|
26
|
+
testProjectId,
|
|
27
|
+
branchDataMock
|
|
28
|
+
)
|
|
29
|
+
t.equal(
|
|
30
|
+
response,
|
|
31
|
+
responseStub.data,
|
|
32
|
+
'Actual response matches expected response'
|
|
33
|
+
)
|
|
34
|
+
sandbox.restore()
|
|
35
|
+
t.end()
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
function checkProjectIdValidation () {
|
|
39
|
+
const badData = [
|
|
40
|
+
{
|
|
41
|
+
testName: 'No Project ID'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
testName: 'Empty string',
|
|
45
|
+
projectId: ''
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
testName: 'False boolean value',
|
|
49
|
+
projectId: false
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
testName: 'Undefined value',
|
|
53
|
+
projectId: undefined
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
testName: 'Null value',
|
|
57
|
+
projectId: null
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
for (let ii = 0; ii < badData.length; ii++) {
|
|
61
|
+
test(`Project ID validation should throw an error when: ${badData[ii].testName} is passed in`, async t => {
|
|
62
|
+
t.plan(1)
|
|
63
|
+
const responseStub = {
|
|
64
|
+
success: true,
|
|
65
|
+
data: 'Test data response'
|
|
66
|
+
}
|
|
67
|
+
const branchDataMock = {
|
|
68
|
+
name: 'Test_Branch_Name',
|
|
69
|
+
source: 'main'
|
|
70
|
+
}
|
|
71
|
+
const testProjectId = badData[ii].projectId
|
|
72
|
+
const branchServiceStub = new BranchService()
|
|
73
|
+
sandbox.stub(branchServiceStub, '_requireReady').resolves()
|
|
74
|
+
sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
|
|
75
|
+
try {
|
|
76
|
+
await branchServiceStub.createBranch(testProjectId, branchDataMock)
|
|
77
|
+
t.fail('Project ID validation threw an error with an invalid value')
|
|
78
|
+
} catch (err) {
|
|
79
|
+
t.equal(
|
|
80
|
+
err.toString(),
|
|
81
|
+
'Error: Project ID is required',
|
|
82
|
+
`Project ID validation successfully threw an error with: ${badData[ii].testName}`
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
sandbox.restore()
|
|
86
|
+
t.end()
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function checkBranchDataNameValidation () {
|
|
92
|
+
const badData = [
|
|
93
|
+
{
|
|
94
|
+
testName: 'No name'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
testName: 'Empty string',
|
|
98
|
+
name: ''
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
testName: 'False boolean value',
|
|
102
|
+
name: false
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
testName: 'Undefined value',
|
|
106
|
+
name: undefined
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
testName: 'Null value',
|
|
110
|
+
name: null
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
for (let ii = 0; ii < badData.length; ii++) {
|
|
114
|
+
test(`Branch name validation should throw an error when: ${badData[ii].testName} is passed in`, async t => {
|
|
115
|
+
t.plan(1)
|
|
116
|
+
const responseStub = {
|
|
117
|
+
success: true,
|
|
118
|
+
data: 'Test data response'
|
|
119
|
+
}
|
|
120
|
+
const branchName = {
|
|
121
|
+
name: badData[ii].name,
|
|
122
|
+
source: 'main'
|
|
123
|
+
}
|
|
124
|
+
const testProjectId = 'Test Project ID'
|
|
125
|
+
const branchServiceStub = new BranchService()
|
|
126
|
+
sandbox.stub(branchServiceStub, '_requireReady').resolves()
|
|
127
|
+
sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
|
|
128
|
+
try {
|
|
129
|
+
await branchServiceStub.createBranch(testProjectId, branchName)
|
|
130
|
+
t.fail('Branch name validation threw an error with an invalid value')
|
|
131
|
+
} catch (err) {
|
|
132
|
+
t.equal(
|
|
133
|
+
err.toString(),
|
|
134
|
+
'Error: Branch name is required',
|
|
135
|
+
`Branch name validation successfully threw an error with: ${badData[ii].testName}`
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
sandbox.restore()
|
|
139
|
+
t.end()
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
checkBranchDataNameValidation()
|
|
145
|
+
checkProjectIdValidation()
|
|
146
|
+
// #endregion
|
|
147
|
+
|
|
148
|
+
// #region Cleanup
|
|
149
|
+
test('teardown', t => {
|
|
150
|
+
sandbox.restore()
|
|
151
|
+
t.end()
|
|
152
|
+
})
|
|
153
|
+
// #endregion
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/* eslint-disable no-undefined */
|
|
2
|
+
import test from 'tape'
|
|
3
|
+
import sinon from 'sinon'
|
|
4
|
+
import { BranchService } from '../../BranchService.js'
|
|
5
|
+
|
|
6
|
+
// #region Setup
|
|
7
|
+
const sandbox = sinon.createSandbox()
|
|
8
|
+
// #endregion
|
|
9
|
+
|
|
10
|
+
// #region Tests
|
|
11
|
+
test('deleteBranch should return response data', async t => {
|
|
12
|
+
t.plan(2)
|
|
13
|
+
const responseStub = {
|
|
14
|
+
success: true,
|
|
15
|
+
data: 'Test data response'
|
|
16
|
+
}
|
|
17
|
+
const branchDataMock = {
|
|
18
|
+
name: 'Test_Branch_Name',
|
|
19
|
+
branch: 'not_main'
|
|
20
|
+
}
|
|
21
|
+
const testProjectId = 'Test Project ID'
|
|
22
|
+
const branchServiceStub = new BranchService()
|
|
23
|
+
sandbox.stub(branchServiceStub, '_requireReady').resolves()
|
|
24
|
+
sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
|
|
25
|
+
const response = await branchServiceStub.deleteBranch(
|
|
26
|
+
testProjectId,
|
|
27
|
+
branchDataMock.branch
|
|
28
|
+
)
|
|
29
|
+
t.ok(response.success, 'Response successfully returned')
|
|
30
|
+
t.equal(
|
|
31
|
+
response.data,
|
|
32
|
+
responseStub.data,
|
|
33
|
+
'Actual response matches expected response'
|
|
34
|
+
)
|
|
35
|
+
sandbox.restore()
|
|
36
|
+
t.end()
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
test('Branch name validation should throw an error when the branch is main', async t => {
|
|
40
|
+
t.plan(1)
|
|
41
|
+
const responseStub = {
|
|
42
|
+
success: true,
|
|
43
|
+
data: 'Test data response'
|
|
44
|
+
}
|
|
45
|
+
const branchServiceStub = new BranchService()
|
|
46
|
+
sandbox.stub(branchServiceStub, '_requireReady').resolves()
|
|
47
|
+
sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
|
|
48
|
+
try {
|
|
49
|
+
await branchServiceStub.deleteBranch('Test Project ID', 'main')
|
|
50
|
+
t.fail('Branch name validation threw an error with an invalid value')
|
|
51
|
+
} catch (err) {
|
|
52
|
+
t.equal(
|
|
53
|
+
err.toString(),
|
|
54
|
+
'Error: Cannot delete main branch',
|
|
55
|
+
'deleteBranch successfully threw an error when the main branch is deleted'
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
sandbox.restore()
|
|
59
|
+
t.end()
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
function checkProjectIdValidation () {
|
|
63
|
+
const badData = [
|
|
64
|
+
{
|
|
65
|
+
testName: 'No Project ID'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
testName: 'Empty string',
|
|
69
|
+
projectId: ''
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
testName: 'False boolean value',
|
|
73
|
+
projectId: false
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
testName: 'Undefined value',
|
|
77
|
+
projectId: undefined
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
testName: 'Null value',
|
|
81
|
+
projectId: null
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
for (let ii = 0; ii < badData.length; ii++) {
|
|
85
|
+
test(`Project ID validation should throw an error when: ${badData[ii].testName} is passed in`, async t => {
|
|
86
|
+
t.plan(1)
|
|
87
|
+
const responseStub = {
|
|
88
|
+
success: true,
|
|
89
|
+
data: 'Test data response'
|
|
90
|
+
}
|
|
91
|
+
const branchDataMock = {
|
|
92
|
+
name: 'Test_Branch_Name',
|
|
93
|
+
branch: 'not_main'
|
|
94
|
+
}
|
|
95
|
+
const testProjectId = badData[ii].projectId
|
|
96
|
+
const branchServiceStub = new BranchService()
|
|
97
|
+
sandbox.stub(branchServiceStub, '_requireReady').resolves()
|
|
98
|
+
sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
|
|
99
|
+
try {
|
|
100
|
+
await branchServiceStub.deleteBranch(testProjectId, branchDataMock)
|
|
101
|
+
t.fail('Project ID validation threw an error with an invalid value')
|
|
102
|
+
} catch (err) {
|
|
103
|
+
t.equal(
|
|
104
|
+
err.toString(),
|
|
105
|
+
'Error: Project ID is required',
|
|
106
|
+
`Project ID validation successfully threw an error with: ${badData[ii].testName}`
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
sandbox.restore()
|
|
110
|
+
t.end()
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function checkBranchDataNameValidation () {
|
|
116
|
+
const badData = [
|
|
117
|
+
{
|
|
118
|
+
testName: 'No name'
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
testName: 'Empty string',
|
|
122
|
+
name: ''
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
testName: 'False boolean value',
|
|
126
|
+
name: false
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
testName: 'Undefined value',
|
|
130
|
+
name: undefined
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
testName: 'Null value',
|
|
134
|
+
name: null
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
for (let ii = 0; ii < badData.length; ii++) {
|
|
138
|
+
test(`Branch name validation should throw an error when: ${badData[ii].testName} is passed in`, async t => {
|
|
139
|
+
t.plan(1)
|
|
140
|
+
const responseStub = {
|
|
141
|
+
success: true,
|
|
142
|
+
data: 'Test data response'
|
|
143
|
+
}
|
|
144
|
+
const testProjectId = 'Test Project ID'
|
|
145
|
+
const branchServiceStub = new BranchService()
|
|
146
|
+
sandbox.stub(branchServiceStub, '_requireReady').resolves()
|
|
147
|
+
sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
|
|
148
|
+
try {
|
|
149
|
+
await branchServiceStub.deleteBranch(testProjectId, badData[ii].name)
|
|
150
|
+
t.fail('Branch name validation threw an error with an invalid value')
|
|
151
|
+
} catch (err) {
|
|
152
|
+
t.equal(
|
|
153
|
+
err.toString(),
|
|
154
|
+
'Error: Branch name is required',
|
|
155
|
+
`Branch name validation successfully threw an error with: ${badData[ii].testName}`
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
sandbox.restore()
|
|
159
|
+
t.end()
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
checkBranchDataNameValidation()
|
|
165
|
+
checkProjectIdValidation()
|
|
166
|
+
// #endregion
|
|
167
|
+
|
|
168
|
+
// #region Cleanup
|
|
169
|
+
test('teardown', t => {
|
|
170
|
+
sandbox.restore()
|
|
171
|
+
t.end()
|
|
172
|
+
})
|
|
173
|
+
// #endregion
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/* eslint-disable no-undefined */
|
|
2
|
+
import test from 'tape'
|
|
3
|
+
import sinon from 'sinon'
|
|
4
|
+
import { BranchService } from '../../BranchService.js'
|
|
5
|
+
|
|
6
|
+
// #region Setup
|
|
7
|
+
const sandbox = sinon.createSandbox()
|
|
8
|
+
// #endregion
|
|
9
|
+
|
|
10
|
+
// #region Tests
|
|
11
|
+
test('getBranchChanges should return response data', async (t) => {
|
|
12
|
+
t.plan(1)
|
|
13
|
+
const responseStub = {
|
|
14
|
+
success: true,
|
|
15
|
+
data: 'Test data response'
|
|
16
|
+
}
|
|
17
|
+
const branchDataMock = {
|
|
18
|
+
name: 'Test_Branch_Name'
|
|
19
|
+
}
|
|
20
|
+
const testProjectId = 'Test Project ID'
|
|
21
|
+
const branchServiceStub = new BranchService()
|
|
22
|
+
sandbox.stub(branchServiceStub, '_requireReady').resolves()
|
|
23
|
+
sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
|
|
24
|
+
const response = await branchServiceStub.getBranchChanges(
|
|
25
|
+
testProjectId,
|
|
26
|
+
branchDataMock.name
|
|
27
|
+
)
|
|
28
|
+
t.equal(
|
|
29
|
+
response,
|
|
30
|
+
responseStub.data,
|
|
31
|
+
'Actual response matches expected response'
|
|
32
|
+
)
|
|
33
|
+
sandbox.restore()
|
|
34
|
+
t.end()
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
function checkProjectIdValidation () {
|
|
38
|
+
const badData = [
|
|
39
|
+
{
|
|
40
|
+
testName: 'No Project ID'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
testName: 'Empty string',
|
|
44
|
+
projectId: ''
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
testName: 'False boolean value',
|
|
48
|
+
projectId: false
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
testName: 'Undefined value',
|
|
52
|
+
projectId: undefined
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
testName: 'Null value',
|
|
56
|
+
projectId: null
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
for (let ii = 0; ii < badData.length; ii++) {
|
|
60
|
+
test(`Project ID validation should throw an error when: ${badData[ii].testName} is passed in`, async (t) => {
|
|
61
|
+
t.plan(1)
|
|
62
|
+
const responseStub = {
|
|
63
|
+
success: true,
|
|
64
|
+
data: 'Test data response'
|
|
65
|
+
}
|
|
66
|
+
const branchDataMock = {
|
|
67
|
+
name: 'Test_Branch_Name'
|
|
68
|
+
}
|
|
69
|
+
const testProjectId = badData[ii].projectId
|
|
70
|
+
const branchServiceStub = new BranchService()
|
|
71
|
+
sandbox.stub(branchServiceStub, '_requireReady').resolves()
|
|
72
|
+
sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
|
|
73
|
+
try {
|
|
74
|
+
await branchServiceStub.getBranchChanges(
|
|
75
|
+
testProjectId,
|
|
76
|
+
branchDataMock.name
|
|
77
|
+
)
|
|
78
|
+
t.fail('Project ID validation threw an error with an invalid value')
|
|
79
|
+
} catch (err) {
|
|
80
|
+
t.equal(
|
|
81
|
+
err.toString(),
|
|
82
|
+
'Error: Project ID is required',
|
|
83
|
+
`Project ID validation successfully threw an error with: ${badData[ii].testName}`
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
sandbox.restore()
|
|
87
|
+
t.end()
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function checkBranchDataNameValidation () {
|
|
93
|
+
const badData = [
|
|
94
|
+
{
|
|
95
|
+
testName: 'Empty string',
|
|
96
|
+
name: ''
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
testName: 'False boolean value',
|
|
100
|
+
name: false
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
testName: 'Null value',
|
|
104
|
+
name: null
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
for (let ii = 0; ii < badData.length; ii++) {
|
|
108
|
+
test(`Branch name validation should throw an error when: ${badData[ii].testName} is passed in`, async (t) => {
|
|
109
|
+
t.plan(1)
|
|
110
|
+
const responseStub = {
|
|
111
|
+
success: true,
|
|
112
|
+
data: 'Test data response'
|
|
113
|
+
}
|
|
114
|
+
const testProjectId = 'Test Project ID'
|
|
115
|
+
const branchServiceStub = new BranchService()
|
|
116
|
+
sandbox.stub(branchServiceStub, '_requireReady').resolves()
|
|
117
|
+
sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
|
|
118
|
+
try {
|
|
119
|
+
await branchServiceStub.getBranchChanges(
|
|
120
|
+
testProjectId,
|
|
121
|
+
badData[ii].name
|
|
122
|
+
)
|
|
123
|
+
t.fail('Branch name validation threw an error with an invalid value')
|
|
124
|
+
} catch (err) {
|
|
125
|
+
t.equal(
|
|
126
|
+
err.toString(),
|
|
127
|
+
'Error: Branch name is required',
|
|
128
|
+
`Branch name validation successfully threw an error with: ${badData[ii].testName}`
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
sandbox.restore()
|
|
132
|
+
t.end()
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
checkBranchDataNameValidation()
|
|
138
|
+
checkProjectIdValidation()
|
|
139
|
+
// #endregion
|
|
140
|
+
|
|
141
|
+
// #region Cleanup
|
|
142
|
+
test('teardown', (t) => {
|
|
143
|
+
sandbox.restore()
|
|
144
|
+
t.end()
|
|
145
|
+
})
|
|
146
|
+
// #endregion
|