-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #273 from forcedotcom/sh/partial-bundle-delete
fix: treat ExperienceBundles and StaticResources like bundles for partial delete
- Loading branch information
Showing
24 changed files
with
466 additions
and
50 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
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
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,170 @@ | ||
/* | ||
* 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 path from 'path'; | ||
import * as fs from 'fs'; | ||
import { TestSession } from '@salesforce/cli-plugins-testkit'; | ||
import { expect } from 'chai'; | ||
import * as sinon from 'sinon'; | ||
import { getComponentSets } from '../../../src/shared/localComponentSetArray'; | ||
|
||
describe('Bundle-like types delete', () => { | ||
let session: TestSession; | ||
|
||
before(async () => { | ||
session = await TestSession.create({ | ||
project: { | ||
sourceDir: path.join('test', 'nuts', 'repros', 'partialBundleDelete'), | ||
}, | ||
authStrategy: 'NONE', | ||
}); | ||
}); | ||
|
||
// We need a sinon sandbox to stub the file system to make it look like we | ||
// deleted some files. | ||
const sandbox = sinon.createSandbox(); | ||
|
||
after(async () => { | ||
await session?.clean(); | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
it('returns components for deploy with partial LWC delete', () => { | ||
const lwcTestCompDir = path.join(session.project.dir, 'force-app', 'lwc', 'testComp'); | ||
const lwcHtmlFile = path.join(lwcTestCompDir, 'myComp.html'); | ||
const lwcJsFile = path.join(lwcTestCompDir, 'myComp.js'); | ||
const lwcMetaFile = path.join(lwcTestCompDir, 'myComp.js-meta.xml'); | ||
|
||
const compSets = getComponentSets([ | ||
{ | ||
path: path.join(session.project.dir, 'force-app', 'lwc'), | ||
nonDeletes: [lwcJsFile, lwcMetaFile], | ||
deletes: [lwcHtmlFile], | ||
}, | ||
]); | ||
|
||
expect(compSets.length).to.equal(1); | ||
compSets.forEach((cs) => { | ||
expect(cs.getTypesOfDestructiveChanges()).to.deep.equal([]); | ||
const comps = cs.getSourceComponents().toArray(); | ||
expect(comps[0].isMarkedForDelete()).to.equal(false); | ||
}); | ||
}); | ||
|
||
it('returns components for delete for full LWC delete', () => { | ||
// We stub this so it appears that we deleted all the LWC files | ||
sandbox.stub(fs, 'existsSync').returns(false); | ||
const lwcTestCompDir = path.join(session.project.dir, 'force-app', 'lwc', 'testComp'); | ||
const lwcHtmlFile = path.join(lwcTestCompDir, 'myComp.html'); | ||
const lwcJsFile = path.join(lwcTestCompDir, 'myComp.js'); | ||
const lwcMetaFile = path.join(lwcTestCompDir, 'myComp.js-meta.xml'); | ||
|
||
const compSets = getComponentSets([ | ||
{ | ||
path: path.join(session.project.dir, 'force-app', 'lwc'), | ||
nonDeletes: [], | ||
deletes: [lwcHtmlFile, lwcJsFile, lwcMetaFile], | ||
}, | ||
]); | ||
|
||
expect(compSets.length).to.equal(1); | ||
compSets.forEach((cs) => { | ||
expect(cs.getTypesOfDestructiveChanges()).to.deep.equal(['post']); | ||
const comps = cs.getSourceComponents().toArray(); | ||
expect(comps[0].isMarkedForDelete()).to.equal(true); | ||
}); | ||
}); | ||
|
||
it('returns components for deploy with partial StaticResource delete', () => { | ||
const srDir = path.join(session.project.dir, 'force-app', 'staticresources'); | ||
const srFile1 = path.join(srDir, 'ZippedResource', 'file1.json'); | ||
const srFile2 = path.join(srDir, 'ZippedResource', 'file2.json'); | ||
const srMetaFile = path.join(srDir, 'ZippedResource.resource-meta.xml'); | ||
|
||
const compSets = getComponentSets([ | ||
{ | ||
path: srDir, | ||
nonDeletes: [srMetaFile, srFile2], | ||
deletes: [srFile1], | ||
}, | ||
]); | ||
|
||
expect(compSets.length).to.equal(1); | ||
compSets.forEach((cs) => { | ||
expect(cs.getTypesOfDestructiveChanges()).to.deep.equal([]); | ||
const comps = cs.getSourceComponents().toArray(); | ||
expect(comps[0].isMarkedForDelete()).to.equal(false); | ||
}); | ||
}); | ||
|
||
it('returns components for delete for full StaticResource delete', () => { | ||
// We stub this so it appears that we deleted all the ZippedResource static resource files | ||
sandbox.stub(fs, 'existsSync').returns(false); | ||
const srDir = path.join(session.project.dir, 'force-app', 'staticresources'); | ||
const srFile1 = path.join(srDir, 'ZippedResource', 'file1.json'); | ||
const srFile2 = path.join(srDir, 'ZippedResource', 'file2.json'); | ||
const srMetaFile = path.join(srDir, 'ZippedResource.resource-meta.xml'); | ||
|
||
const compSets = getComponentSets([ | ||
{ | ||
path: srDir, | ||
nonDeletes: [], | ||
deletes: [srFile1, srFile2, srMetaFile], | ||
}, | ||
]); | ||
|
||
expect(compSets.length).to.equal(1); | ||
compSets.forEach((cs) => { | ||
expect(cs.getTypesOfDestructiveChanges()).to.deep.equal(['post']); | ||
const comps = cs.getSourceComponents().toArray(); | ||
expect(comps[0].isMarkedForDelete()).to.equal(true); | ||
}); | ||
}); | ||
|
||
it('returns components for deploy with partial DigitalExperienceBundle delete', () => { | ||
const debDir = path.join(session.project.dir, 'force-app', 'digitalExperiences', 'site', 'Xcel_Energy1'); | ||
const deFile1 = path.join(debDir, 'sfdc_cms__view', 'home', 'content.json'); | ||
|
||
const compSets = getComponentSets([ | ||
{ | ||
path: debDir, | ||
nonDeletes: [], | ||
deletes: [deFile1], | ||
}, | ||
]); | ||
|
||
expect(compSets.length).to.equal(1); | ||
compSets.forEach((cs) => { | ||
expect(cs.getTypesOfDestructiveChanges()).to.deep.equal([]); | ||
const comps = cs.getSourceComponents().toArray(); | ||
expect(comps[0].isMarkedForDelete()).to.equal(false); | ||
}); | ||
}); | ||
|
||
it('returns components for deploy with partial ExperienceBundle delete', () => { | ||
const ebDir = path.join(session.project.dir, 'force-app', 'experiences', 'fooEB'); | ||
const eFile1 = path.join(ebDir, 'views', 'login.json'); | ||
const eFile2 = path.join(ebDir, 'routes', 'login.json'); | ||
|
||
const compSets = getComponentSets([ | ||
{ | ||
path: ebDir, | ||
nonDeletes: [eFile2], | ||
deletes: [eFile1], | ||
}, | ||
]); | ||
|
||
expect(compSets.length).to.equal(1); | ||
compSets.forEach((cs) => { | ||
expect(cs.getTypesOfDestructiveChanges()).to.deep.equal([]); | ||
const comps = cs.getSourceComponents().toArray(); | ||
expect(comps[0].isMarkedForDelete()).to.equal(false); | ||
}); | ||
}); | ||
}); |
4 changes: 4 additions & 0 deletions
4
...te/force-app/digitalExperiences/site/Xcel_Energy1/Xcel_Energy1.digitalExperience-meta.xml
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,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<DigitalExperienceBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<label>Xcel_Energy1</label> | ||
</DigitalExperienceBundle> |
5 changes: 5 additions & 0 deletions
5
...ndleDelete/force-app/digitalExperiences/site/Xcel_Energy1/sfdc_cms__view/error/_meta.json
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,5 @@ | ||
{ | ||
"apiName": "error", | ||
"type": "sfdc_cms__view", | ||
"path": "views" | ||
} |
71 changes: 71 additions & 0 deletions
71
...leDelete/force-app/digitalExperiences/site/Xcel_Energy1/sfdc_cms__view/error/content.json
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,71 @@ | ||
{ | ||
"type": "sfdc_cms__view", | ||
"title": "Error", | ||
"contentBody": { | ||
"sfdc_cms:component": { | ||
"definitionName": "community_layout:sldsFlexibleLayout", | ||
"sfdc_cms:children": [ | ||
{ | ||
"regionName": "content", | ||
"sfdc_cms:children": [ | ||
{ | ||
"componentAttributes": { | ||
"backgroundImageConfig": "", | ||
"backgroundImageOverlay": "rgba(0,0,0,0)", | ||
"sectionConfig": "{\"UUID\":\"66609d49-c588-40c5-a8d7-755443ed9fb4\",\"columns\":[{\"UUID\":\"b1a85d75-a44b-4392-9ded-5d56b382d087\",\"columnName\":\"Column 1\",\"columnKey\":\"col1\",\"columnWidth\":\"12\",\"seedComponents\":null}]}" | ||
}, | ||
"definitionName": "community_layout:section", | ||
"sfdc_cms:children": [ | ||
{ | ||
"regionName": "col1", | ||
"sfdc_cms:children": [ | ||
{ | ||
"componentAttributes": { | ||
"richTextValue": "<h1 style=\"text-align: center;\">Invalid Page</h1>" | ||
}, | ||
"definitionName": "community_builder:richTextEditor", | ||
"sfdc_cms:id": "f4b7e5ae-83fc-47f7-a5ba-025f3d9bd2b4", | ||
"sfdc_cms:type": "component" | ||
} | ||
], | ||
"sfdc_cms:id": "b1a85d75-a44b-4392-9ded-5d56b382d087", | ||
"sfdc_cms:type": "region", | ||
"title": "Column 1" | ||
} | ||
], | ||
"sfdc_cms:id": "66609d49-c588-40c5-a8d7-755443ed9fb4", | ||
"sfdc_cms:type": "component" | ||
} | ||
], | ||
"sfdc_cms:id": "84eb2730-80e9-480b-9a63-e7beda32e9cf", | ||
"sfdc_cms:type": "region", | ||
"title": "Content" | ||
}, | ||
{ | ||
"regionName": "sfdcHiddenRegion", | ||
"sfdc_cms:children": [ | ||
{ | ||
"componentAttributes": { | ||
"customHeadTags": "", | ||
"description": "", | ||
"pageTitle": "Error", | ||
"recordId": "{!recordId}" | ||
}, | ||
"definitionName": "community_builder:seoAssistant", | ||
"sfdc_cms:id": "fe045efd-2e45-495b-b7e2-d21d6f586314", | ||
"sfdc_cms:type": "component" | ||
} | ||
], | ||
"sfdc_cms:id": "4352728a-3324-4524-8bd2-a4074d544541", | ||
"sfdc_cms:type": "region", | ||
"title": "sfdcHiddenRegion" | ||
} | ||
], | ||
"sfdc_cms:id": "270041de-95c7-41e5-b70f-918878f71f68", | ||
"sfdc_cms:type": "component" | ||
}, | ||
"themeLayoutType": "Inner", | ||
"title": "Error", | ||
"viewType": "error" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...undleDelete/force-app/digitalExperiences/site/Xcel_Energy1/sfdc_cms__view/home/_meta.json
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,5 @@ | ||
{ | ||
"apiName": "home", | ||
"type": "sfdc_cms__view", | ||
"path": "views" | ||
} |
Oops, something went wrong.