Skip to content

Commit

Permalink
feat: analytics dashboard lwc templates
Browse files Browse the repository at this point in the history
@W-9191596@
  • Loading branch information
smithgp committed May 24, 2021
1 parent 0648ff5 commit 0db5d2f
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,82 @@ describe('Lightning component creation tests:', () => {
);
});

describe('Check analytics dashboard lwc creation', () => {
test
.withOrg()
.withProject()
.stdout()
.command([
'force:lightning:component:create',
'--componentname',
'foo',
'--outputdir',
'lwc',
'--type',
'lwc',
'--template',
'analyticsDashboard'
])
.it(
'should create analyticsDashboard lwc files in the lwc output directory',
ctx => {
const jsFile = path.join('lwc', 'foo', 'foo.js');
const metaFile = path.join('lwc', 'foo', 'foo.js-meta.xml');
assert.file(metaFile);
assert.file(path.join('lwc', 'foo', 'foo.html'));
assert.file(jsFile);
assert.fileContent(metaFile, '<target>analytics__Dashboard</target>');
assert.fileContent(metaFile, 'targets="analytics__Dashboard"');
assert.fileContent(metaFile, '<hasStep>false</hasStep>');
assert.fileContent(
jsFile,
'export default class Foo extends LightningElement {'
);
assert.fileContent(jsFile, '@api getState;');
assert.fileContent(jsFile, '@api setState;');
}
);
test
.withOrg()
.withProject()
.stdout()
.command([
'force:lightning:component:create',
'--componentname',
'foo',
'--outputdir',
'lwc',
'--type',
'lwc',
'--template',
'analyticsDashboardWithStep'
])
.it(
'should create analyticsDashboardWithStep lwc files in the lwc output directory',
ctx => {
const jsFile = path.join('lwc', 'foo', 'foo.js');
const metaFile = path.join('lwc', 'foo', 'foo.js-meta.xml');
assert.file(metaFile);
assert.file(path.join('lwc', 'foo', 'foo.html'));
assert.file(jsFile);
assert.fileContent(metaFile, '<target>analytics__Dashboard</target>');
assert.fileContent(metaFile, 'targets="analytics__Dashboard"');
assert.fileContent(metaFile, '<hasStep>true</hasStep>');
assert.fileContent(
jsFile,
'export default class Foo extends LightningElement {'
);
assert.fileContent(jsFile, '@api getState;');
assert.fileContent(jsFile, '@api setState;');
assert.fileContent(jsFile, '@api results;');
assert.fileContent(jsFile, '@api metadata;');
assert.fileContent(jsFile, '@api selection;');
assert.fileContent(jsFile, '@api setSelection;');
assert.fileContent(jsFile, '@api selectMode;');
}
);
});

describe('lightning component failures', () => {
test
.withOrg()
Expand Down Expand Up @@ -261,5 +337,28 @@ describe('Lightning component creation tests:', () => {
.it('should throw invalid template error', ctx => {
expect(ctx.stderr).to.contain(messages.getMessage('InvalidTemplate'));
});
test
.withOrg()
.withProject()
.stderr()
.command([
'force:lightning:component:create',
'--outputdir',
'aura',
'--componentname',
'foo',
'--type',
'aura',
'--template',
'analyticsDashboard'
])
.it('should throw missing template error', ctx => {
expect(ctx.stderr).to.contain(
messages.getMessage('MissingLightningComponentTemplate', [
'analyticsDashboard',
'aura'
])
);
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>

</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { LightningElement, api } from 'lwc';

export default class <%= className %> extends LightningElement {
@api getState;
@api setState;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion><%= apiVersion %></apiVersion>
<isExposed>true</isExposed>
<targets>
<target>analytics__Dashboard</target>
</targets>
<targetConfigs>
<targetConfig targets="analytics__Dashboard">
<hasStep>false</hasStep>
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>

</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { LightningElement, api } from 'lwc';

export default class <%= className %> extends LightningElement {
@api results;
@api metadata;
@api selection;
@api setSelection;
@api selectMode;
@api getState;
@api setState;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion><%= apiVersion %></apiVersion>
<isExposed>true</isExposed>
<targets>
<target>analytics__Dashboard</target>
</targets>
<targetConfigs>
<targetConfig targets="analytics__Dashboard">
<hasStep>true</hasStep>
</targetConfig>
</targetConfigs>
</LightningComponentBundle>

0 comments on commit 0db5d2f

Please sign in to comment.