|
|
@@ -16,7 +16,7 @@ jest.mock('app/core/core', () => {
|
|
|
/* tslint:disable:import-blacklist */
|
|
|
import System from 'systemjs/dist/system.js';
|
|
|
|
|
|
-import { AppPluginMeta, PluginMetaInfo, PluginType, AppPlugin } from '@grafana/ui';
|
|
|
+import { AppPluginMeta, PluginMetaInfo, PluginType, PluginIncludeType, AppPlugin } from '@grafana/ui';
|
|
|
import { importAppPlugin } from './plugin_loader';
|
|
|
|
|
|
class MyCustomApp extends AppPlugin {
|
|
|
@@ -66,3 +66,47 @@ describe('Load App', () => {
|
|
|
expect(app.calledTwice).toBeTruthy();
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+import { ExampleConfigCtrl as ConfigCtrl } from 'app/plugins/app/example-app/legacy/config';
|
|
|
+import { AngularExamplePageCtrl } from 'app/plugins/app/example-app/legacy/angular_example_page';
|
|
|
+
|
|
|
+describe('Load Legacy App', () => {
|
|
|
+ const app = {
|
|
|
+ ConfigCtrl,
|
|
|
+ AngularExamplePageCtrl, // Must match `pages.component` in plugin.json
|
|
|
+ };
|
|
|
+
|
|
|
+ const modulePath = 'my/custom/legacy/plugin/module';
|
|
|
+
|
|
|
+ beforeAll(() => {
|
|
|
+ System.set(modulePath, System.newModule(app));
|
|
|
+ });
|
|
|
+
|
|
|
+ afterAll(() => {
|
|
|
+ System.delete(modulePath);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should call init and set meta for legacy app', async () => {
|
|
|
+ const meta: AppPluginMeta = {
|
|
|
+ id: 'test-app',
|
|
|
+ module: modulePath,
|
|
|
+ baseUrl: 'xxx',
|
|
|
+ info: {} as PluginMetaInfo,
|
|
|
+ type: PluginType.app,
|
|
|
+ name: 'test',
|
|
|
+ includes: [
|
|
|
+ {
|
|
|
+ type: PluginIncludeType.page,
|
|
|
+ name: 'Example Page',
|
|
|
+ component: 'AngularExamplePageCtrl',
|
|
|
+ role: 'Viewer',
|
|
|
+ addToNav: false,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+
|
|
|
+ const loaded = await importAppPlugin(meta);
|
|
|
+ expect(loaded).toHaveProperty('angularPages');
|
|
|
+ expect(loaded.angularPages).toHaveProperty('AngularExamplePageCtrl', AngularExamplePageCtrl);
|
|
|
+ });
|
|
|
+});
|