Skip to content

Commit 759d168

Browse files
lesya7cursoragent
andauthored
@W-21265308 WebApplication: allow any case for app names (#1684)
* fix: allow WebApplication app name in any case, add tests - Use appName (from folder) instead of source.name to preserve case - Add tests for MyApp, myapp, MYAPP Co-authored-by: Cursor <cursoragent@cursor.com> * Bumping up @salesforce/core Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent e772d59 commit 759d168

4 files changed

Lines changed: 1737 additions & 2214 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"node": ">=18.0.0"
2626
},
2727
"dependencies": {
28-
"@salesforce/core": "^8.26.0",
28+
"@salesforce/core": "^8.26.2",
2929
"@salesforce/kit": "^3.2.4",
3030
"@salesforce/ts-types": "^2.0.12",
3131
"@salesforce/types": "^1.6.0",

src/resolve/adapters/webApplicationsSourceAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class WebApplicationsSourceAdapter extends BundleSourceAdapter {
5252
? source
5353
: new SourceComponent(
5454
{
55-
name: source.name,
55+
name: appName,
5656
type: source.type,
5757
content: source.content,
5858
xml: expectedXmlPath,

test/resolve/adapters/webApplicationsSourceAdapter.test.ts

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import { join } from 'node:path';
1717
import { assert, expect } from 'chai';
1818
import { Messages, SfError } from '@salesforce/core';
19-
import { ForceIgnore, RegistryAccess, SourceComponent, VirtualTreeContainer, registry } from '../../../src';
19+
import { ForceIgnore, RegistryAccess, SourceComponent, VirtualDirectory, VirtualTreeContainer, registry } from '../../../src';
2020
import { WebApplicationsSourceAdapter } from '../../../src/resolve/adapters';
2121
import { RegistryTestUtil } from '../registryTestUtil';
2222

@@ -152,4 +152,54 @@ describe('WebApplicationsSourceAdapter', () => {
152152
);
153153
testUtil.restore();
154154
});
155+
156+
describe('app name case', () => {
157+
const buildAdapterWithAppName = (appName: string) => {
158+
const appPath = join(BASE_PATH, appName);
159+
const metaFile = join(appPath, `${appName}.webapplication-meta.xml`);
160+
const config = { outputDir: 'src', routing: { trailingSlash: 'auto', fallback: '/index.html' } };
161+
const vfs: VirtualDirectory[] = [
162+
{
163+
dirPath: appPath,
164+
children: [
165+
`${appName}.webapplication-meta.xml`,
166+
{ name: 'webapplication.json', data: Buffer.from(JSON.stringify(config)) },
167+
'src',
168+
],
169+
},
170+
{ dirPath: join(appPath, 'src'), children: ['index.html'] },
171+
];
172+
const t = new VirtualTreeContainer(vfs);
173+
return {
174+
adapter: new WebApplicationsSourceAdapter(registry.types.webapplication, registryAccess, forceIgnore, t),
175+
appPath,
176+
metaFile,
177+
};
178+
};
179+
180+
it('should preserve mixed-case app name (MyApp)', () => {
181+
const { adapter, appPath, metaFile } = buildAdapterWithAppName('MyApp');
182+
const comp = adapter.getComponent(appPath);
183+
expect(comp).to.not.be.undefined;
184+
expect(comp!.name).to.equal('MyApp');
185+
expect(comp!.fullName).to.equal('MyApp');
186+
expect(comp!.xml).to.equal(metaFile);
187+
});
188+
189+
it('should preserve lowercase app name (myapp)', () => {
190+
const { adapter, appPath } = buildAdapterWithAppName('myapp');
191+
const comp = adapter.getComponent(appPath);
192+
expect(comp).to.not.be.undefined;
193+
expect(comp!.name).to.equal('myapp');
194+
expect(comp!.fullName).to.equal('myapp');
195+
});
196+
197+
it('should preserve uppercase app name (MYAPP)', () => {
198+
const { adapter, appPath } = buildAdapterWithAppName('MYAPP');
199+
const comp = adapter.getComponent(appPath);
200+
expect(comp).to.not.be.undefined;
201+
expect(comp!.name).to.equal('MYAPP');
202+
expect(comp!.fullName).to.equal('MYAPP');
203+
});
204+
});
155205
});

0 commit comments

Comments
 (0)