Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: tracking nuts for COT/CFT #597

Merged
merged 7 commits into from
Oct 5, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions test/nuts/translation.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import * as fs from 'fs';
import * as path from 'path';
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit';
import { expect } from 'chai';
import { PushResponse } from 'src/formatters/source/pushResultFormatter';
import { DeployCommandResult } from '../../src/formatters/deployResultFormatter';
import { RetrieveCommandResult } from '../../src/formatters/retrieveResultFormatter';
import { StatusResult } from '../../src/formatters/source/statusFormatter';

describe('translations', () => {
let session: TestSession;
Expand All @@ -32,6 +34,39 @@ describe('translations', () => {
after(async () => {
await session?.clean();
});
describe('tracking/push', () => {
it('can deploy the whole project', async () => {
execCmd('force:source:push --json', {
ensureExitCode: 0,
});
});

it('modify and see local change', async () => {
const fieldFile = path.join(translationPath, 'customField__c.fieldTranslation-meta.xml');
const original = await fs.promises.readFile(fieldFile, 'utf8');
await fs.promises.writeFile(fieldFile, original.replace('spanish', 'español'));
const statusResult = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
}).jsonOutput.result;

expect(statusResult[0].type).to.equal('CustomObjectTranslation');
});

it('push local change', async () => {
const pushResult = execCmd<PushResponse>('force:source:push --json', {
ensureExitCode: 0,
}).jsonOutput.result;
// eslint-disable-next-line no-console
console.log(JSON.stringify(pushResult, undefined, 2));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still required? any other assertions on pushResult?

});

it('sees no local changes', () => {
const statusResult = execCmd<StatusResult[]>('force:source:status --json', {
ensureExitCode: 0,
}).jsonOutput.result;
expect(statusResult).to.deep.equal([]);
});
});

describe('manifest', () => {
after(async () => {
Expand Down Expand Up @@ -94,14 +129,14 @@ describe('translations', () => {
});
});

it('can "deploy" CFTs', async () => {
// should not actually deploy anything
execCmd(
it('can deploy CFTs', async () => {
const result = execCmd<DeployCommandResult>(
`force:source:deploy -p ${path.join(translationPath, 'customField__c.fieldTranslation-meta.xml')} --json`,
{
ensureExitCode: 0,
}
);
expect(result.jsonOutput.result.deployedSource.some((d) => d.type === 'CustomObjectTranslation')).to.be.true;
});

it('can deploy COT', async () => {
Expand Down