From 02f4423a5732de82223f424bc198170744393720 Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Tue, 31 Oct 2023 10:06:54 -0600 Subject: [PATCH] test: add MPD NUTs for CFT/COT --- package.json | 1 + .../customField__c.fieldTranslation-meta.xml | 0 ...tomObject__c-es.objectTranslation-meta.xml | 0 .../sfdx-project.json | 4 ++ test/nuts/specialTypes/translation.nut.ts | 44 +++++++++++++++++-- 5 files changed, 45 insertions(+), 4 deletions(-) rename test/nuts/specialTypes/customTranslationProject/{force-app => my-app}/main/default/objectTranslations/customObject__c-es/customField__c.fieldTranslation-meta.xml (100%) rename test/nuts/specialTypes/customTranslationProject/{force-app => my-app}/main/default/objectTranslations/customObject__c-es/customObject__c-es.objectTranslation-meta.xml (100%) diff --git a/package.json b/package.json index c6e6df45..1f3de95b 100644 --- a/package.json +++ b/package.json @@ -152,6 +152,7 @@ "test:nuts:manifest": "nyc mocha \"test/nuts/manifest/*.nut.ts\" --slow 4500 --timeout 1200000 --parallel --retries 0 --jobs 20", "test:nuts:retrieve": "nyc mocha \"test/nuts/retrieve/*.nut.ts\" --slow 4500 --timeout 1200000 --parallel --retries 0 --jobs 20", "test:nuts:specialTypes": "nyc mocha \"test/nuts/specialTypes/*.nut.ts\" --slow 4500 --timeout 1200000 --parallel --retries 0 --jobs 20", + "test:nuts:specialTypes:translations": "mocha \"test/nuts/specialTypes/translation.nut.ts\" --slow 4500 --timeout 1200000 --retries 0 --jobs 20", "test:nuts:static": "nyc mocha \"test/commands/**/*.nut.ts\" \"test/nuts/*.nut.ts\" --slow 4500 --timeout 1200000 --parallel --retries 0 --jobs 20", "test:nuts:tracking": "nyc mocha \"test/nuts/tracking/*.nut.ts\" --slow 4500 --timeout 1200000 --parallel --retries 0 --jobs 20", "test:only": "wireit", diff --git a/test/nuts/specialTypes/customTranslationProject/force-app/main/default/objectTranslations/customObject__c-es/customField__c.fieldTranslation-meta.xml b/test/nuts/specialTypes/customTranslationProject/my-app/main/default/objectTranslations/customObject__c-es/customField__c.fieldTranslation-meta.xml similarity index 100% rename from test/nuts/specialTypes/customTranslationProject/force-app/main/default/objectTranslations/customObject__c-es/customField__c.fieldTranslation-meta.xml rename to test/nuts/specialTypes/customTranslationProject/my-app/main/default/objectTranslations/customObject__c-es/customField__c.fieldTranslation-meta.xml diff --git a/test/nuts/specialTypes/customTranslationProject/force-app/main/default/objectTranslations/customObject__c-es/customObject__c-es.objectTranslation-meta.xml b/test/nuts/specialTypes/customTranslationProject/my-app/main/default/objectTranslations/customObject__c-es/customObject__c-es.objectTranslation-meta.xml similarity index 100% rename from test/nuts/specialTypes/customTranslationProject/force-app/main/default/objectTranslations/customObject__c-es/customObject__c-es.objectTranslation-meta.xml rename to test/nuts/specialTypes/customTranslationProject/my-app/main/default/objectTranslations/customObject__c-es/customObject__c-es.objectTranslation-meta.xml diff --git a/test/nuts/specialTypes/customTranslationProject/sfdx-project.json b/test/nuts/specialTypes/customTranslationProject/sfdx-project.json index 21b70164..8a311d03 100644 --- a/test/nuts/specialTypes/customTranslationProject/sfdx-project.json +++ b/test/nuts/specialTypes/customTranslationProject/sfdx-project.json @@ -3,6 +3,10 @@ { "path": "force-app", "default": true + }, + { + "path": "my-app", + "default": false } ], "name": "default", diff --git a/test/nuts/specialTypes/translation.nut.ts b/test/nuts/specialTypes/translation.nut.ts index 99b4a0ce..1b5f73f4 100644 --- a/test/nuts/specialTypes/translation.nut.ts +++ b/test/nuts/specialTypes/translation.nut.ts @@ -15,6 +15,7 @@ describe('translations', () => { let session: TestSession; let projectPath: string; let translationPath: string; + let fieldTranslationPath: string; before(async () => { session = await TestSession.create({ @@ -31,8 +32,14 @@ describe('translations', () => { }, ], }); - projectPath = path.join(session.project.dir, 'force-app', 'main', 'default'); + projectPath = path.join(session.project.dir, 'my-app', 'main', 'default'); translationPath = path.join(projectPath, 'objectTranslations', 'customObject__c-es'); + fieldTranslationPath = path.join( + projectPath, + 'objectTranslations', + 'customObject__c-es', + 'customField__c.fieldTranslation-meta.xml' + ); }); after(async () => { @@ -77,7 +84,7 @@ describe('translations', () => { }); it('can generate manifest for translation types', async () => { - execCmd('force:source:manifest:create -p force-app --json', { ensureExitCode: 0 }); + execCmd('force:source:manifest:create -p my-app --json', { ensureExitCode: 0 }); expect(fs.existsSync(path.join(session.project.dir, 'package.xml'))).to.be.true; }); @@ -85,7 +92,7 @@ describe('translations', () => { const deployResults = execCmd('project deploy start -x package.xml --json', { ensureExitCode: 0, }).jsonOutput?.result; - expect(deployResults?.files.length).to.equal(7); + expect(deployResults?.files.length).to.equal(2); }); it('retrieve without local metadata', async () => { @@ -95,7 +102,7 @@ describe('translations', () => { const retrieveResults = execCmd('project retrieve start -x package.xml --json', { ensureExitCode: 0, }).jsonOutput?.result; - expect(retrieveResults?.files).to.have.length(7); + expect(retrieveResults?.files).to.have.length(2); }); }); @@ -181,6 +188,35 @@ describe('translations', () => { }); }); }); + describe('MPD', () => { + describe('deploy', () => { + it('can deploy the whole project', async () => { + execCmd('project deploy start -d force-app -d my-app --json', { + ensureExitCode: 0, + }); + }); + }); + + describe('retrieve', () => { + it('can retrieve the whole project', async () => { + execCmd('project retrieve start -d force-app -d my-app --json', { + ensureExitCode: 0, + }); + }); + + describe('individual type retrieves', () => { + before(() => { + fs.unlinkSync(fieldTranslationPath); + }); + it('will write the CFT with the COT, even when not in the default package', async () => { + execCmd(`project retrieve start -d ${translationPath} --json`, { + ensureExitCode: 0, + }); + expect(fs.existsSync(fieldTranslationPath)).to.be.true; + }); + }); + }); + }); describe('mdapi format', () => { it('can convert COT/CFTs correctly', () => {