@salesforce/core 4.0.0 → 4.0.1
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/LICENSE.txt +1 -1
- package/README.md +93 -44
- package/lib/config/aliasesConfig.d.ts +12 -0
- package/lib/config/aliasesConfig.js +28 -0
- package/lib/config/authInfoConfig.d.ts +19 -0
- package/lib/config/authInfoConfig.js +35 -0
- package/lib/config/config.d.ts +87 -22
- package/lib/config/config.js +117 -65
- package/lib/config/configAggregator.d.ts +41 -35
- package/lib/config/configAggregator.js +102 -73
- package/lib/config/configFile.d.ts +2 -2
- package/lib/config/configFile.js +38 -29
- package/lib/config/configGroup.d.ts +141 -0
- package/lib/config/configGroup.js +225 -0
- package/lib/config/configStore.d.ts +9 -9
- package/lib/config/configStore.js +17 -15
- package/lib/config/envVars.d.ts +15 -9
- package/lib/config/envVars.js +71 -47
- package/lib/config/orgUsersConfig.js +2 -0
- package/lib/config/sandboxOrgConfig.js +2 -0
- package/lib/config/sandboxProcessCache.d.ts +16 -0
- package/lib/config/sandboxProcessCache.js +38 -0
- package/lib/config/tokensConfig.d.ts +10 -0
- package/lib/config/tokensConfig.js +29 -0
- package/lib/config/ttlConfig.d.ts +34 -0
- package/lib/config/ttlConfig.js +50 -0
- package/lib/crypto/crypto.js +15 -22
- package/lib/crypto/keyChain.js +2 -3
- package/lib/crypto/keyChainImpl.d.ts +5 -3
- package/lib/crypto/keyChainImpl.js +58 -61
- package/lib/crypto/secureBuffer.d.ts +1 -1
- package/lib/deviceOauthService.d.ts +3 -3
- package/lib/deviceOauthService.js +27 -25
- package/lib/exported.d.ts +15 -12
- package/lib/exported.js +28 -16
- package/lib/global.d.ts +11 -3
- package/lib/global.js +39 -12
- package/lib/lifecycleEvents.d.ts +1 -1
- package/lib/lifecycleEvents.js +3 -0
- package/lib/logger.d.ts +19 -9
- package/lib/logger.js +112 -86
- package/lib/messages.d.ts +53 -36
- package/lib/messages.js +81 -91
- package/lib/org/authInfo.d.ts +56 -20
- package/lib/org/authInfo.js +232 -131
- package/lib/org/authRemover.d.ts +8 -7
- package/lib/org/authRemover.js +32 -28
- package/lib/org/connection.d.ts +13 -37
- package/lib/org/connection.js +78 -124
- package/lib/org/index.js +5 -1
- package/lib/org/org.d.ts +151 -48
- package/lib/org/org.js +466 -220
- package/lib/org/orgConfigProperties.d.ts +64 -3
- package/lib/org/orgConfigProperties.js +96 -4
- package/lib/org/permissionSetAssignment.js +4 -13
- package/lib/org/scratchOrgCache.d.ts +20 -0
- package/lib/org/scratchOrgCache.js +33 -0
- package/lib/org/scratchOrgCreate.d.ts +28 -17
- package/lib/org/scratchOrgCreate.js +125 -53
- package/lib/org/scratchOrgErrorCodes.d.ts +9 -3
- package/lib/org/scratchOrgErrorCodes.js +34 -17
- package/lib/org/scratchOrgFeatureDeprecation.js +1 -6
- package/lib/org/scratchOrgInfoApi.d.ts +21 -47
- package/lib/org/scratchOrgInfoApi.js +129 -63
- package/lib/org/scratchOrgInfoGenerator.d.ts +6 -5
- package/lib/org/scratchOrgInfoGenerator.js +76 -62
- package/lib/org/scratchOrgLifecycleEvents.d.ts +10 -0
- package/lib/org/scratchOrgLifecycleEvents.js +41 -0
- package/lib/org/scratchOrgSettingsGenerator.d.ts +44 -21
- package/lib/org/scratchOrgSettingsGenerator.js +165 -98
- package/lib/org/scratchOrgTypes.d.ts +43 -0
- package/lib/org/scratchOrgTypes.js +9 -0
- package/lib/org/user.d.ts +1 -1
- package/lib/org/user.js +25 -34
- package/lib/schema/printer.d.ts +6 -0
- package/lib/schema/printer.js +34 -31
- package/lib/schema/validator.d.ts +12 -10
- package/lib/schema/validator.js +56 -76
- package/lib/{sfdxError.d.ts → sfError.d.ts} +12 -20
- package/lib/{sfdxError.js → sfError.js} +40 -30
- package/lib/{sfdxProject.d.ts → sfProject.d.ts} +75 -35
- package/lib/sfProject.js +651 -0
- package/lib/{globalInfo → stateAggregator}/accessors/aliasAccessor.d.ts +27 -12
- package/lib/{globalInfo → stateAggregator}/accessors/aliasAccessor.js +47 -31
- package/lib/stateAggregator/accessors/orgAccessor.d.ts +101 -0
- package/lib/stateAggregator/accessors/orgAccessor.js +240 -0
- package/lib/stateAggregator/accessors/sandboxAccessor.d.ts +8 -0
- package/lib/stateAggregator/accessors/sandboxAccessor.js +28 -0
- package/lib/stateAggregator/accessors/tokenAccessor.d.ts +63 -0
- package/lib/stateAggregator/accessors/tokenAccessor.js +80 -0
- package/lib/stateAggregator/index.d.ts +4 -0
- package/lib/stateAggregator/index.js +27 -0
- package/lib/stateAggregator/stateAggregator.d.ts +25 -0
- package/lib/stateAggregator/stateAggregator.js +46 -0
- package/lib/status/myDomainResolver.d.ts +1 -1
- package/lib/status/myDomainResolver.js +4 -4
- package/lib/status/pollingClient.js +4 -4
- package/lib/status/streamingClient.d.ts +2 -2
- package/lib/status/streamingClient.js +58 -63
- package/lib/status/types.d.ts +2 -2
- package/lib/testSetup.d.ts +206 -75
- package/lib/testSetup.js +463 -165
- package/lib/util/cache.d.ts +2 -2
- package/lib/util/cache.js +6 -6
- package/lib/util/checkLightningDomain.js +3 -4
- package/lib/util/directoryWriter.d.ts +12 -0
- package/lib/util/directoryWriter.js +54 -0
- package/lib/util/getJwtAudienceUrl.js +1 -1
- package/lib/util/internal.d.ts +28 -2
- package/lib/util/internal.js +65 -8
- package/lib/util/jsonXmlTools.js +2 -4
- package/lib/util/mapKeys.d.ts +9 -9
- package/lib/util/mapKeys.js +13 -9
- package/lib/util/sfdc.d.ts +51 -51
- package/lib/util/sfdc.js +74 -79
- package/lib/util/sfdcUrl.d.ts +5 -19
- package/lib/util/sfdcUrl.js +40 -49
- package/lib/util/structuredWriter.d.ts +9 -0
- package/lib/util/structuredWriter.js +3 -0
- package/lib/util/zipWriter.d.ts +8 -6
- package/lib/util/zipWriter.js +13 -13
- package/lib/webOAuthServer.d.ts +20 -6
- package/lib/webOAuthServer.js +102 -56
- package/messageTransformer/messageTransformer.ts +93 -0
- package/messages/auth.md +9 -1
- package/messages/config.md +42 -6
- package/messages/connection.md +8 -0
- package/messages/core.md +10 -0
- package/messages/envVars.md +37 -3
- package/messages/org.md +21 -1
- package/messages/scratchOrgCreate.md +2 -6
- package/messages/scratchOrgErrorCodes.md +17 -1
- package/messages/scratchOrgInfoApi.md +9 -0
- package/messages/scratchOrgInfoGenerator.md +9 -1
- package/package.json +121 -46
- package/CHANGELOG.md +0 -1244
- package/lib/config/keychainConfig.d.ts +0 -19
- package/lib/config/keychainConfig.js +0 -43
- package/lib/globalInfo/accessors/orgAccessor.d.ts +0 -13
- package/lib/globalInfo/accessors/orgAccessor.js +0 -45
- package/lib/globalInfo/accessors/tokenAccessor.d.ts +0 -13
- package/lib/globalInfo/accessors/tokenAccessor.js +0 -35
- package/lib/globalInfo/globalInfoConfig.d.ts +0 -36
- package/lib/globalInfo/globalInfoConfig.js +0 -105
- package/lib/globalInfo/index.d.ts +0 -6
- package/lib/globalInfo/index.js +0 -29
- package/lib/globalInfo/sfdxDataHandler.d.ts +0 -43
- package/lib/globalInfo/sfdxDataHandler.js +0 -217
- package/lib/globalInfo/types.d.ts +0 -39
- package/lib/globalInfo/types.js +0 -10
- package/lib/sfdxProject.js +0 -557
- package/lib/util/fs.d.ts +0 -201
- package/lib/util/fs.js +0 -378
package/lib/testSetup.d.ts
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import
|
|
3
|
+
import { SinonSandbox, SinonStatic, SinonStub } from 'sinon';
|
|
4
4
|
import { AnyJson, JsonMap, Optional } from '@salesforce/ts-types';
|
|
5
5
|
import { ConfigContents } from './config/configStore';
|
|
6
|
+
import { Connection } from './org/connection';
|
|
6
7
|
import { Logger } from './logger';
|
|
7
|
-
import {
|
|
8
|
+
import { SfError } from './sfError';
|
|
8
9
|
import { CometClient, CometSubscription, Message, StreamingExtension } from './status/streamingClient';
|
|
9
|
-
import {
|
|
10
|
+
import { AuthFields, SandboxFields } from './org';
|
|
11
|
+
import { AliasGroup } from './config/aliasesConfig';
|
|
10
12
|
/**
|
|
11
13
|
* Different parts of the system that are mocked out. They can be restored for
|
|
12
14
|
* individual tests. Test's stubs should always go on the DEFAULT which is exposed
|
|
13
15
|
* on the TestContext.
|
|
14
16
|
*/
|
|
15
17
|
export interface SandboxTypes {
|
|
16
|
-
DEFAULT:
|
|
17
|
-
CRYPTO:
|
|
18
|
-
CONFIG:
|
|
19
|
-
PROJECT:
|
|
20
|
-
CONNECTION:
|
|
21
|
-
FS:
|
|
18
|
+
DEFAULT: SinonSandbox;
|
|
19
|
+
CRYPTO: SinonSandbox;
|
|
20
|
+
CONFIG: SinonSandbox;
|
|
21
|
+
PROJECT: SinonSandbox;
|
|
22
|
+
CONNECTION: SinonSandbox;
|
|
23
|
+
FS: SinonSandbox;
|
|
24
|
+
ORGS: SinonSandbox;
|
|
22
25
|
}
|
|
23
26
|
/**
|
|
24
27
|
* Different hooks into {@link ConfigFile} used for testing instead of doing file IO.
|
|
@@ -52,15 +55,15 @@ export interface ConfigStub {
|
|
|
52
55
|
updateContents?: () => Promise<JsonMap>;
|
|
53
56
|
}
|
|
54
57
|
/**
|
|
55
|
-
*
|
|
58
|
+
* Instantiate a @salesforce/core test context.
|
|
56
59
|
*/
|
|
57
|
-
export
|
|
60
|
+
export declare class TestContext {
|
|
58
61
|
/**
|
|
59
62
|
* The default sandbox is cleared out before each test run.
|
|
60
63
|
*
|
|
61
|
-
* **See** [sinon sandbox]{@link
|
|
64
|
+
* **See** [sinon sandbox]{@link https://sinonjs.org/releases/v14/sandbox/}.
|
|
62
65
|
*/
|
|
63
|
-
SANDBOX:
|
|
66
|
+
SANDBOX: SinonSandbox;
|
|
64
67
|
/**
|
|
65
68
|
* An object of different sandboxes. Used when
|
|
66
69
|
* needing to restore parts of the system for customized testing.
|
|
@@ -74,58 +77,69 @@ export interface TestContext {
|
|
|
74
77
|
* id A unique id for the test run.
|
|
75
78
|
*/
|
|
76
79
|
id: string;
|
|
77
|
-
/**
|
|
78
|
-
* A function that returns unique strings.
|
|
79
|
-
*/
|
|
80
|
-
uniqid: () => string;
|
|
81
80
|
/**
|
|
82
81
|
* An object used in tests that interact with config files.
|
|
83
82
|
*/
|
|
84
83
|
configStubs: {
|
|
85
84
|
[configName: string]: Optional<ConfigStub>;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
AliasesConfig?: ConfigStub;
|
|
86
|
+
AuthInfoConfig?: ConfigStub;
|
|
87
|
+
Config?: ConfigStub;
|
|
88
|
+
SfProjectJson?: ConfigStub;
|
|
89
|
+
TokensConfig?: ConfigStub;
|
|
90
|
+
OrgUsersConfig?: ConfigStub;
|
|
90
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* A record of stubs created during instantiation.
|
|
94
|
+
*/
|
|
95
|
+
stubs: Record<string, SinonStub>;
|
|
96
|
+
constructor(options?: {
|
|
97
|
+
sinon?: SinonStatic;
|
|
98
|
+
sandbox?: SinonSandbox;
|
|
99
|
+
setup?: boolean;
|
|
100
|
+
});
|
|
101
|
+
/**
|
|
102
|
+
* Generate unique string.
|
|
103
|
+
*/
|
|
104
|
+
uniqid(): string;
|
|
91
105
|
/**
|
|
92
106
|
* A function used when resolving the local path. Calls localPathResolverSync by default.
|
|
93
107
|
*
|
|
94
108
|
* @param uid Unique id.
|
|
95
109
|
*/
|
|
96
|
-
localPathRetriever
|
|
110
|
+
localPathRetriever(uid: string): Promise<string>;
|
|
97
111
|
/**
|
|
98
112
|
* A function used when resolving the local path.
|
|
99
113
|
*
|
|
100
114
|
* @param uid Unique id.
|
|
101
115
|
*/
|
|
102
|
-
localPathRetrieverSync
|
|
116
|
+
localPathRetrieverSync(uid: string): string;
|
|
103
117
|
/**
|
|
104
118
|
* A function used when resolving the global path. Calls globalPathResolverSync by default.
|
|
105
119
|
*
|
|
106
120
|
* @param uid Unique id.
|
|
107
121
|
*/
|
|
108
|
-
globalPathRetriever
|
|
122
|
+
globalPathRetriever(uid: string): Promise<string>;
|
|
109
123
|
/**
|
|
110
124
|
* A function used when resolving the global path.
|
|
111
125
|
*
|
|
112
126
|
* @param uid Unique id.
|
|
113
127
|
*/
|
|
114
|
-
globalPathRetrieverSync
|
|
128
|
+
globalPathRetrieverSync(uid: string): string;
|
|
115
129
|
/**
|
|
116
130
|
* A function used for resolving paths. Calls localPathRetriever and globalPathRetriever.
|
|
117
131
|
*
|
|
118
132
|
* @param isGlobal `true` if the config is global.
|
|
119
133
|
* @param uid user id.
|
|
120
134
|
*/
|
|
121
|
-
rootPathRetriever
|
|
135
|
+
rootPathRetriever(isGlobal: boolean, uid?: string): Promise<string>;
|
|
122
136
|
/**
|
|
123
137
|
* A function used for resolving paths. Calls localPathRetrieverSync and globalPathRetrieverSync.
|
|
124
138
|
*
|
|
125
139
|
* @param isGlobal `true` if the config is global.
|
|
126
140
|
* @param uid user id.
|
|
127
141
|
*/
|
|
128
|
-
rootPathRetrieverSync
|
|
142
|
+
rootPathRetrieverSync(isGlobal: boolean, uid?: string): string;
|
|
129
143
|
/**
|
|
130
144
|
* Used to mock http request to Salesforce.
|
|
131
145
|
*
|
|
@@ -134,7 +148,7 @@ export interface TestContext {
|
|
|
134
148
|
*
|
|
135
149
|
* **See** {@link Connection.request}
|
|
136
150
|
*/
|
|
137
|
-
fakeConnectionRequest
|
|
151
|
+
fakeConnectionRequest(request: AnyJson, options?: AnyJson): Promise<AnyJson>;
|
|
138
152
|
/**
|
|
139
153
|
* Gets a config stub contents by name.
|
|
140
154
|
*
|
|
@@ -149,8 +163,62 @@ export interface TestContext {
|
|
|
149
163
|
* @param value The actual stub contents. The Mock data.
|
|
150
164
|
*/
|
|
151
165
|
setConfigStubContents(name: string, value: ConfigContents): void;
|
|
152
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Set stubs for working in the context of a SfProject
|
|
168
|
+
*/
|
|
169
|
+
inProject(inProject?: boolean): void;
|
|
170
|
+
/**
|
|
171
|
+
* Stub salesforce org authorizations.
|
|
172
|
+
*/
|
|
173
|
+
stubAuths(...orgs: MockTestOrgData[]): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Stub salesforce user authorizations.
|
|
176
|
+
*
|
|
177
|
+
* @param users The users to stub.
|
|
178
|
+
* The key is the username of the admin user and it must be included in the users array in order to obtain the orgId key for the remaining users.
|
|
179
|
+
* The admin user is excluded from the users array.
|
|
180
|
+
*
|
|
181
|
+
*/
|
|
182
|
+
stubUsers(users: Record<string, MockTestOrgData[]>): void;
|
|
183
|
+
/**
|
|
184
|
+
* Stub salesforce sandbox authorizations.
|
|
185
|
+
*/
|
|
186
|
+
stubSandboxes(...sandboxes: MockTestSandboxData[]): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Stub the aliases in the global aliases config file.
|
|
189
|
+
*/
|
|
190
|
+
stubAliases(aliases: Record<string, string>, group?: AliasGroup): void;
|
|
191
|
+
/**
|
|
192
|
+
* Stub contents in the config file.
|
|
193
|
+
*/
|
|
194
|
+
stubConfig(config: Record<string, string>): Promise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* Stub the tokens in the global token config file.
|
|
197
|
+
*/
|
|
198
|
+
stubTokens(tokens: Record<string, string>): void;
|
|
199
|
+
restore(): void;
|
|
200
|
+
init(): void;
|
|
201
|
+
/**
|
|
202
|
+
* Add beforeEach and afterEach hooks to init the stubs and restore them.
|
|
203
|
+
* This is called automatically when the class is instantiated unless the setup option is set to false.
|
|
204
|
+
*/
|
|
205
|
+
setup(): void;
|
|
206
|
+
private requireSinon;
|
|
153
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* A function to generate a unique id and return it in the context of a template, if supplied.
|
|
210
|
+
*
|
|
211
|
+
* A template is a string that can contain `${%s}` to be replaced with a unique id.
|
|
212
|
+
* If the template contains the "%s" placeholder, it will be replaced with the unique id otherwise the id will be appended to the template.
|
|
213
|
+
*
|
|
214
|
+
* @param options an object with the following properties:
|
|
215
|
+
* - template: a template string.
|
|
216
|
+
* - length: the length of the unique id as presented in hexadecimal.
|
|
217
|
+
*/
|
|
218
|
+
export declare function uniqid(options?: {
|
|
219
|
+
template?: string;
|
|
220
|
+
length?: number;
|
|
221
|
+
}): string;
|
|
154
222
|
/**
|
|
155
223
|
* Instantiate a @salesforce/core test context. This is automatically created by `const $$ = testSetup()`
|
|
156
224
|
* but is useful if you don't want to have a global stub of @salesforce/core and you want to isolate it to
|
|
@@ -163,16 +231,16 @@ export interface TestContext {
|
|
|
163
231
|
* const $$ = instantiateContext();
|
|
164
232
|
*
|
|
165
233
|
* beforeEach(() => {
|
|
166
|
-
*
|
|
234
|
+
* $$.init()
|
|
167
235
|
* });
|
|
168
236
|
*
|
|
169
237
|
* afterEach(() => {
|
|
170
|
-
*
|
|
238
|
+
* $$.restore();
|
|
171
239
|
* });
|
|
172
240
|
* ```
|
|
173
241
|
* @param sinon
|
|
174
242
|
*/
|
|
175
|
-
export declare const instantiateContext: (sinon?:
|
|
243
|
+
export declare const instantiateContext: (sinon?: SinonStatic) => TestContext;
|
|
176
244
|
/**
|
|
177
245
|
* Stub a @salesforce/core test context. This will mock out logging to a file, config file reading and writing,
|
|
178
246
|
* local and global path resolution, and http request using connection (soon)*.
|
|
@@ -188,16 +256,16 @@ export declare const instantiateContext: (sinon?: any) => TestContext;
|
|
|
188
256
|
* const $$ = instantiateContext();
|
|
189
257
|
*
|
|
190
258
|
* beforeEach(() => {
|
|
191
|
-
*
|
|
259
|
+
* $$.init()
|
|
192
260
|
* });
|
|
193
261
|
*
|
|
194
262
|
* afterEach(() => {
|
|
195
|
-
*
|
|
263
|
+
* $$.restore();
|
|
196
264
|
* });
|
|
197
265
|
* ```
|
|
198
266
|
* @param testContext
|
|
199
267
|
*/
|
|
200
|
-
export declare const stubContext: (testContext: TestContext) =>
|
|
268
|
+
export declare const stubContext: (testContext: TestContext) => Record<string, SinonStub>;
|
|
201
269
|
/**
|
|
202
270
|
* Restore a @salesforce/core test context. This is automatically stubbed in the global beforeEach created by
|
|
203
271
|
* `const $$ = testSetup()` but is useful if you don't want to have a global stub of @salesforce/core and you
|
|
@@ -208,57 +276,28 @@ export declare const stubContext: (testContext: TestContext) => void;
|
|
|
208
276
|
* const $$ = instantiateContext();
|
|
209
277
|
*
|
|
210
278
|
* beforeEach(() => {
|
|
211
|
-
*
|
|
279
|
+
* $$.init()
|
|
212
280
|
* });
|
|
213
281
|
*
|
|
214
282
|
* afterEach(() => {
|
|
215
|
-
*
|
|
283
|
+
* $$.restore();
|
|
216
284
|
* });
|
|
217
285
|
* ```
|
|
218
286
|
* @param testContext
|
|
219
287
|
*/
|
|
220
288
|
export declare const restoreContext: (testContext: TestContext) => void;
|
|
221
|
-
/**
|
|
222
|
-
* Use to mock out different pieces of sfdx-core to make testing easier. This will mock out
|
|
223
|
-
* logging to a file, config file reading and writing, local and global path resolution, and
|
|
224
|
-
* *http request using connection (soon)*.
|
|
225
|
-
*
|
|
226
|
-
* **Note:** The testSetup should be outside of the describe. If you need to stub per test, use
|
|
227
|
-
* `instantiateContext`, `stubContext`, and `restoreContext`.
|
|
228
|
-
* ```
|
|
229
|
-
* // In a mocha tests
|
|
230
|
-
* import testSetup from '@salesforce/core/lib/testSetup';
|
|
231
|
-
*
|
|
232
|
-
* const $$ = testSetup();
|
|
233
|
-
*
|
|
234
|
-
* describe(() => {
|
|
235
|
-
* it('test', () => {
|
|
236
|
-
* // Stub out your own method
|
|
237
|
-
* $$.SANDBOX.stub(MyClass.prototype, 'myMethod').returnsFake(() => {});
|
|
238
|
-
*
|
|
239
|
-
* // Set the contents that is used when aliases are read. Same for all config files.
|
|
240
|
-
* $$.configStubs.Aliases = { contents: { 'myTestAlias': 'user@company.com' } };
|
|
241
|
-
*
|
|
242
|
-
* // Will use the contents set above.
|
|
243
|
-
* const username = Aliases.fetch('myTestAlias');
|
|
244
|
-
* expect(username).to.equal('user@company.com');
|
|
245
|
-
* });
|
|
246
|
-
* });
|
|
247
|
-
* ```
|
|
248
|
-
*/
|
|
249
|
-
export declare const testSetup: (sinon?: any) => TestContext;
|
|
250
289
|
/**
|
|
251
290
|
* A pre-canned error for try/catch testing.
|
|
252
291
|
*
|
|
253
292
|
* **See** {@link shouldThrow}
|
|
254
293
|
*/
|
|
255
|
-
export declare const unexpectedResult:
|
|
294
|
+
export declare const unexpectedResult: SfError;
|
|
256
295
|
/**
|
|
257
296
|
* Use for this testing pattern:
|
|
258
297
|
* ```
|
|
259
298
|
* try {
|
|
260
299
|
* await call()
|
|
261
|
-
* assert.fail(
|
|
300
|
+
* assert.fail("this should never happen");
|
|
262
301
|
* } catch (e) {
|
|
263
302
|
* ...
|
|
264
303
|
* }
|
|
@@ -274,7 +313,29 @@ export declare const unexpectedResult: SfdxError;
|
|
|
274
313
|
*
|
|
275
314
|
* @param f The async function that is expected to throw.
|
|
276
315
|
*/
|
|
277
|
-
export declare function shouldThrow(f: Promise<unknown
|
|
316
|
+
export declare function shouldThrow(f: Promise<unknown>, message?: string): Promise<never>;
|
|
317
|
+
/**
|
|
318
|
+
* Use for this testing pattern:
|
|
319
|
+
* ```
|
|
320
|
+
* try {
|
|
321
|
+
* call()
|
|
322
|
+
* assert.fail("this should never happen");
|
|
323
|
+
* } catch (e) {
|
|
324
|
+
* ...
|
|
325
|
+
* }
|
|
326
|
+
*
|
|
327
|
+
* Just do this
|
|
328
|
+
*
|
|
329
|
+
* try {
|
|
330
|
+
* shouldThrowSync(call); // If this succeeds unexpectedResultError is thrown.
|
|
331
|
+
* } catch(e) {
|
|
332
|
+
* ...
|
|
333
|
+
* }
|
|
334
|
+
* ```
|
|
335
|
+
*
|
|
336
|
+
* @param f The function that is expected to throw.
|
|
337
|
+
*/
|
|
338
|
+
export declare function shouldThrowSync(f: () => unknown, message?: string): never;
|
|
278
339
|
/**
|
|
279
340
|
* A helper to determine if a subscription will use callback or errorback.
|
|
280
341
|
* Enable errback to simulate a subscription failure.
|
|
@@ -302,7 +363,7 @@ export interface StreamingMockCometSubscriptionOptions {
|
|
|
302
363
|
/**
|
|
303
364
|
* If it's an error that states what that error should be.
|
|
304
365
|
*/
|
|
305
|
-
subscriptionErrbackError?:
|
|
366
|
+
subscriptionErrbackError?: SfError;
|
|
306
367
|
/**
|
|
307
368
|
* A list of messages to playback for the client. One message per process tick.
|
|
308
369
|
*/
|
|
@@ -372,12 +433,32 @@ export declare class StreamingMockCometClient extends CometClient {
|
|
|
372
433
|
*/
|
|
373
434
|
disconnect(): Promise<void>;
|
|
374
435
|
}
|
|
436
|
+
type MockUserInfo = {
|
|
437
|
+
Id: string;
|
|
438
|
+
Username: string;
|
|
439
|
+
LastName: string;
|
|
440
|
+
Alias: string;
|
|
441
|
+
Configs: string[] | undefined;
|
|
442
|
+
TimeZoneSidKey: string;
|
|
443
|
+
LocaleSidKey: string;
|
|
444
|
+
EmailEncodingKey: string;
|
|
445
|
+
ProfileId: string;
|
|
446
|
+
LanguageLocaleKey: string;
|
|
447
|
+
Email: string;
|
|
448
|
+
};
|
|
375
449
|
/**
|
|
376
|
-
* Mock class for
|
|
450
|
+
* Mock class for Salesforce Orgs.
|
|
451
|
+
*
|
|
452
|
+
* @example
|
|
453
|
+
* ```
|
|
454
|
+
* const testOrg = new MockTestOrgData();
|
|
455
|
+
* await $$.stubAuths(testOrg)
|
|
456
|
+
* ```
|
|
377
457
|
*/
|
|
378
458
|
export declare class MockTestOrgData {
|
|
379
459
|
testId: string;
|
|
380
|
-
|
|
460
|
+
aliases?: string[];
|
|
461
|
+
configs?: string[];
|
|
381
462
|
username: string;
|
|
382
463
|
devHubUsername?: string;
|
|
383
464
|
orgId: string;
|
|
@@ -387,15 +468,65 @@ export declare class MockTestOrgData {
|
|
|
387
468
|
clientSecret: string;
|
|
388
469
|
authcode: string;
|
|
389
470
|
accessToken: string;
|
|
390
|
-
refreshToken: string;
|
|
471
|
+
refreshToken: string | undefined;
|
|
472
|
+
tracksSource: boolean | undefined;
|
|
391
473
|
userId: string;
|
|
392
474
|
redirectUri: string;
|
|
475
|
+
isDevHub?: boolean;
|
|
476
|
+
isScratchOrg?: boolean;
|
|
477
|
+
isExpired?: boolean | 'unknown';
|
|
478
|
+
password?: string;
|
|
393
479
|
constructor(id?: string, options?: {
|
|
394
480
|
username: string;
|
|
395
481
|
});
|
|
482
|
+
/**
|
|
483
|
+
* Add devhub username to properties.
|
|
484
|
+
*/
|
|
396
485
|
createDevHubUsername(username: string): void;
|
|
486
|
+
/**
|
|
487
|
+
* Mark this org as a devhub.
|
|
488
|
+
*/
|
|
397
489
|
makeDevHub(): void;
|
|
490
|
+
/**
|
|
491
|
+
* Returns a MockTestOrgData that represents a user created in the org.
|
|
492
|
+
*/
|
|
398
493
|
createUser(user: string): MockTestOrgData;
|
|
399
|
-
|
|
400
|
-
|
|
494
|
+
/**
|
|
495
|
+
* Return mock user information based on this org.
|
|
496
|
+
*/
|
|
497
|
+
getMockUserInfo(): MockUserInfo;
|
|
498
|
+
/**
|
|
499
|
+
* Return the auth config file contents.
|
|
500
|
+
*/
|
|
501
|
+
getConfig(): Promise<AuthFields>;
|
|
502
|
+
/**
|
|
503
|
+
* Return the Connection for the org.
|
|
504
|
+
*/
|
|
505
|
+
getConnection(): Promise<Connection>;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Mock class for Salesforce Sandboxes.
|
|
509
|
+
*
|
|
510
|
+
* @example
|
|
511
|
+
* ```
|
|
512
|
+
* const testOrg = new MockTestSandboxData();
|
|
513
|
+
* await $$.stubSandboxes(testOrg)
|
|
514
|
+
* ```
|
|
515
|
+
*/
|
|
516
|
+
export declare class MockTestSandboxData {
|
|
517
|
+
id: string;
|
|
518
|
+
sandboxOrgId: string;
|
|
519
|
+
prodOrgUsername: string;
|
|
520
|
+
sandboxName?: string;
|
|
521
|
+
username?: string;
|
|
522
|
+
constructor(id?: string, options?: Partial<{
|
|
523
|
+
prodOrgUsername: string;
|
|
524
|
+
name: string;
|
|
525
|
+
username: string;
|
|
526
|
+
}>);
|
|
527
|
+
/**
|
|
528
|
+
* Return the auth config file contents.
|
|
529
|
+
*/
|
|
530
|
+
getConfig(): Promise<SandboxFields>;
|
|
401
531
|
}
|
|
532
|
+
export {};
|