-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: offer suggestions for unresolved metadata types
- Loading branch information
1 parent
67a24fd
commit bceba7f
Showing
12 changed files
with
472 additions
and
5 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,87 @@ | ||
/* | ||
* 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 { TestSession } from '@salesforce/cli-plugins-testkit'; | ||
import { expect } from 'chai'; | ||
import { SfError } from '@salesforce/core'; | ||
import { ComponentSetBuilder } from '../../../src'; | ||
|
||
describe('suggest types', () => { | ||
let session: TestSession; | ||
|
||
before(async () => { | ||
session = await TestSession.create({ | ||
project: { | ||
sourceDir: path.join('test', 'nuts', 'suggestType', 'testProj'), | ||
}, | ||
devhubAuthStrategy: 'NONE', | ||
}); | ||
}); | ||
|
||
after(async () => { | ||
await session?.clean(); | ||
}); | ||
|
||
it('it offers a suggestions on an invalid type', async () => { | ||
try { | ||
await ComponentSetBuilder.build({ | ||
sourcepath: [path.join(session.project.dir, 'force-app', 'main', 'default', 'objects')], | ||
}); | ||
throw new Error('This test should have thrown'); | ||
} catch (err) { | ||
const error = err as SfError; | ||
expect(error.name).to.equal('TypeInferenceError'); | ||
expect(error.actions).to.include( | ||
'A search for the ".objct-meta.xml" metadata suffix found the following close match:' | ||
); | ||
expect(error.actions).to.include( | ||
'- Did you mean ".object-meta.xml" instead for the "CustomObject" metadata type?' | ||
); | ||
} | ||
}); | ||
|
||
it('it offers a suggestions on a incorrect casing', async () => { | ||
try { | ||
await ComponentSetBuilder.build({ | ||
sourcepath: [path.join(session.project.dir, 'force-app', 'main', 'default', 'layouts')], | ||
}); | ||
throw new Error('This test should have thrown'); | ||
} catch (err) { | ||
const error = err as SfError; | ||
expect(error.name).to.equal('TypeInferenceError'); | ||
expect(error.actions).to.include( | ||
'A search for the ".Layout-meta.xml" metadata suffix found the following close match:' | ||
); | ||
expect(error.actions).to.include('- Did you mean ".layout-meta.xml" instead for the "Layout" metadata type?'); | ||
} | ||
}); | ||
|
||
it('it offers multiple suggestions if Levenshtein distance is the same', async () => { | ||
try { | ||
await ComponentSetBuilder.build({ | ||
sourcepath: [path.join(session.project.dir, 'force-app', 'main', 'default', 'tabs')], | ||
}); | ||
throw new Error('This test should have thrown'); | ||
} catch (err) { | ||
const error = err as SfError; | ||
expect(error.name).to.equal('TypeInferenceError'); | ||
expect(error.actions).to.include( | ||
'A search for the ".tabsss-meta.xml" metadata suffix found the following close matches:' | ||
); | ||
expect(error.actions).to.include( | ||
'- Did you mean ".labels-meta.xml" instead for the "CustomLabels" metadata type?' | ||
); | ||
expect(error.actions).to.include('- Did you mean ".tab-meta.xml" instead for the "CustomTab" metadata type?'); | ||
} | ||
}); | ||
|
||
it('it ignores package manifest files', async () => { | ||
const cs = await ComponentSetBuilder.build({ sourcepath: [path.join(session.project.dir, 'package-manifest')] }); | ||
expect(cs['components'].size).to.equal(0); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
test/nuts/suggestType/testProj/config/project-scratch-def.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,13 @@ | ||
{ | ||
"orgName": "ewillhoit company", | ||
"edition": "Developer", | ||
"features": ["EnableSetPasswordInApi"], | ||
"settings": { | ||
"lightningExperienceSettings": { | ||
"enableS1DesktopEnabled": true | ||
}, | ||
"mobileSettings": { | ||
"enableS1EncryptedStoragePref2": false | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...stProj/force-app/main/default/layouts/MyTestObject__c-MyTestObject Layout.Layout-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,55 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Layout xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<layoutSections> | ||
<customLabel>false</customLabel> | ||
<detailHeading>false</detailHeading> | ||
<editHeading>true</editHeading> | ||
<label>Information</label> | ||
<layoutColumns> | ||
<layoutItems> | ||
<behavior>Required</behavior> | ||
<field>Name</field> | ||
</layoutItems> | ||
</layoutColumns> | ||
<layoutColumns> | ||
<layoutItems> | ||
<behavior>Edit</behavior> | ||
<field>OwnerId</field> | ||
</layoutItems> | ||
</layoutColumns> | ||
<style>TwoColumnsTopToBottom</style> | ||
</layoutSections> | ||
<layoutSections> | ||
<customLabel>false</customLabel> | ||
<detailHeading>false</detailHeading> | ||
<editHeading>true</editHeading> | ||
<label>System Information</label> | ||
<layoutColumns> | ||
<layoutItems> | ||
<behavior>Readonly</behavior> | ||
<field>CreatedById</field> | ||
</layoutItems> | ||
</layoutColumns> | ||
<layoutColumns> | ||
<layoutItems> | ||
<behavior>Readonly</behavior> | ||
<field>LastModifiedById</field> | ||
</layoutItems> | ||
</layoutColumns> | ||
<style>TwoColumnsTopToBottom</style> | ||
</layoutSections> | ||
<layoutSections> | ||
<customLabel>false</customLabel> | ||
<detailHeading>false</detailHeading> | ||
<editHeading>true</editHeading> | ||
<layoutColumns/> | ||
<layoutColumns/> | ||
<layoutColumns/> | ||
<style>CustomLinks</style> | ||
</layoutSections> | ||
<showEmailCheckbox>false</showEmailCheckbox> | ||
<showHighlightsPanel>false</showHighlightsPanel> | ||
<showInteractionLogPanel>false</showInteractionLogPanel> | ||
<showRunAssignmentRulesCheckbox>false</showRunAssignmentRulesCheckbox> | ||
<showSubmitAndAttachButton>false</showSubmitAndAttachButton> | ||
</Layout> |
Oops, something went wrong.
bceba7f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
eda-componentSetCreate-linux
228
ms207
ms1.10
eda-sourceToMdapi-linux
6124
ms5509
ms1.11
eda-sourceToZip-linux
4695
ms5141
ms0.91
eda-mdapiToSource-linux
4296
ms3679
ms1.17
lotsOfClasses-componentSetCreate-linux
449
ms419
ms1.07
lotsOfClasses-sourceToMdapi-linux
8956
ms7706
ms1.16
lotsOfClasses-sourceToZip-linux
7052
ms5925
ms1.19
lotsOfClasses-mdapiToSource-linux
4794
ms4055
ms1.18
lotsOfClassesOneDir-componentSetCreate-linux
784
ms707
ms1.11
lotsOfClassesOneDir-sourceToMdapi-linux
11965
ms10718
ms1.12
lotsOfClassesOneDir-sourceToZip-linux
10676
ms8979
ms1.19
lotsOfClassesOneDir-mdapiToSource-linux
9197
ms7179
ms1.28
This comment was automatically generated by workflow using github-action-benchmark.
bceba7f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
eda-componentSetCreate-win32
387
ms397
ms0.97
eda-sourceToMdapi-win32
7802
ms8512
ms0.92
eda-sourceToZip-win32
6294
ms6272
ms1.00
eda-mdapiToSource-win32
7130
ms7626
ms0.93
lotsOfClasses-componentSetCreate-win32
803
ms828
ms0.97
lotsOfClasses-sourceToMdapi-win32
10541
ms11493
ms0.92
lotsOfClasses-sourceToZip-win32
7504
ms7814
ms0.96
lotsOfClasses-mdapiToSource-win32
8863
ms9307
ms0.95
lotsOfClassesOneDir-componentSetCreate-win32
1451
ms1555
ms0.93
lotsOfClassesOneDir-sourceToMdapi-win32
17294
ms19120
ms0.90
lotsOfClassesOneDir-sourceToZip-win32
12202
ms12797
ms0.95
lotsOfClassesOneDir-mdapiToSource-win32
15364
ms16771
ms0.92
This comment was automatically generated by workflow using github-action-benchmark.