Skip to content

Commit c914d59

Browse files
committed
feat: analytics dashboard lwc templates
@W-9191596@
1 parent 008a5bd commit c914d59

File tree

7 files changed

+148
-0
lines changed

7 files changed

+148
-0
lines changed

packages/plugin-templates/test/commands/force/lightning/component/create.test.ts

+99
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,82 @@ describe('Lightning component creation tests:', () => {
210210
);
211211
});
212212

213+
describe('Check analytics dashboard lwc creation', () => {
214+
test
215+
.withOrg()
216+
.withProject()
217+
.stdout()
218+
.command([
219+
'force:lightning:component:create',
220+
'--componentname',
221+
'foo',
222+
'--outputdir',
223+
'lwc',
224+
'--type',
225+
'lwc',
226+
'--template',
227+
'analyticsDashboard'
228+
])
229+
.it(
230+
'should create analyticsDashboard lwc files in the lwc output directory',
231+
ctx => {
232+
const jsFile = path.join('lwc', 'foo', 'foo.js');
233+
const metaFile = path.join('lwc', 'foo', 'foo.js-meta.xml');
234+
assert.file(metaFile);
235+
assert.file(path.join('lwc', 'foo', 'foo.html'));
236+
assert.file(jsFile);
237+
assert.fileContent(metaFile, '<target>analytics__Dashboard</target>');
238+
assert.fileContent(metaFile, 'targets="analytics__Dashboard"');
239+
assert.fileContent(metaFile, '<hasStep>false</hasStep>');
240+
assert.fileContent(
241+
jsFile,
242+
'export default class Foo extends LightningElement {'
243+
);
244+
assert.fileContent(jsFile, '@api getState;');
245+
assert.fileContent(jsFile, '@api setState;');
246+
}
247+
);
248+
test
249+
.withOrg()
250+
.withProject()
251+
.stdout()
252+
.command([
253+
'force:lightning:component:create',
254+
'--componentname',
255+
'foo',
256+
'--outputdir',
257+
'lwc',
258+
'--type',
259+
'lwc',
260+
'--template',
261+
'analyticsDashboardWithStep'
262+
])
263+
.it(
264+
'should create analyticsDashboardWithStep lwc files in the lwc output directory',
265+
ctx => {
266+
const jsFile = path.join('lwc', 'foo', 'foo.js');
267+
const metaFile = path.join('lwc', 'foo', 'foo.js-meta.xml');
268+
assert.file(metaFile);
269+
assert.file(path.join('lwc', 'foo', 'foo.html'));
270+
assert.file(jsFile);
271+
assert.fileContent(metaFile, '<target>analytics__Dashboard</target>');
272+
assert.fileContent(metaFile, 'targets="analytics__Dashboard"');
273+
assert.fileContent(metaFile, '<hasStep>true</hasStep>');
274+
assert.fileContent(
275+
jsFile,
276+
'export default class Foo extends LightningElement {'
277+
);
278+
assert.fileContent(jsFile, '@api getState;');
279+
assert.fileContent(jsFile, '@api setState;');
280+
assert.fileContent(jsFile, '@api results;');
281+
assert.fileContent(jsFile, '@api metadata;');
282+
assert.fileContent(jsFile, '@api selection;');
283+
assert.fileContent(jsFile, '@api setSelection;');
284+
assert.fileContent(jsFile, '@api selectMode;');
285+
}
286+
);
287+
});
288+
213289
describe('lightning component failures', () => {
214290
test
215291
.withOrg()
@@ -261,5 +337,28 @@ describe('Lightning component creation tests:', () => {
261337
.it('should throw invalid template error', ctx => {
262338
expect(ctx.stderr).to.contain(messages.getMessage('InvalidTemplate'));
263339
});
340+
test
341+
.withOrg()
342+
.withProject()
343+
.stderr()
344+
.command([
345+
'force:lightning:component:create',
346+
'--outputdir',
347+
'aura',
348+
'--componentname',
349+
'foo',
350+
'--type',
351+
'aura',
352+
'--template',
353+
'analyticsDashboard'
354+
])
355+
.it('should throw missing template error', ctx => {
356+
expect(ctx.stderr).to.contain(
357+
messages.getMessage('MissingLightningComponentTemplate', [
358+
'analyticsDashboard',
359+
'aura'
360+
])
361+
);
362+
});
264363
});
265364
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
3+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { LightningElement, api } from 'lwc';
2+
3+
export default class <%= className %> extends LightningElement {
4+
@api getState;
5+
@api setState;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<apiVersion><%= apiVersion %></apiVersion>
4+
<isExposed>true</isExposed>
5+
<targets>
6+
<target>analytics__Dashboard</target>
7+
</targets>
8+
<targetConfigs>
9+
<targetConfig targets="analytics__Dashboard">
10+
<hasStep>false</hasStep>
11+
</targetConfig>
12+
</targetConfigs>
13+
</LightningComponentBundle>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
3+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { LightningElement, api } from 'lwc';
2+
3+
export default class <%= className %> extends LightningElement {
4+
@api results;
5+
@api metadata;
6+
@api selection;
7+
@api setSelection;
8+
@api selectMode;
9+
@api getState;
10+
@api setState;
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<apiVersion><%= apiVersion %></apiVersion>
4+
<isExposed>true</isExposed>
5+
<targets>
6+
<target>analytics__Dashboard</target>
7+
</targets>
8+
<targetConfigs>
9+
<targetConfig targets="analytics__Dashboard">
10+
<hasStep>true</hasStep>
11+
</targetConfig>
12+
</targetConfigs>
13+
</LightningComponentBundle>

0 commit comments

Comments
 (0)