diff --git a/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-md-files.expected/labels/CustomLabels.labels b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-md-files.expected/labels/CustomLabels.labels new file mode 100644 index 0000000000..d57a2391aa --- /dev/null +++ b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-md-files.expected/labels/CustomLabels.labels @@ -0,0 +1,24 @@ + + + + DeleteMe + en_US + true + DeleteMe + Test + + + KeepMe1 + en_US + true + KeepMe1 + Test + + + KeepMe2 + en_US + true + KeepMe2 + Test + + diff --git a/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-md-files.expected/package.xml b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-md-files.expected/package.xml new file mode 100644 index 0000000000..51950dd57c --- /dev/null +++ b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-md-files.expected/package.xml @@ -0,0 +1,8 @@ + + + + CustomLabels + CustomLabels + + 60.0 + diff --git a/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-source-files.expected/force-app/main/default/labels/CustomLabels/CustomLabels.labels-meta.xml b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-source-files.expected/force-app/main/default/labels/CustomLabels/CustomLabels.labels-meta.xml new file mode 100644 index 0000000000..6d9520ca90 --- /dev/null +++ b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-source-files.expected/force-app/main/default/labels/CustomLabels/CustomLabels.labels-meta.xml @@ -0,0 +1,2 @@ + + diff --git a/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-source-files.expected/force-app/main/default/labels/CustomLabels/DeleteMe.label-meta.xml b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-source-files.expected/force-app/main/default/labels/CustomLabels/DeleteMe.label-meta.xml new file mode 100644 index 0000000000..14bf9da669 --- /dev/null +++ b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-source-files.expected/force-app/main/default/labels/CustomLabels/DeleteMe.label-meta.xml @@ -0,0 +1,8 @@ + + + DeleteMe + en_US + true + DeleteMe + Test + diff --git a/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-source-files.expected/force-app/main/default/labels/CustomLabels/KeepMe1.label-meta.xml b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-source-files.expected/force-app/main/default/labels/CustomLabels/KeepMe1.label-meta.xml new file mode 100644 index 0000000000..9a78141d6e --- /dev/null +++ b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-source-files.expected/force-app/main/default/labels/CustomLabels/KeepMe1.label-meta.xml @@ -0,0 +1,8 @@ + + + KeepMe1 + en_US + true + KeepMe1 + Test + diff --git a/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-source-files.expected/force-app/main/default/labels/CustomLabels/KeepMe2.label-meta.xml b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-source-files.expected/force-app/main/default/labels/CustomLabels/KeepMe2.label-meta.xml new file mode 100644 index 0000000000..64ab9ef9b3 --- /dev/null +++ b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/__snapshots__/verify-source-files.expected/force-app/main/default/labels/CustomLabels/KeepMe2.label-meta.xml @@ -0,0 +1,8 @@ + + + KeepMe2 + en_US + true + KeepMe2 + Test + diff --git a/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/originalMdapi/labels/CustomLabels.labels b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/originalMdapi/labels/CustomLabels.labels new file mode 100644 index 0000000000..d57a2391aa --- /dev/null +++ b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/originalMdapi/labels/CustomLabels.labels @@ -0,0 +1,24 @@ + + + + DeleteMe + en_US + true + DeleteMe + Test + + + KeepMe1 + en_US + true + KeepMe1 + Test + + + KeepMe2 + en_US + true + KeepMe2 + Test + + diff --git a/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/originalMdapi/package.xml b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/originalMdapi/package.xml new file mode 100644 index 0000000000..76c38d0d62 --- /dev/null +++ b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/originalMdapi/package.xml @@ -0,0 +1,14 @@ + + + + DeleteMe + KeepMe1 + KeepMe2 + CustomLabel + + + CustomLabels + CustomLabels + + 57.0 + diff --git a/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/sfdx-project.json b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/sfdx-project.json new file mode 100644 index 0000000000..97d16c7028 --- /dev/null +++ b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/sfdx-project.json @@ -0,0 +1,13 @@ +{ + "name": "variantTest", + "namespace": "", + "packageDirectories": [ + { + "default": true, + "path": "force-app" + } + ], + "sourceBehaviorOptions": ["decomposeCustomLabelsBeta"], + "sfdcLoginUrl": "https://login.salesforce.com", + "sourceApiVersion": "60.0" +} diff --git a/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/snapshots.test.ts b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/snapshots.test.ts new file mode 100644 index 0000000000..fbb625b584 --- /dev/null +++ b/test/snapshot/sampleProjects/preset-decomposeLabels_Deprecated/snapshots.test.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023, 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 'node:fs'; +import * as path from 'node:path'; +import { + compareTwoXml, + fileSnap, + mdapiToSource, + sourceToMdapi, + MDAPI_OUT, + dirsAreIdentical, + FORCE_APP, +} from '../../helper/conversions'; + +// we don't want failing tests outputting over each other +/* eslint-disable no-await-in-loop */ + +describe('decomposed custom labels', () => { + const testDir = path.join('test', 'snapshot', 'sampleProjects', 'preset-decomposeLabels_Deprecated'); + let sourceFiles: string[]; + let mdFiles: string[]; + + before(async () => { + sourceFiles = await mdapiToSource(testDir); + mdFiles = await sourceToMdapi(testDir); + }); + it('verify source files', async () => { + for (const file of sourceFiles) { + await fileSnap(file, testDir); + } + dirsAreIdentical( + path.join(testDir, FORCE_APP), + path.join(testDir, '__snapshots__', 'verify-source-files.expected', FORCE_APP) + ); + }); + it('verify md files', async () => { + for (const file of mdFiles) { + await fileSnap(file, testDir); + } + }); + it('round trip of metadata format is equivalent', async () => { + const [old, updated] = await Promise.all([ + fs.promises.readFile(path.join(testDir, 'originalMdapi', 'labels', 'CustomLabels.labels'), 'utf8'), + fs.promises.readFile(path.join(testDir, MDAPI_OUT, 'labels', 'CustomLabels.labels'), 'utf8'), + ]); + compareTwoXml(old, updated); + }); + + after(async () => { + await Promise.all([ + fs.promises.rm(path.join(testDir, FORCE_APP), { recursive: true, force: true }), + fs.promises.rm(path.join(testDir, MDAPI_OUT), { recursive: true, force: true }), + ]); + }); +});