Plugins: Improve frontend loader cache (#87488)
* do it * set empty child version to parent version * feat(plugins): use pluginId for loader cache keys * feat(plugins): apply caching to all js and css files systemjs loads * remove old code and add comment * test(plugins): update systemjs hooks tests in line with better caching * test(plugins): wip - comment out failing backend loader tests * fix tests and improve comment * Update public/app/features/plugins/loader/cache.test.ts Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com> --------- Co-authored-by: Will Browne <will.browne@grafana.com> Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
This commit is contained in:
co-authored by
Levente Balogh
Will Browne
parent
897b81e566
commit
036c878843
@@ -96,7 +96,7 @@ func TestTemplateDecorateFunc(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_configureAppChildPlugin(t *testing.T) {
|
||||
t.Run("When setting paths based on core plugin on Windows", func(t *testing.T) {
|
||||
t.Run("Child plugin will inherit parent version information when version is empty", func(t *testing.T) {
|
||||
child := &plugins.Plugin{
|
||||
FS: fakes.NewFakePluginFiles("c:\\grafana\\public\\app\\plugins\\app\\testdata-app\\datasources\\datasource"),
|
||||
}
|
||||
@@ -104,6 +104,7 @@ func Test_configureAppChildPlugin(t *testing.T) {
|
||||
JSONData: plugins.JSONData{
|
||||
Type: plugins.TypeApp,
|
||||
ID: "testdata-app",
|
||||
Info: plugins.Info{Version: "1.0.0"},
|
||||
},
|
||||
Class: plugins.ClassCore,
|
||||
FS: fakes.NewFakePluginFiles("c:\\grafana\\public\\app\\plugins\\app\\testdata-app"),
|
||||
@@ -112,19 +113,22 @@ func Test_configureAppChildPlugin(t *testing.T) {
|
||||
|
||||
configureAppChildPlugin(parent, child)
|
||||
|
||||
require.Equal(t, "core:plugin/testdata-app/datasources/datasource", child.Module)
|
||||
require.Equal(t, "testdata-app", child.IncludedInAppID)
|
||||
require.Equal(t, "public/app/plugins/app/testdata-app", child.BaseURL)
|
||||
require.Equal(t, parent.Info.Version, child.Info.Version)
|
||||
})
|
||||
|
||||
t.Run("When setting paths based on external plugin", func(t *testing.T) {
|
||||
t.Run("Child plugin will not inherit parent version information when version is non-empty", func(t *testing.T) {
|
||||
child := &plugins.Plugin{
|
||||
FS: fakes.NewFakePluginFiles("/plugins/parent-app/child-panel"),
|
||||
JSONData: plugins.JSONData{
|
||||
Info: plugins.Info{Version: "2.0.2"},
|
||||
},
|
||||
}
|
||||
parent := &plugins.Plugin{
|
||||
JSONData: plugins.JSONData{
|
||||
Type: plugins.TypeApp,
|
||||
ID: "testdata-app",
|
||||
Info: plugins.Info{Version: "2.0.0"},
|
||||
},
|
||||
Class: plugins.ClassExternal,
|
||||
FS: fakes.NewFakePluginFiles("/plugins/parent-app"),
|
||||
@@ -133,9 +137,8 @@ func Test_configureAppChildPlugin(t *testing.T) {
|
||||
|
||||
configureAppChildPlugin(parent, child)
|
||||
|
||||
require.Equal(t, "public/plugins/testdata-app/child-panel/module.js", child.Module)
|
||||
require.Equal(t, "testdata-app", child.IncludedInAppID)
|
||||
require.Equal(t, "plugins/parent-app", child.BaseURL)
|
||||
require.NotEqual(t, parent.Info.Version, child.Info.Version)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user