diff --git a/packages/plugin-templates/test/commands/force/lightning/component/create.test.ts b/packages/plugin-templates/test/commands/force/lightning/component/create.test.ts index a7dfe412..81649784 100644 --- a/packages/plugin-templates/test/commands/force/lightning/component/create.test.ts +++ b/packages/plugin-templates/test/commands/force/lightning/component/create.test.ts @@ -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, 'analytics__Dashboard'); + assert.fileContent(metaFile, 'targets="analytics__Dashboard"'); + assert.fileContent(metaFile, 'false'); + 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, 'analytics__Dashboard'); + assert.fileContent(metaFile, 'targets="analytics__Dashboard"'); + assert.fileContent(metaFile, 'true'); + 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() @@ -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' + ]) + ); + }); }); }); diff --git a/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboard/analyticsDashboard.html b/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboard/analyticsDashboard.html new file mode 100644 index 00000000..27e0f695 --- /dev/null +++ b/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboard/analyticsDashboard.html @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboard/analyticsDashboard.js b/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboard/analyticsDashboard.js new file mode 100644 index 00000000..2dbe7656 --- /dev/null +++ b/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboard/analyticsDashboard.js @@ -0,0 +1,6 @@ +import { LightningElement, api } from 'lwc'; + +export default class <%= className %> extends LightningElement { + @api getState; + @api setState; +} \ No newline at end of file diff --git a/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboard/analyticsDashboard.js-meta.xml b/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboard/analyticsDashboard.js-meta.xml new file mode 100644 index 00000000..efdc8304 --- /dev/null +++ b/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboard/analyticsDashboard.js-meta.xml @@ -0,0 +1,13 @@ + + + <%= apiVersion %> + true + + analytics__Dashboard + + + + false + + + \ No newline at end of file diff --git a/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboardWithStep/analyticsDashboardWithStep.html b/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboardWithStep/analyticsDashboardWithStep.html new file mode 100644 index 00000000..27e0f695 --- /dev/null +++ b/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboardWithStep/analyticsDashboardWithStep.html @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboardWithStep/analyticsDashboardWithStep.js b/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboardWithStep/analyticsDashboardWithStep.js new file mode 100644 index 00000000..4d9450f4 --- /dev/null +++ b/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboardWithStep/analyticsDashboardWithStep.js @@ -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; +} \ No newline at end of file diff --git a/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboardWithStep/analyticsDashboardWithStep.js-meta.xml b/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboardWithStep/analyticsDashboardWithStep.js-meta.xml new file mode 100644 index 00000000..8bfcdfcf --- /dev/null +++ b/packages/templates/src/templates/lightningcomponent/lwc/analyticsDashboardWithStep/analyticsDashboardWithStep.js-meta.xml @@ -0,0 +1,13 @@ + + + <%= apiVersion %> + true + + analytics__Dashboard + + + + true + + + \ No newline at end of file