generated from salesforcecli/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update app:create to take an --appdescription flags (#249)
feat: update autoinstall:app:create to take --appname and --appdescription flags
- Loading branch information
1 parent
821380e
commit d6746cd
Showing
8 changed files
with
141 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,6 +179,49 @@ describe('analytics:app:create', () => { | |
}); | ||
}); | ||
|
||
test | ||
.withOrg({ username: '[email protected]' }, true) | ||
.withConnectionRequest(request => { | ||
request = ensureJsonMap(request); | ||
if (request.method === 'GET') { | ||
// call for all templates | ||
return Promise.resolve({ | ||
templates: [testTemplateJson, sustainabilityTemplateJson] | ||
}); | ||
} | ||
if (request.method === 'POST') { | ||
saveOffRequestBody(request.body as string); | ||
return Promise.resolve({ id: appId }); | ||
} | ||
return Promise.reject(); | ||
}) | ||
.stdout() | ||
.command([ | ||
'analytics:app:create', | ||
'--templatename', | ||
'Sustainability', | ||
'--appname', | ||
'customname', | ||
'--appdescription', | ||
'customdesc', | ||
'--async' | ||
]) | ||
.it( | ||
'runs analytics:app:create --templatename Sustainability --appname customname --appdescription customdesc --async', | ||
ctx => { | ||
expect(ctx.stdout).to.contain(messages.getMessage('createAppSuccessAsync', [appId])); | ||
expect(requestBody, 'requestBody').to.not.be.undefined; | ||
expect(requestBody, 'requestBody').to.include({ | ||
// request body should have values from the templates GET | ||
templateSourceId: sustainabilityTemplateJson.id, | ||
// but name and label should come from the cli arg | ||
label: 'customname', | ||
name: 'customname', | ||
description: 'customdesc' | ||
}); | ||
} | ||
); | ||
|
||
test | ||
.withOrg({ username: '[email protected]' }, true) | ||
.withConnectionRequest(request => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import { UX } from '@salesforce/command'; | |
import * as core from '@salesforce/core'; | ||
import { expect, test } from '@salesforce/command/lib/test'; | ||
import { SfdxError } from '@salesforce/core'; | ||
import { JsonMap } from '@salesforce/ts-types'; | ||
import { AnyJson, ensureJsonMap, ensureString, JsonMap } from '@salesforce/ts-types'; | ||
import { AutoInstallRequestType, AutoInstallStatus } from '../../../../src/lib/analytics/autoinstall/autoinstall'; | ||
|
||
core.Messages.importMessagesDirectory(__dirname); | ||
|
@@ -32,10 +32,21 @@ function stubTimeout(callback?: () => unknown) { | |
} | ||
|
||
describe('analytics:autoinstall:app:create', () => { | ||
let requestBody: AnyJson | undefined; | ||
function saveOffRequestBody(json: string | undefined) { | ||
requestBody = undefined; | ||
try { | ||
requestBody = json && (JSON.parse(json) as AnyJson); | ||
} catch (e) { | ||
expect.fail('Error parsing request body: ' + (e instanceof Error ? e.message : String(e))); | ||
} | ||
} | ||
|
||
// use this so we can have return different values from withConnectionRequest() to simulate polling | ||
let requestNum: number; | ||
beforeEach(() => { | ||
requestNum = 0; | ||
requestBody = undefined; | ||
}); | ||
|
||
test | ||
|
@@ -261,4 +272,32 @@ describe('analytics:autoinstall:app:create', () => { | |
.it('runs analytics:autoinstall:app:create with error during polling', ctx => { | ||
expect(ctx.stderr).to.contain('expected error in polling'); | ||
}); | ||
|
||
// Test that --appname and --appdescription values appear in the request body | ||
test | ||
.withOrg({ username: '[email protected]' }, true) | ||
.withConnectionRequest(async request => { | ||
request = ensureJsonMap(request); | ||
saveOffRequestBody(ensureString(request.body)); | ||
return requestWithStatus('New'); | ||
}) | ||
.stdout() | ||
.command([ | ||
'analytics:autoinstall:app:create', | ||
'--async', | ||
'-n', | ||
'abc', | ||
'--appname', | ||
'customname', | ||
'--appdescription', | ||
'customdesc' | ||
]) | ||
.it('runs analytics:autoinstall:app:create --async --appname customname --appdescription customdesc', ctx => { | ||
expect(ctx.stdout).to.contain(messages.getMessage('appCreateRequestSuccess', ['0UZxx0000004FzkGAE'])); | ||
expect(requestBody, 'requestBody').to.have.nested.include({ | ||
'configuration.appConfiguration.appLabel': 'customname', | ||
'configuration.appConfiguration.appName': 'customname', | ||
'configuration.appConfiguration.appDescription': 'customdesc' | ||
}); | ||
}); | ||
}); |