@ -81,6 +81,7 @@ describe('Plugin Extension Validators', () => {
it ( 'should throw an error if the placement does not have the right prefix' , ( ) = > {
it ( 'should throw an error if the placement does not have the right prefix' , ( ) = > {
expect ( ( ) = > {
expect ( ( ) = > {
assertPlacementIsValid ( {
assertPlacementIsValid ( {
type : PluginExtensionTypes . link ,
title : 'Title' ,
title : 'Title' ,
description : 'Description' ,
description : 'Description' ,
path : '...' ,
path : '...' ,
@ -92,6 +93,7 @@ describe('Plugin Extension Validators', () => {
it ( 'should NOT throw an error if the placement is correct' , ( ) = > {
it ( 'should NOT throw an error if the placement is correct' , ( ) = > {
expect ( ( ) = > {
expect ( ( ) = > {
assertPlacementIsValid ( {
assertPlacementIsValid ( {
type : PluginExtensionTypes . link ,
title : 'Title' ,
title : 'Title' ,
description : 'Description' ,
description : 'Description' ,
path : '...' ,
path : '...' ,
@ -99,6 +101,7 @@ describe('Plugin Extension Validators', () => {
} ) ;
} ) ;
assertPlacementIsValid ( {
assertPlacementIsValid ( {
type : PluginExtensionTypes . link ,
title : 'Title' ,
title : 'Title' ,
description : 'Description' ,
description : 'Description' ,
path : '...' ,
path : '...' ,
@ -203,18 +206,20 @@ describe('Plugin Extension Validators', () => {
describe ( 'isPluginExtensionConfigValid()' , ( ) = > {
describe ( 'isPluginExtensionConfigValid()' , ( ) = > {
it ( 'should return TRUE if the plugin extension configuration is valid' , ( ) = > {
it ( 'should return TRUE if the plugin extension configuration is valid' , ( ) = > {
const pluginId = 'my-super-plugin' ;
const pluginId = 'my-super-plugin' ;
// Command
expect (
expect (
isPluginExtensionConfigValid ( pluginId , {
isPluginExtensionConfigValid ( pluginId , {
type : PluginExtensionTypes . link ,
title : 'Title' ,
title : 'Title' ,
description : 'Description' ,
description : 'Description' ,
placement : 'grafana/some-page/some-placement' ,
placement : 'grafana/some-page/some-placement' ,
onClick : jest.fn ( ) ,
} as PluginExtensionLinkConfig )
} as PluginExtensionLinkConfig )
) . toBe ( true ) ;
) . toBe ( true ) ;
// Link
expect (
expect (
isPluginExtensionConfigValid ( pluginId , {
isPluginExtensionConfigValid ( pluginId , {
type : PluginExtensionTypes . link ,
title : 'Title' ,
title : 'Title' ,
description : 'Description' ,
description : 'Description' ,
placement : 'grafana/some-page/some-placement' ,
placement : 'grafana/some-page/some-placement' ,
@ -231,6 +236,7 @@ describe('Plugin Extension Validators', () => {
// Link (wrong path)
// Link (wrong path)
expect (
expect (
isPluginExtensionConfigValid ( pluginId , {
isPluginExtensionConfigValid ( pluginId , {
type : PluginExtensionTypes . link ,
title : 'Title' ,
title : 'Title' ,
description : 'Description' ,
description : 'Description' ,
placement : 'grafana/some-page/some-placement' ,
placement : 'grafana/some-page/some-placement' ,
@ -238,9 +244,20 @@ describe('Plugin Extension Validators', () => {
} as PluginExtensionLinkConfig )
} as PluginExtensionLinkConfig )
) . toBe ( false ) ;
) . toBe ( false ) ;
// Link (no path and no onClick)
expect (
isPluginExtensionConfigValid ( pluginId , {
type : PluginExtensionTypes . link ,
title : 'Title' ,
description : 'Description' ,
placement : 'grafana/some-page/some-placement' ,
} as PluginExtensionLinkConfig )
) . toBe ( false ) ;
// Link (missing title)
// Link (missing title)
expect (
expect (
isPluginExtensionConfigValid ( pluginId , {
isPluginExtensionConfigValid ( pluginId , {
type : PluginExtensionTypes . link ,
title : '' ,
title : '' ,
description : 'Description' ,
description : 'Description' ,
placement : 'grafana/some-page/some-placement' ,
placement : 'grafana/some-page/some-placement' ,