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

fix: match using decoded component keys in ComponentSet.has() #1070

Merged
merged 4 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions src/collections/componentSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,13 @@ export class ComponentSet extends LazyCollection<MetadataComponent> {
return true;
}

// This will decode the key of the component before comparing, which can solve some edge cases
// in component fullNames such as Layouts. See: https://github.com/forcedotcom/cli/issues/1683
const isDirectlyInSetDecoded = this.components.has(decodeURI(simpleKey(component)));
if (isDirectlyInSetDecoded) {
return true;
}
shetzel marked this conversation as resolved.
Show resolved Hide resolved

const wildcardMember: ComponentLike = {
fullName: ComponentSet.WILDCARD,
type: typeof component.type === 'object' ? component.type.name : component.type,
Expand Down
20 changes: 20 additions & 0 deletions test/collections/componentSet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,26 @@ describe('ComponentSet', () => {

expect(set.has(child)).to.be.true;
});

it('should correctly evaluate membership with decoded MetadataComponent key', () => {
const set = new ComponentSet(undefined, registryAccess);
const decodedComponent: MetadataComponent = {
fullName: 'Broker__c-v1.1 Broker Layout',
type: registry.types.layout,
};
const encodedComponent: MetadataComponent = {
fullName: 'Broker__c-v1%2E1 Broker Layout',
type: registry.types.layout,
};

expect(set.has(decodedComponent)).to.be.false;
expect(set.has(encodedComponent)).to.be.false;

set.add(decodedComponent);

expect(set.has(encodedComponent)).to.be.true;
expect(set.has(decodedComponent)).to.be.true;
});
});

it('should calculate size correctly', () => {
Expand Down