@perses-dev/plugin-system 0.23.1 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/cjs/model/calculations.js +6 -1
  2. package/dist/cjs/model/index.js +2 -2
  3. package/dist/model/calculations.d.ts +1 -1
  4. package/dist/model/calculations.d.ts.map +1 -1
  5. package/dist/model/calculations.js +7 -1
  6. package/dist/model/calculations.js.map +1 -1
  7. package/dist/model/index.d.ts +2 -2
  8. package/dist/model/index.d.ts.map +1 -1
  9. package/dist/model/index.js +2 -2
  10. package/dist/model/index.js.map +1 -1
  11. package/dist/model/time-series-queries.d.ts +3 -4
  12. package/dist/model/time-series-queries.d.ts.map +1 -1
  13. package/dist/model/time-series-queries.js.map +1 -1
  14. package/package.json +5 -4
  15. package/dist/cjs/components/CalculationSelector/CalculationSelector.test.js +0 -65
  16. package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.test.js +0 -107
  17. package/dist/cjs/components/PluginEditor/PluginEditor.test.js +0 -150
  18. package/dist/cjs/components/PluginKindSelect.test.js +0 -86
  19. package/dist/cjs/components/PluginRegistry/PluginRegistry.test.js +0 -144
  20. package/dist/cjs/components/PluginSpecEditor.test.js +0 -92
  21. package/dist/components/CalculationSelector/CalculationSelector.test.d.ts +0 -2
  22. package/dist/components/CalculationSelector/CalculationSelector.test.d.ts.map +0 -1
  23. package/dist/components/CalculationSelector/CalculationSelector.test.js +0 -58
  24. package/dist/components/CalculationSelector/CalculationSelector.test.js.map +0 -1
  25. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.d.ts +0 -2
  26. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.d.ts.map +0 -1
  27. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js +0 -100
  28. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js.map +0 -1
  29. package/dist/components/PluginEditor/PluginEditor.test.d.ts +0 -2
  30. package/dist/components/PluginEditor/PluginEditor.test.d.ts.map +0 -1
  31. package/dist/components/PluginEditor/PluginEditor.test.js +0 -143
  32. package/dist/components/PluginEditor/PluginEditor.test.js.map +0 -1
  33. package/dist/components/PluginKindSelect.test.d.ts +0 -2
  34. package/dist/components/PluginKindSelect.test.d.ts.map +0 -1
  35. package/dist/components/PluginKindSelect.test.js +0 -79
  36. package/dist/components/PluginKindSelect.test.js.map +0 -1
  37. package/dist/components/PluginRegistry/PluginRegistry.test.d.ts +0 -2
  38. package/dist/components/PluginRegistry/PluginRegistry.test.d.ts.map +0 -1
  39. package/dist/components/PluginRegistry/PluginRegistry.test.js +0 -137
  40. package/dist/components/PluginRegistry/PluginRegistry.test.js.map +0 -1
  41. package/dist/components/PluginSpecEditor.test.d.ts +0 -2
  42. package/dist/components/PluginSpecEditor.test.d.ts.map +0 -1
  43. package/dist/components/PluginSpecEditor.test.js +0 -85
  44. package/dist/components/PluginSpecEditor.test.js.map +0 -1
@@ -1,79 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- import userEvent from '@testing-library/user-event';
15
- import { screen } from '@testing-library/react';
16
- import { renderWithContext } from '../test';
17
- import { PluginKindSelect } from './PluginKindSelect';
18
- describe('PluginKindSelect', ()=>{
19
- const renderComponent = (props)=>{
20
- return renderWithContext(/*#__PURE__*/ _jsx(PluginKindSelect, {
21
- ...props
22
- }));
23
- };
24
- // Opens the select and waits for loading to finish (i.e. options to appear)
25
- const openSelect = async ()=>{
26
- const select = screen.getByRole('button');
27
- userEvent.click(select);
28
- const options = await screen.findAllByRole('option');
29
- return options;
30
- };
31
- it('displays the list of plugins for a plugin type', async ()=>{
32
- renderComponent({
33
- pluginType: 'Panel',
34
- value: ''
35
- });
36
- // Open the select and verify the list of options from the test plugin data
37
- const options = await openSelect();
38
- expect(options).toHaveLength(2);
39
- let option = screen.queryByRole('option', {
40
- name: 'Bert Panel 1'
41
- });
42
- expect(option).toBeInTheDocument();
43
- option = screen.queryByRole('option', {
44
- name: 'Bert Panel 2'
45
- });
46
- expect(option).toBeInTheDocument();
47
- });
48
- it('shows the correct selected value', async ()=>{
49
- renderComponent({
50
- pluginType: 'Variable',
51
- value: 'ErnieVariable'
52
- });
53
- // Use findByRole to wait for loading to finish and selected value to appear
54
- const select = await screen.findByRole('button', {
55
- name: 'Ernie Variable'
56
- });
57
- expect(select).toBeInTheDocument();
58
- });
59
- it('can select new value', async ()=>{
60
- let onChangeValue = undefined;
61
- const onChange = jest.fn((e)=>{
62
- onChangeValue = e.target.value;
63
- });
64
- renderComponent({
65
- pluginType: 'Variable',
66
- value: 'ErnieVariable',
67
- onChange
68
- });
69
- await openSelect();
70
- const newOption = screen.getByRole('option', {
71
- name: 'Bert Variable'
72
- });
73
- userEvent.click(newOption);
74
- expect(onChange).toHaveBeenCalledTimes(1);
75
- expect(onChangeValue).toBe('BertVariable');
76
- });
77
- });
78
-
79
- //# sourceMappingURL=PluginKindSelect.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/PluginKindSelect.test.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport userEvent from '@testing-library/user-event';\nimport { screen } from '@testing-library/react';\nimport { renderWithContext } from '../test';\nimport { PluginKindSelect, PluginKindSelectProps } from './PluginKindSelect';\n\ndescribe('PluginKindSelect', () => {\n const renderComponent = (props: PluginKindSelectProps) => {\n return renderWithContext(<PluginKindSelect {...props} />);\n };\n\n // Opens the select and waits for loading to finish (i.e. options to appear)\n const openSelect = async () => {\n const select = screen.getByRole('button');\n userEvent.click(select);\n const options = await screen.findAllByRole('option');\n return options;\n };\n\n it('displays the list of plugins for a plugin type', async () => {\n renderComponent({\n pluginType: 'Panel',\n value: '',\n });\n\n // Open the select and verify the list of options from the test plugin data\n const options = await openSelect();\n expect(options).toHaveLength(2);\n\n let option = screen.queryByRole('option', { name: 'Bert Panel 1' });\n expect(option).toBeInTheDocument();\n option = screen.queryByRole('option', { name: 'Bert Panel 2' });\n expect(option).toBeInTheDocument();\n });\n\n it('shows the correct selected value', async () => {\n renderComponent({\n pluginType: 'Variable',\n value: 'ErnieVariable',\n });\n\n // Use findByRole to wait for loading to finish and selected value to appear\n const select = await screen.findByRole('button', { name: 'Ernie Variable' });\n expect(select).toBeInTheDocument();\n });\n\n it('can select new value', async () => {\n let onChangeValue: string | undefined = undefined;\n const onChange = jest.fn((e) => {\n onChangeValue = e.target.value;\n });\n renderComponent({\n pluginType: 'Variable',\n value: 'ErnieVariable',\n onChange,\n });\n\n await openSelect();\n const newOption = screen.getByRole('option', { name: 'Bert Variable' });\n userEvent.click(newOption);\n\n expect(onChange).toHaveBeenCalledTimes(1);\n expect(onChangeValue).toBe('BertVariable');\n });\n});\n"],"names":["userEvent","screen","renderWithContext","PluginKindSelect","describe","renderComponent","props","openSelect","select","getByRole","click","options","findAllByRole","it","pluginType","value","expect","toHaveLength","option","queryByRole","name","toBeInTheDocument","findByRole","onChangeValue","undefined","onChange","jest","fn","e","target","newOption","toHaveBeenCalledTimes","toBe"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CA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export {};
2
- //# sourceMappingURL=PluginRegistry.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PluginRegistry.test.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/PluginRegistry.test.tsx"],"names":[],"mappings":""}
@@ -1,137 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import React from 'react';
15
- import { screen } from '@testing-library/react';
16
- import { useListPluginMetadata, usePlugin } from '../../runtime';
17
- import { renderWithContext } from '../../test';
18
- describe('PluginRegistry', ()=>{
19
- const renderPluginRegistry = (children)=>{
20
- renderWithContext(children);
21
- };
22
- it('can load a plugin that exists', async ()=>{
23
- renderPluginRegistry(/*#__PURE__*/ _jsx(PluginConsumer, {
24
- pluginType: "Variable",
25
- kind: "ErnieVariable"
26
- }));
27
- const hasPlugin = await screen.findByText('Has plugin: true', undefined, {
28
- timeout: 3000
29
- });
30
- expect(hasPlugin).toBeInTheDocument();
31
- });
32
- it('errors when plugin is not installed', async ()=>{
33
- // This plugin is not in the test metadata at all
34
- renderPluginRegistry(/*#__PURE__*/ _jsx(PluginConsumer, {
35
- pluginType: "TimeSeriesQuery",
36
- kind: "NotInstalled"
37
- }));
38
- const error = await screen.findByText(/error:/i);
39
- expect(error).toBeInTheDocument();
40
- expect(error).toHaveTextContent(/not installed/i);
41
- });
42
- it('errors when plugin is missing from the module', async ()=>{
43
- // This plugin is in the test metadata, but the code is missing from the module
44
- renderPluginRegistry(/*#__PURE__*/ _jsx(PluginConsumer, {
45
- pluginType: "Variable",
46
- kind: "MissingErnieVariable"
47
- }));
48
- const error = await screen.findByText(/error:/i);
49
- expect(error).toBeInTheDocument();
50
- expect(error).toHaveTextContent(/missing/i);
51
- });
52
- it('lists metadata for plugin metadata that exists', async ()=>{
53
- // There should be 3 variable plugins across both test modules
54
- renderPluginRegistry(/*#__PURE__*/ _jsx(MetadataConsumer, {
55
- pluginType: "Variable"
56
- }));
57
- const table = await screen.findByRole('table');
58
- expect(table).toBeInTheDocument();
59
- const rows = screen.getAllByRole('row');
60
- expect(rows).toHaveLength(3);
61
- });
62
- it('lists metadata for plugin types with no plugins available', async ()=>{
63
- // There are no TimeSeriesQuery plugins in any of the test modules
64
- renderPluginRegistry(/*#__PURE__*/ _jsx(MetadataConsumer, {
65
- pluginType: "TimeSeriesQuery"
66
- }));
67
- const table = await screen.findByRole('table');
68
- expect(table).toBeInTheDocument();
69
- const rows = screen.queryAllByRole('row');
70
- expect(rows).toHaveLength(0);
71
- });
72
- });
73
- // A helper component for testing the PluginRegistry by calling usePlugin to load a plugin
74
- const PluginConsumer = (props)=>{
75
- const { data: plugin , isLoading , error } = usePlugin(props.pluginType, props.kind);
76
- if (error) {
77
- return /*#__PURE__*/ _jsxs("div", {
78
- children: [
79
- "Error: ",
80
- error.message
81
- ]
82
- });
83
- }
84
- if (isLoading) {
85
- return /*#__PURE__*/ _jsx("div", {
86
- children: "Loading"
87
- });
88
- }
89
- return /*#__PURE__*/ _jsxs("div", {
90
- children: [
91
- "Has plugin: ",
92
- (plugin !== undefined).toString()
93
- ]
94
- });
95
- };
96
- // A helper component for testing the PluginRegistry metadata APIs by calling useListPluginMetadata
97
- const MetadataConsumer = (props)=>{
98
- const { data: pluginMetadata , isLoading , error } = useListPluginMetadata(props.pluginType);
99
- if (error) {
100
- return /*#__PURE__*/ _jsxs("div", {
101
- children: [
102
- "Error: ",
103
- error.message
104
- ]
105
- });
106
- }
107
- if (isLoading) {
108
- return /*#__PURE__*/ _jsx("div", {
109
- children: "Loading"
110
- });
111
- }
112
- if (pluginMetadata === undefined) {
113
- return null;
114
- }
115
- return /*#__PURE__*/ _jsx("table", {
116
- children: /*#__PURE__*/ _jsx("tbody", {
117
- children: pluginMetadata.map((item)=>/*#__PURE__*/ _jsxs("tr", {
118
- children: [
119
- /*#__PURE__*/ _jsx("td", {
120
- children: item.pluginType
121
- }),
122
- /*#__PURE__*/ _jsx("td", {
123
- children: item.kind
124
- }),
125
- /*#__PURE__*/ _jsx("td", {
126
- children: item.display.name
127
- }),
128
- /*#__PURE__*/ _jsx("td", {
129
- children: item.display.description
130
- })
131
- ]
132
- }, item.kind))
133
- })
134
- });
135
- };
136
-
137
- //# sourceMappingURL=PluginRegistry.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/PluginRegistry/PluginRegistry.test.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React from 'react';\nimport { screen } from '@testing-library/react';\nimport { PluginType } from '../../model';\nimport { useListPluginMetadata, usePlugin } from '../../runtime';\nimport { renderWithContext } from '../../test';\n\ndescribe('PluginRegistry', () => {\n const renderPluginRegistry = (children: React.ReactNode) => {\n renderWithContext(children);\n };\n\n it('can load a plugin that exists', async () => {\n renderPluginRegistry(<PluginConsumer pluginType=\"Variable\" kind=\"ErnieVariable\" />);\n\n const hasPlugin = await screen.findByText('Has plugin: true', undefined, { timeout: 3000 });\n expect(hasPlugin).toBeInTheDocument();\n });\n\n it('errors when plugin is not installed', async () => {\n // This plugin is not in the test metadata at all\n renderPluginRegistry(<PluginConsumer pluginType=\"TimeSeriesQuery\" kind=\"NotInstalled\" />);\n\n const error = await screen.findByText(/error:/i);\n expect(error).toBeInTheDocument();\n expect(error).toHaveTextContent(/not installed/i);\n });\n\n it('errors when plugin is missing from the module', async () => {\n // This plugin is in the test metadata, but the code is missing from the module\n renderPluginRegistry(<PluginConsumer pluginType=\"Variable\" kind=\"MissingErnieVariable\" />);\n\n const error = await screen.findByText(/error:/i);\n expect(error).toBeInTheDocument();\n expect(error).toHaveTextContent(/missing/i);\n });\n\n it('lists metadata for plugin metadata that exists', async () => {\n // There should be 3 variable plugins across both test modules\n renderPluginRegistry(<MetadataConsumer pluginType=\"Variable\" />);\n\n const table = await screen.findByRole('table');\n expect(table).toBeInTheDocument();\n const rows = screen.getAllByRole('row');\n expect(rows).toHaveLength(3);\n });\n\n it('lists metadata for plugin types with no plugins available', async () => {\n // There are no TimeSeriesQuery plugins in any of the test modules\n renderPluginRegistry(<MetadataConsumer pluginType=\"TimeSeriesQuery\" />);\n\n const table = await screen.findByRole('table');\n expect(table).toBeInTheDocument();\n const rows = screen.queryAllByRole('row');\n expect(rows).toHaveLength(0);\n });\n});\n\n// A helper component for testing the PluginRegistry by calling usePlugin to load a plugin\nconst PluginConsumer = (props: { pluginType: PluginType; kind: string }) => {\n const { data: plugin, isLoading, error } = usePlugin(props.pluginType, props.kind);\n if (error) {\n return <div>Error: {(error as Error).message}</div>;\n }\n if (isLoading) {\n return <div>Loading</div>;\n }\n return <div>Has plugin: {(plugin !== undefined).toString()}</div>;\n};\n\n// A helper component for testing the PluginRegistry metadata APIs by calling useListPluginMetadata\nconst MetadataConsumer = (props: { pluginType: PluginType }) => {\n const { data: pluginMetadata, isLoading, error } = useListPluginMetadata(props.pluginType);\n if (error) {\n return <div>Error: {(error as Error).message}</div>;\n }\n if (isLoading) {\n return <div>Loading</div>;\n }\n\n if (pluginMetadata === undefined) {\n return null;\n }\n\n return (\n <table>\n <tbody>\n {pluginMetadata.map((item) => (\n <tr key={item.kind}>\n <td>{item.pluginType}</td>\n <td>{item.kind}</td>\n <td>{item.display.name}</td>\n <td>{item.display.description}</td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n};\n"],"names":["React","screen","useListPluginMetadata","usePlugin","renderWithContext","describe","renderPluginRegistry","children","it","PluginConsumer","pluginType","kind","hasPlugin","findByText","undefined","timeout","expect","toBeInTheDocument","error","toHaveTextContent","MetadataConsumer","table","findByRole","rows","getAllByRole","toHaveLength","queryAllByRole","props","data","plugin","isLoading","div","message","toString","pluginMetadata","tbody","map","item","tr","td","display","name","description"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,OAAOA,KAAK,MAAM,OAAO,CAAC;AAC1B,SAASC,MAAM,QAAQ,wBAAwB,CAAC;AAEhD,SAASC,qBAAqB,EAAEC,SAAS,QAAQ,eAAe,CAAC;AACjE,SAASC,iBAAiB,QAAQ,YAAY,CAAC;AAE/CC,QAAQ,CAAC,gBAAgB,EAAE,IAAM;IAC/B,MAAMC,oBAAoB,GAAG,CAACC,QAAyB,GAAK;QAC1DH,iBAAiB,CAACG,QAAQ,CAAC,CAAC;IAC9B,CAAC,AAAC;IAEFC,EAAE,CAAC,+BAA+B,EAAE,UAAY;QAC9CF,oBAAoB,eAAC,KAACG,cAAc;YAACC,UAAU,EAAC,UAAU;YAACC,IAAI,EAAC,eAAe;UAAG,CAAC,CAAC;QAEpF,MAAMC,SAAS,GAAG,MAAMX,MAAM,CAACY,UAAU,CAAC,kBAAkB,EAAEC,SAAS,EAAE;YAAEC,OAAO,EAAE,IAAI;SAAE,CAAC,AAAC;QAC5FC,MAAM,CAACJ,SAAS,CAAC,CAACK,iBAAiB,EAAE,CAAC;IACxC,CAAC,CAAC,CAAC;IAEHT,EAAE,CAAC,qCAAqC,EAAE,UAAY;QACp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UAAO,CAAC;IACtD,CAAC;IACD,IAAIF,SAAS,EAAE;QACb,qBAAO,KAACC,KAAG;sBAAC,SAAO;UAAM,CAAC;IAC5B,CAAC;IAED,IAAIG,cAAc,KAAKpB,SAAS,EAAE;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qBACE,KAACO,OAAK;kBACJ,cAAA,KAACc,OAAK;sBACHD,cAAc,CAACE,GAAG,CAAC,CAACC,IAAI,iBACvB,MAACC,IAAE;;sCACD,KAACC,IAAE;sCAAEF,IAAI,CAAC3B,UAAU;0BAAM;sCAC1B,KAAC6B,IAAE;sCAAEF,IAAI,CAAC1B,IAAI;0BAAM;sCACpB,KAAC4B,IAAE;sCAAEF,IAAI,CAACG,OAAO,CAACC,IAAI;0BAAM;sCAC5B,KAACF,IAAE;sCAAEF,IAAI,CAACG,OAAO,CAACE,WAAW;0BAAM;;mBAJ5BL,IAAI,CAAC1B,IAAI,CAKb,AACN,CAAC;UACI;MACF,CACR;AACJ,CAAC,AAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=PluginSpecEditor.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PluginSpecEditor.test.d.ts","sourceRoot":"","sources":["../../src/components/PluginSpecEditor.test.tsx"],"names":[],"mappings":""}
@@ -1,85 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- import userEvent from '@testing-library/user-event';
15
- import { screen } from '@testing-library/react';
16
- import { renderWithContext } from '../test';
17
- import { PluginSpecEditor } from './PluginSpecEditor';
18
- describe('PluginSpecEditor', ()=>{
19
- const renderComponent = (props)=>{
20
- renderWithContext(/*#__PURE__*/ _jsx(PluginSpecEditor, {
21
- ...props
22
- }));
23
- };
24
- describe('Panel plugin', ()=>{
25
- it('should show query and json editors', async ()=>{
26
- renderComponent({
27
- pluginType: 'Panel',
28
- pluginKind: 'BertPanel1',
29
- value: {},
30
- onChange: jest.fn()
31
- });
32
- const queryTab = await screen.findByLabelText('Query');
33
- expect(queryTab).toBeInTheDocument();
34
- const editor = await screen.findByLabelText('BertPanel1 editor');
35
- expect(editor).toBeInTheDocument();
36
- const jsonEditor = await screen.findByLabelText('JSON');
37
- expect(jsonEditor).toBeInTheDocument();
38
- });
39
- it('should display other options editor components', async ()=>{
40
- renderComponent({
41
- pluginType: 'Panel',
42
- pluginKind: 'BertPanel2',
43
- value: {},
44
- onChange: jest.fn()
45
- });
46
- const settingsTab = await screen.findByLabelText('Settings');
47
- expect(settingsTab).toBeInTheDocument();
48
- const editor = await screen.findByLabelText('BertPanel2 editor');
49
- expect(editor).toBeInTheDocument();
50
- const customTab = await screen.findByLabelText('Custom Tab');
51
- expect(customTab).toBeInTheDocument();
52
- const jsonEditor = await screen.findByLabelText('JSON');
53
- expect(jsonEditor).toBeInTheDocument();
54
- });
55
- });
56
- it('propagates value changes', async ()=>{
57
- const onChange = jest.fn();
58
- renderComponent({
59
- pluginType: 'Panel',
60
- pluginKind: 'BertPanel1',
61
- value: {
62
- option1: 'Option1Value'
63
- },
64
- onChange
65
- });
66
- const editor = await screen.findByLabelText('BertPanel1 editor');
67
- expect(editor).toHaveValue('Option1Value');
68
- userEvent.clear(editor);
69
- expect(onChange).toHaveBeenCalledWith({
70
- option1: ''
71
- });
72
- });
73
- it('shows an error if plugin fails to load', async ()=>{
74
- renderComponent({
75
- pluginType: 'Variable',
76
- pluginKind: 'DoesNotExist',
77
- value: {},
78
- onChange: jest.fn()
79
- });
80
- const errorAlert = await screen.findByRole('alert');
81
- expect(errorAlert).toHaveTextContent(/doesnotexist/i);
82
- });
83
- });
84
-
85
- //# sourceMappingURL=PluginSpecEditor.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/PluginSpecEditor.test.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport userEvent from '@testing-library/user-event';\nimport { screen } from '@testing-library/react';\nimport { renderWithContext } from '../test';\nimport { PluginSpecEditor, PluginSpecEditorProps } from './PluginSpecEditor';\n\ndescribe('PluginSpecEditor', () => {\n const renderComponent = (props: PluginSpecEditorProps) => {\n renderWithContext(<PluginSpecEditor {...props} />);\n };\n\n describe('Panel plugin', () => {\n it('should show query and json editors', async () => {\n renderComponent({ pluginType: 'Panel', pluginKind: 'BertPanel1', value: {}, onChange: jest.fn() });\n const queryTab = await screen.findByLabelText('Query');\n expect(queryTab).toBeInTheDocument();\n const editor = await screen.findByLabelText('BertPanel1 editor');\n expect(editor).toBeInTheDocument();\n const jsonEditor = await screen.findByLabelText('JSON');\n expect(jsonEditor).toBeInTheDocument();\n });\n\n it('should display other options editor components', async () => {\n renderComponent({ pluginType: 'Panel', pluginKind: 'BertPanel2', value: {}, onChange: jest.fn() });\n const settingsTab = await screen.findByLabelText('Settings');\n expect(settingsTab).toBeInTheDocument();\n const editor = await screen.findByLabelText('BertPanel2 editor');\n expect(editor).toBeInTheDocument();\n const customTab = await screen.findByLabelText('Custom Tab');\n expect(customTab).toBeInTheDocument();\n const jsonEditor = await screen.findByLabelText('JSON');\n expect(jsonEditor).toBeInTheDocument();\n });\n });\n\n it('propagates value changes', async () => {\n const onChange = jest.fn();\n renderComponent({ pluginType: 'Panel', pluginKind: 'BertPanel1', value: { option1: 'Option1Value' }, onChange });\n\n const editor = await screen.findByLabelText('BertPanel1 editor');\n expect(editor).toHaveValue('Option1Value');\n userEvent.clear(editor);\n expect(onChange).toHaveBeenCalledWith({ option1: '' });\n });\n\n it('shows an error if plugin fails to load', async () => {\n renderComponent({ pluginType: 'Variable', pluginKind: 'DoesNotExist', value: {}, onChange: jest.fn() });\n const errorAlert = await screen.findByRole('alert');\n expect(errorAlert).toHaveTextContent(/doesnotexist/i);\n });\n});\n"],"names":["userEvent","screen","renderWithContext","PluginSpecEditor","describe","renderComponent","props","it","pluginType","pluginKind","value","onChange","jest","fn","queryTab","findByLabelText","expect","toBeInTheDocument","editor","jsonEditor","settingsTab","customTab","option1","toHaveValue","clear","toHaveBeenCalledWith","errorAlert","findByRole","toHaveTextContent"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,OAAOA,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,MAAM,QAAQ,wBAAwB,CAAC;AAChD,SAASC,iBAAiB,QAAQ,SAAS,CAAC;AAC5C,SAASC,gBAAgB,QAA+B,oBAAoB,CAAC;AAE7EC,QAAQ,CAAC,kBAAkB,EAAE,IAAM;IACjC,MAAMC,eAAe,GAAG,CAACC,KAA4B,GAAK;QACxDJ,iBAAiB,eAAC,KAACC,gBAAgB;YAAE,GAAGG,KAAK;UAAI,CAAC,CAAC;IACrD,CAAC,AAAC;IAEFF,QAAQ,CAAC,cAAc,EAAE,IAAM;QAC7BG,EAAE,CAAC,oCAAoC,EAAE,UAAY;YACnDF,eAAe,CAAC;gBAAEG,UAAU,EAAE,OAAO;gBAAEC,UAAU,EAAE,YAAY;gBA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