Skip to content

Commit

Permalink
test: move existing snapshot project
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Aug 8, 2024
1 parent d873517 commit 5065e62
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomLabels xmlns="http://soap.sforce.com/2006/04/metadata">
<labels>
<fullName>DeleteMe</fullName>
<language>en_US</language>
<protected>true</protected>
<shortDescription>DeleteMe</shortDescription>
<value>Test</value>
</labels>
<labels>
<fullName>KeepMe1</fullName>
<language>en_US</language>
<protected>true</protected>
<shortDescription>KeepMe1</shortDescription>
<value>Test</value>
</labels>
<labels>
<fullName>KeepMe2</fullName>
<language>en_US</language>
<protected>true</protected>
<shortDescription>KeepMe2</shortDescription>
<value>Test</value>
</labels>
</CustomLabels>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>CustomLabels</members>
<name>CustomLabels</name>
</types>
<version>60.0</version>
</Package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomLabels xmlns="http://soap.sforce.com/2006/04/metadata"></CustomLabels>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomLabel xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>DeleteMe</fullName>
<language>en_US</language>
<protected>true</protected>
<shortDescription>DeleteMe</shortDescription>
<value>Test</value>
</CustomLabel>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomLabel xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>KeepMe1</fullName>
<language>en_US</language>
<protected>true</protected>
<shortDescription>KeepMe1</shortDescription>
<value>Test</value>
</CustomLabel>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomLabel xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>KeepMe2</fullName>
<language>en_US</language>
<protected>true</protected>
<shortDescription>KeepMe2</shortDescription>
<value>Test</value>
</CustomLabel>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomLabels xmlns="http://soap.sforce.com/2006/04/metadata">
<labels>
<fullName>DeleteMe</fullName>
<language>en_US</language>
<protected>true</protected>
<shortDescription>DeleteMe</shortDescription>
<value>Test</value>
</labels>
<labels>
<fullName>KeepMe1</fullName>
<language>en_US</language>
<protected>true</protected>
<shortDescription>KeepMe1</shortDescription>
<value>Test</value>
</labels>
<labels>
<fullName>KeepMe2</fullName>
<language>en_US</language>
<protected>true</protected>
<shortDescription>KeepMe2</shortDescription>
<value>Test</value>
</labels>
</CustomLabels>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>DeleteMe</members>
<members>KeepMe1</members>
<members>KeepMe2</members>
<name>CustomLabel</name>
</types>
<types>
<members>CustomLabels</members>
<name>CustomLabels</name>
</types>
<version>57.0</version>
</Package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "variantTest",
"namespace": "",
"packageDirectories": [
{
"default": true,
"path": "force-app"
}
],
"sourceBehaviorOptions": ["decomposeCustomLabelsBeta"],
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "60.0"
}
Original file line number Diff line number Diff line change
@@ -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 }),
]);
});
});

0 comments on commit 5065e62

Please sign in to comment.