@symbo.ls/sdk 2.34.6 → 2.34.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/dist/cjs/index.js +24 -0
- package/dist/cjs/services/BranchService.js +4 -4
- package/dist/cjs/services/IntegrationService.js +538 -0
- package/dist/cjs/services/MetricsService.js +62 -0
- package/dist/cjs/services/PaymentService.js +1 -1
- package/dist/cjs/services/PullRequestService.js +8 -6
- package/dist/cjs/services/WaitlistService.js +148 -0
- package/dist/cjs/services/index.js +13 -1
- package/dist/cjs/utils/services.js +26 -1
- package/dist/esm/index.js +751 -12
- package/dist/esm/services/BranchService.js +4 -4
- package/dist/esm/services/IntegrationService.js +1319 -0
- package/dist/esm/services/MetricsService.js +843 -0
- package/dist/esm/services/PaymentService.js +1 -1
- package/dist/esm/services/PullRequestService.js +8 -6
- package/dist/esm/services/WaitlistService.js +929 -0
- package/dist/esm/services/index.js +708 -12
- package/dist/esm/utils/services.js +26 -1
- package/dist/node/index.js +32 -2
- package/dist/node/services/BranchService.js +4 -4
- package/dist/node/services/IntegrationService.js +519 -0
- package/dist/node/services/MetricsService.js +43 -0
- package/dist/node/services/PaymentService.js +1 -1
- package/dist/node/services/PullRequestService.js +8 -6
- package/dist/node/services/WaitlistService.js +129 -0
- package/dist/node/services/index.js +13 -1
- package/dist/node/utils/services.js +26 -1
- package/package.json +8 -7
- package/src/index.js +40 -13
- package/src/services/BranchService.js +5 -5
- package/src/services/IntegrationService.js +548 -0
- package/src/services/MetricsService.js +40 -0
- package/src/services/PaymentService.js +1 -1
- package/src/services/PullRequestService.js +6 -6
- package/src/services/WaitlistService.js +130 -0
- package/src/services/index.js +16 -2
- 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/uploadMultipleFiles.test.js +111 -0
- package/src/services/tests/FileService/validateFile.test.js +63 -0
- package/src/services/tests/PlanService/getActivePlans.test.js +0 -2
- package/src/utils/services.js +29 -1
|
@@ -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,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import { AuthService } from './AuthService.js'
|
|
3
2
|
import { CollabService } from './CollabService.js'
|
|
4
3
|
import { ProjectService } from './ProjectService.js'
|
|
@@ -12,6 +11,9 @@ import { PullRequestService } from './PullRequestService.js'
|
|
|
12
11
|
import { AdminService } from './AdminService.js'
|
|
13
12
|
import { ScreenshotService } from './ScreenshotService.js'
|
|
14
13
|
import { TrackingService } from './TrackingService.js'
|
|
14
|
+
import { WaitlistService } from './WaitlistService.js'
|
|
15
|
+
import { MetricsService } from './MetricsService.js'
|
|
16
|
+
import { IntegrationService } from './IntegrationService.js'
|
|
15
17
|
|
|
16
18
|
const createService = (ServiceClass, config) => new ServiceClass(config)
|
|
17
19
|
|
|
@@ -54,6 +56,15 @@ export const createScreenshotService = config =>
|
|
|
54
56
|
export const createTrackingService = config =>
|
|
55
57
|
createService(TrackingService, config)
|
|
56
58
|
|
|
59
|
+
export const createWaitlistService = config =>
|
|
60
|
+
createService(WaitlistService, config)
|
|
61
|
+
|
|
62
|
+
export const createMetricsService = config =>
|
|
63
|
+
createService(MetricsService, config)
|
|
64
|
+
|
|
65
|
+
export const createIntegrationService = config =>
|
|
66
|
+
createService(IntegrationService, config)
|
|
67
|
+
|
|
57
68
|
export {
|
|
58
69
|
AuthService,
|
|
59
70
|
CollabService,
|
|
@@ -67,5 +78,8 @@ export {
|
|
|
67
78
|
PullRequestService,
|
|
68
79
|
AdminService,
|
|
69
80
|
ScreenshotService,
|
|
70
|
-
TrackingService
|
|
81
|
+
TrackingService,
|
|
82
|
+
WaitlistService,
|
|
83
|
+
MetricsService,
|
|
84
|
+
IntegrationService
|
|
71
85
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import test from 'tape'
|
|
2
|
+
import { FileService } from '../../FileService.js'
|
|
3
|
+
|
|
4
|
+
// #region Tests
|
|
5
|
+
test('createFileFormData should return a basic formData object', t => {
|
|
6
|
+
t.plan(3)
|
|
7
|
+
const mockFileData = {
|
|
8
|
+
size: 13,
|
|
9
|
+
type: 'text/*',
|
|
10
|
+
name: 'filename.txt'
|
|
11
|
+
}
|
|
12
|
+
const mockFile = new File(['file contents'], mockFileData.name, {
|
|
13
|
+
type: mockFileData.type
|
|
14
|
+
})
|
|
15
|
+
const fileServiceStub = new FileService()
|
|
16
|
+
const response = fileServiceStub.createFileFormData(mockFile)
|
|
17
|
+
t.equal(
|
|
18
|
+
Array.from(response)[0][1].size,
|
|
19
|
+
mockFileData.size,
|
|
20
|
+
'Actual file size matches expected file size'
|
|
21
|
+
)
|
|
22
|
+
t.equal(
|
|
23
|
+
Array.from(response)[0][1].type,
|
|
24
|
+
mockFileData.type,
|
|
25
|
+
'Actual file type matches expected file type'
|
|
26
|
+
)
|
|
27
|
+
t.equal(
|
|
28
|
+
Array.from(response)[0][1].name,
|
|
29
|
+
mockFileData.name,
|
|
30
|
+
'Actual file name matches expected file name'
|
|
31
|
+
)
|
|
32
|
+
t.end()
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
test('createFileFormData should return a formData object with metadata', t => {
|
|
36
|
+
t.plan(4)
|
|
37
|
+
const mockFileData = {
|
|
38
|
+
size: 13,
|
|
39
|
+
type: 'text/*',
|
|
40
|
+
name: 'filename.txt'
|
|
41
|
+
}
|
|
42
|
+
const mockFile = new File(['file contents'], mockFileData.name, {
|
|
43
|
+
type: mockFileData.type
|
|
44
|
+
})
|
|
45
|
+
const mockMetaData = {
|
|
46
|
+
name: 'Test Name',
|
|
47
|
+
description: 'Test Description',
|
|
48
|
+
key: 'Test Key'
|
|
49
|
+
}
|
|
50
|
+
const fileServiceStub = new FileService()
|
|
51
|
+
const response = fileServiceStub.createFileFormData(mockFile, mockMetaData)
|
|
52
|
+
t.equal(
|
|
53
|
+
Array.from(response)[0][1].size,
|
|
54
|
+
mockFileData.size,
|
|
55
|
+
'Actual file size matches expected file size'
|
|
56
|
+
)
|
|
57
|
+
t.equal(
|
|
58
|
+
Array.from(response)[0][1].type,
|
|
59
|
+
mockFileData.type,
|
|
60
|
+
'Actual file type matches expected file type'
|
|
61
|
+
)
|
|
62
|
+
t.equal(
|
|
63
|
+
Array.from(response)[0][1].name,
|
|
64
|
+
mockFileData.name,
|
|
65
|
+
'Actual file name matches expected file name'
|
|
66
|
+
)
|
|
67
|
+
t.equal(
|
|
68
|
+
Array.from(response)[1][1],
|
|
69
|
+
JSON.stringify(mockMetaData),
|
|
70
|
+
'Actual metadata matches expected metadata'
|
|
71
|
+
)
|
|
72
|
+
t.end()
|
|
73
|
+
})
|
|
74
|
+
// #endregion
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* eslint-disable no-undefined */
|
|
2
|
+
import test from 'tape'
|
|
3
|
+
import { FileService } from '../../FileService.js'
|
|
4
|
+
import { BaseService } from '../../BaseService.js'
|
|
5
|
+
|
|
6
|
+
// #region Tests
|
|
7
|
+
test('getFileUrl should return a good file url', t => {
|
|
8
|
+
t.plan(1)
|
|
9
|
+
const mockFileId = 'testFileId'
|
|
10
|
+
const fileServiceStub = new FileService()
|
|
11
|
+
const baseServiceStub = new BaseService()
|
|
12
|
+
const response = fileServiceStub.getFileUrl(mockFileId)
|
|
13
|
+
t.equal(
|
|
14
|
+
response,
|
|
15
|
+
`${baseServiceStub._apiUrl}/core/files/public/${mockFileId}/download`,
|
|
16
|
+
'Actual file url matches expected file url'
|
|
17
|
+
)
|
|
18
|
+
t.end()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
function testFileIdValidation () {
|
|
22
|
+
const badData = [
|
|
23
|
+
{
|
|
24
|
+
name: 'Empty String',
|
|
25
|
+
fileId: ''
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'Undefined',
|
|
29
|
+
fileId: undefined
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'Null',
|
|
33
|
+
fileId: null
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'False boolean value',
|
|
37
|
+
fileId: false
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'True boolean value',
|
|
41
|
+
fileId: true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'Object',
|
|
45
|
+
fileId: {}
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
for (let ii = 0; ii < badData.length; ii++) {
|
|
49
|
+
test(`fileId validation should throw an error when fileId value is: ${badData[ii].name}`, t => {
|
|
50
|
+
t.plan(1)
|
|
51
|
+
const mockFileId = null
|
|
52
|
+
const fileServiceStub = new FileService()
|
|
53
|
+
try {
|
|
54
|
+
fileServiceStub.getFileUrl(mockFileId)
|
|
55
|
+
t.fail('file ID successfully threw an error')
|
|
56
|
+
} catch (err) {
|
|
57
|
+
t.equal(
|
|
58
|
+
err.toString(),
|
|
59
|
+
'Error: File ID is required',
|
|
60
|
+
`file ID validation successfully threw an error when fileId is: ${badData[ii].name}`
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
t.end()
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
testFileIdValidation()
|
|
69
|
+
// #endregion
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* eslint-disable no-undefined */
|
|
2
|
+
import test from 'tape'
|
|
3
|
+
import sinon from 'sinon'
|
|
4
|
+
import { FileService } from '../../FileService.js'
|
|
5
|
+
|
|
6
|
+
// #region Setup
|
|
7
|
+
const sandbox = sinon.createSandbox()
|
|
8
|
+
// #endregion
|
|
9
|
+
|
|
10
|
+
// #region Tests
|
|
11
|
+
test('uploadMultipleFiles should return response data', async t => {
|
|
12
|
+
t.plan(3)
|
|
13
|
+
const uploadFileResponseStub = {
|
|
14
|
+
success: true,
|
|
15
|
+
data: 'test data response'
|
|
16
|
+
}
|
|
17
|
+
const firstMockFile = new File(['file contents'], 'filename.txt', {
|
|
18
|
+
type: 'text/*'
|
|
19
|
+
})
|
|
20
|
+
const secondMockFile = new File(['file contents'], 'filename1.txt', {
|
|
21
|
+
type: 'text/*'
|
|
22
|
+
})
|
|
23
|
+
const files = [firstMockFile, secondMockFile]
|
|
24
|
+
const fileServiceStub = new FileService()
|
|
25
|
+
sandbox.stub(fileServiceStub, 'uploadFile').resolves(uploadFileResponseStub)
|
|
26
|
+
const response = await fileServiceStub.uploadMultipleFiles(files)
|
|
27
|
+
t.equal(
|
|
28
|
+
response.length,
|
|
29
|
+
2,
|
|
30
|
+
'Actual number of uploaded files matches expected number of files'
|
|
31
|
+
)
|
|
32
|
+
t.ok(
|
|
33
|
+
response[0].success,
|
|
34
|
+
'response for first file uploaded successfully returned'
|
|
35
|
+
)
|
|
36
|
+
t.ok(
|
|
37
|
+
response[1].success,
|
|
38
|
+
'response for second file uploaded successfully returned'
|
|
39
|
+
)
|
|
40
|
+
sandbox.restore()
|
|
41
|
+
t.end()
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
test('file validation should throw an error when no file is uploaded', async t => {
|
|
45
|
+
t.plan(1)
|
|
46
|
+
const uploadFileResponseStub = {
|
|
47
|
+
success: true,
|
|
48
|
+
data: 'test data response'
|
|
49
|
+
}
|
|
50
|
+
const fileServiceStub = new FileService()
|
|
51
|
+
sandbox.stub(fileServiceStub, 'uploadFile').resolves(uploadFileResponseStub)
|
|
52
|
+
try {
|
|
53
|
+
await fileServiceStub.uploadMultipleFiles()
|
|
54
|
+
t.fail('file validation successfully threw an error')
|
|
55
|
+
} catch (err) {
|
|
56
|
+
t.equal(
|
|
57
|
+
err.toString(),
|
|
58
|
+
'Error: Files array is required and must not be empty',
|
|
59
|
+
'file validation successfully threw an error when no file was uploaded.'
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
sandbox.restore()
|
|
63
|
+
t.end()
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
function checkFileTypeValidation () {
|
|
67
|
+
const badData = [
|
|
68
|
+
{ name: 'Number value', value: 123 },
|
|
69
|
+
{ name: 'False boolean value', value: false },
|
|
70
|
+
{ name: 'True boolean value', value: true },
|
|
71
|
+
{ name: 'Empty String value', value: '' },
|
|
72
|
+
{ name: 'Object value', value: {} },
|
|
73
|
+
{ name: 'Null value', value: null },
|
|
74
|
+
{ name: 'Undefined value', value: undefined }
|
|
75
|
+
]
|
|
76
|
+
for (let ii = 0; ii < badData.length; ii++) {
|
|
77
|
+
test(`file validation should throw an error when: ${badData[ii].name} is uploaded`, async t => {
|
|
78
|
+
t.plan(1)
|
|
79
|
+
const uploadFileResponseStub = {
|
|
80
|
+
success: true,
|
|
81
|
+
data: 'test data response'
|
|
82
|
+
}
|
|
83
|
+
const fileServiceStub = new FileService()
|
|
84
|
+
sandbox
|
|
85
|
+
.stub(fileServiceStub, 'uploadFile')
|
|
86
|
+
.resolves(uploadFileResponseStub)
|
|
87
|
+
try {
|
|
88
|
+
await fileServiceStub.uploadMultipleFiles(badData[ii].value)
|
|
89
|
+
t.fail('file validation successfully threw an error')
|
|
90
|
+
} catch (err) {
|
|
91
|
+
t.equal(
|
|
92
|
+
err.toString(),
|
|
93
|
+
'Error: Files array is required and must not be empty',
|
|
94
|
+
`file validation successfully threw an error when: ${badData[ii].name} was uploaded.`
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
sandbox.restore()
|
|
98
|
+
t.end()
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
checkFileTypeValidation()
|
|
104
|
+
// #endregion
|
|
105
|
+
|
|
106
|
+
// #region Cleanup
|
|
107
|
+
test('teardown', t => {
|
|
108
|
+
sandbox.restore()
|
|
109
|
+
t.end()
|
|
110
|
+
})
|
|
111
|
+
// #endregion
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import test from 'tape'
|
|
2
|
+
import { FileService } from '../../FileService.js'
|
|
3
|
+
|
|
4
|
+
// #region Tests
|
|
5
|
+
test('validateFile should return a good file url', t => {
|
|
6
|
+
t.plan(1)
|
|
7
|
+
const mockFile = new File(['file contents'], 'filename.txt', {
|
|
8
|
+
type: 'text/*'
|
|
9
|
+
})
|
|
10
|
+
const fileServiceStub = new FileService()
|
|
11
|
+
const response = fileServiceStub.validateFile(mockFile)
|
|
12
|
+
t.ok(response.length === 0, 'Empty array of errors is succesfully returned')
|
|
13
|
+
t.end()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test('file validation should return an error', t => {
|
|
17
|
+
t.plan(1)
|
|
18
|
+
const mockFile = false
|
|
19
|
+
const fileServiceStub = new FileService()
|
|
20
|
+
const response = fileServiceStub.validateFile(mockFile)
|
|
21
|
+
t.equal(
|
|
22
|
+
response[0],
|
|
23
|
+
'File is required',
|
|
24
|
+
'File validation successfully threw an error'
|
|
25
|
+
)
|
|
26
|
+
t.end()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test('size validation should return an error', t => {
|
|
30
|
+
t.plan(1)
|
|
31
|
+
const mockFile = new File(['file contents'], 'filename.txt', {
|
|
32
|
+
type: 'text/*'
|
|
33
|
+
})
|
|
34
|
+
const mockOptions = {
|
|
35
|
+
maxSize: 1
|
|
36
|
+
}
|
|
37
|
+
const fileServiceStub = new FileService()
|
|
38
|
+
const response = fileServiceStub.validateFile(mockFile, mockOptions)
|
|
39
|
+
t.ok(
|
|
40
|
+
response[0].includes('File size (0.00MB) exceeds maximum allowed size of '),
|
|
41
|
+
'Size validation successfully threw an error'
|
|
42
|
+
)
|
|
43
|
+
t.end()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
test('allowedTypes validation should return an error', t => {
|
|
47
|
+
t.plan(1)
|
|
48
|
+
const mockFile = new File(['file contents'], 'filename.txt', {
|
|
49
|
+
type: 'text/*'
|
|
50
|
+
})
|
|
51
|
+
const mockOptions = {
|
|
52
|
+
allowedTypes: ['test123']
|
|
53
|
+
}
|
|
54
|
+
const fileServiceStub = new FileService()
|
|
55
|
+
const response = fileServiceStub.validateFile(mockFile, mockOptions)
|
|
56
|
+
t.equal(
|
|
57
|
+
response[0],
|
|
58
|
+
"File type 'text/*' is not allowed. Allowed types: test123",
|
|
59
|
+
'allowedTypes validation should return an error'
|
|
60
|
+
)
|
|
61
|
+
t.end()
|
|
62
|
+
})
|
|
63
|
+
// #endregion
|
|
@@ -103,8 +103,6 @@ function planFilter () {
|
|
|
103
103
|
const planServiceStub = new PlanService()
|
|
104
104
|
sandbox.stub(planServiceStub, 'getPlans').resolves([badPlans[ii]])
|
|
105
105
|
const response = await planServiceStub.getActivePlans()
|
|
106
|
-
console.log('&&& response: ', response)
|
|
107
|
-
|
|
108
106
|
t.equal(
|
|
109
107
|
response.length,
|
|
110
108
|
0,
|
package/src/utils/services.js
CHANGED
|
@@ -293,5 +293,33 @@ export const SERVICE_METHODS = {
|
|
|
293
293
|
flushQueue: 'tracking',
|
|
294
294
|
getClient: 'tracking',
|
|
295
295
|
isEnabled: 'tracking',
|
|
296
|
-
isInitialized: 'tracking'
|
|
296
|
+
isInitialized: 'tracking',
|
|
297
|
+
|
|
298
|
+
// Waitlist methods
|
|
299
|
+
joinWaitlist: 'waitlist',
|
|
300
|
+
listWaitlistEntries: 'waitlist',
|
|
301
|
+
updateWaitlistEntry: 'waitlist',
|
|
302
|
+
inviteWaitlistEntry: 'waitlist',
|
|
303
|
+
|
|
304
|
+
// Metrics methods
|
|
305
|
+
getContributions: 'metrics',
|
|
306
|
+
|
|
307
|
+
// Integration methods
|
|
308
|
+
integrationWhoami: 'integration',
|
|
309
|
+
listIntegrations: 'integration',
|
|
310
|
+
createIntegration: 'integration',
|
|
311
|
+
updateIntegration: 'integration',
|
|
312
|
+
createIntegrationApiKey: 'integration',
|
|
313
|
+
listIntegrationApiKeys: 'integration',
|
|
314
|
+
revokeIntegrationApiKey: 'integration',
|
|
315
|
+
createIntegrationWebhook: 'integration',
|
|
316
|
+
listIntegrationWebhooks: 'integration',
|
|
317
|
+
updateIntegrationWebhook: 'integration',
|
|
318
|
+
deleteIntegrationWebhook: 'integration',
|
|
319
|
+
listIntegrationWebhookDeliveries: 'integration',
|
|
320
|
+
replayIntegrationWebhookDelivery: 'integration',
|
|
321
|
+
listGitHubConnectors: 'integration',
|
|
322
|
+
createGitHubConnector: 'integration',
|
|
323
|
+
updateGitHubConnector: 'integration',
|
|
324
|
+
deleteGitHubConnector: 'integration'
|
|
297
325
|
}
|