generated from salesforcecli/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: nuts fail for email/reports (#208)
* test: nuts fail for email/reports * test: add a few more inFolder tests * chore: bump SDR version * fix: eslint * fix: update yarn.lock * chore: remove generated NUTs dir during clean * chore: bump SDR version Co-authored-by: Steve Hetzel <[email protected]> Co-authored-by: Cristian Dominguez <[email protected]>
- Loading branch information
1 parent
99df1ca
commit bacee13
Showing
4 changed files
with
128 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
* Copyright (c) 2020, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; | ||
import { expect } from 'chai'; | ||
import { FileResponse } from '@salesforce/source-deploy-retrieve'; | ||
import { DeployCommandResult } from '../../src/formatters/deployResultFormatter'; | ||
import { RetrieveCommandResult } from '../../src/formatters/retrieveResultFormatter'; | ||
|
||
describe('metadata types that go in folders', () => { | ||
let session: TestSession; | ||
|
||
before(async () => { | ||
session = await TestSession.create({ | ||
project: { | ||
gitClone: 'https://github.com/mshanemc/nestedFolders', | ||
}, | ||
setupCommands: [ | ||
'sfdx force:org:create -f config/project-scratch-def.json --setdefaultusername --wait 10 --durationdays 1', | ||
], | ||
}); | ||
}); | ||
|
||
after(async () => { | ||
await session?.clean(); | ||
}); | ||
|
||
describe('emailTemplates', () => { | ||
after(async () => { | ||
await fs.promises.unlink(path.join(session.project.dir, 'package.xml')); | ||
}); | ||
|
||
const getExpectedSource = (state: 'Created' | 'Changed') => [ | ||
{ | ||
fullName: 'Top_Level_Folder', | ||
type: 'EmailFolder', | ||
state, | ||
filePath: path.join('default', 'email', 'Top_Level_Folder.emailFolder-meta.xml'), | ||
}, | ||
{ | ||
fullName: 'Top_Level_Folder/Template_in_folder', | ||
type: 'EmailTemplate', | ||
state, | ||
filePath: path.join('email', 'Top_Level_Folder', 'Template_in_folder.email'), | ||
}, | ||
{ | ||
fullName: 'Top_Level_Folder/Template_in_folder', | ||
type: 'EmailTemplate', | ||
state, | ||
filePath: path.join('email', 'Top_Level_Folder', 'Template_in_folder.email-meta.xml'), | ||
}, | ||
{ | ||
fullName: 'unfiled$public/Top_level_email', | ||
type: 'EmailTemplate', | ||
state, | ||
filePath: path.join('email', 'unfiled$public', 'Top_level_email.email'), | ||
}, | ||
{ | ||
fullName: 'unfiled$public/Top_level_email', | ||
type: 'EmailTemplate', | ||
state, | ||
filePath: path.join('email', 'unfiled$public', 'Top_level_email.email-meta.xml'), | ||
}, | ||
]; | ||
|
||
const getRelativeFileResponses = (resp: FileResponse[]) => { | ||
return resp.map((s) => { | ||
// grab the last 2 directories with the file only | ||
s.filePath = s.filePath.split(path.sep).slice(-3).join(path.sep); | ||
return s; | ||
}); | ||
}; | ||
|
||
it('can generate manifest for just the emailTemplates', () => { | ||
const pathToEmails = path.join('force-app', 'main', 'default', 'email'); | ||
execCmd(`force:source:manifest:create -p ${pathToEmails} --json`, { ensureExitCode: 0 }); | ||
expect(fs.existsSync(path.join(session.project.dir, 'package.xml'))).to.be.true; | ||
}); | ||
|
||
it('can deploy email templates via the manifest', () => { | ||
const deployResults = execCmd<DeployCommandResult>('force:source:deploy -x package.xml --json').jsonOutput; | ||
expect(deployResults.status, JSON.stringify(deployResults)).to.equal(0); | ||
const deployedSource = getRelativeFileResponses(deployResults.result.deployedSource); | ||
expect(deployedSource).to.have.deep.members(getExpectedSource('Created')); | ||
}); | ||
|
||
it('can retrieve email templates via the manifest', () => { | ||
const retrieveResults = execCmd<RetrieveCommandResult>('force:source:retrieve -x package.xml --json').jsonOutput; | ||
expect(retrieveResults.status, JSON.stringify(retrieveResults)).to.equal(0); | ||
const retrievedSource = getRelativeFileResponses(retrieveResults.result.inboundFiles); | ||
expect(retrievedSource).to.have.deep.members(getExpectedSource('Changed')); | ||
}); | ||
}); | ||
|
||
describe('reports', () => { | ||
after(async () => { | ||
await fs.promises.unlink(path.join(session.project.dir, 'package.xml')); | ||
}); | ||
|
||
it('can generate manifest for just the reports', () => { | ||
expect(fs.existsSync(path.join(session.project.dir, 'package.xml'))).to.be.false; | ||
const pathToReports = path.join('force-app', 'main', 'default', 'reports'); | ||
execCmd(`force:source:manifest:create -p ${pathToReports} --json`, { ensureExitCode: 0 }); | ||
expect(fs.existsSync(path.join(session.project.dir, 'package.xml'))).to.be.true; | ||
}); | ||
|
||
it('can deploy reports via the manifest', () => { | ||
execCmd('force:source:deploy -x package.xml --json', { ensureExitCode: 0 }); | ||
}); | ||
|
||
it('can retrieve reports via the manifest', () => { | ||
execCmd('force:source:retrieve -x package.xml --json', { ensureExitCode: 0 }); | ||
}); | ||
}); | ||
}); |
Submodule testProj
deleted from
ae7f21
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