@perses-dev/plugin-system 0.0.0-snapshot-embed-import-errors-8906900 → 0.0.0-snapshot-test-internal-dep-dd238ac
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.
- package/dist/cjs/components/CalculationSelector/CalculationSelector.js +1 -1
- package/dist/cjs/components/CalculationSelector/index.js +1 -1
- package/dist/cjs/components/DatasourceSelect.js +1 -1
- package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +5 -48
- package/dist/cjs/components/OptionsEditorTabs/TabPanel.js +1 -1
- package/dist/cjs/components/OptionsEditorTabs/index.js +1 -1
- package/dist/cjs/components/PluginEditor/PluginEditor.js +1 -1
- package/dist/cjs/components/PluginEditor/index.js +1 -1
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +1 -1
- package/dist/cjs/components/PluginKindSelect.js +1 -1
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +1 -1
- package/dist/cjs/components/PluginRegistry/index.js +1 -1
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +1 -1
- package/dist/cjs/components/PluginSpecEditor.js +39 -5
- package/dist/cjs/components/TimeSeriesQueryEditor.js +1 -1
- package/dist/cjs/components/index.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/model/calculations.js +11 -13
- package/dist/cjs/model/datasource.js +1 -1
- package/dist/cjs/model/index.js +3 -3
- package/dist/cjs/model/panels.js +7 -1
- package/dist/cjs/model/plugin-base.js +1 -1
- package/dist/cjs/model/plugin-loading.js +1 -1
- package/dist/cjs/model/plugins.js +1 -1
- package/dist/cjs/model/time-series-queries.js +1 -1
- package/dist/cjs/model/variables.js +1 -1
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
- package/dist/cjs/runtime/TimeRangeProvider/index.js +1 -1
- package/dist/cjs/runtime/TimeRangeProvider/query-params.js +1 -1
- package/dist/cjs/runtime/datasources.js +1 -1
- package/dist/cjs/runtime/index.js +1 -1
- package/dist/cjs/runtime/plugin-registry.js +1 -1
- package/dist/cjs/runtime/template-variables.js +1 -1
- package/dist/cjs/runtime/time-series-queries.js +1 -1
- package/dist/cjs/test/index.js +1 -1
- package/dist/cjs/test/render.js +1 -1
- package/dist/cjs/test/setup-tests.js +1 -1
- package/dist/cjs/test/test-plugins/bert/index.js +33 -20
- package/dist/cjs/test/test-plugins/ernie/index.js +1 -1
- package/dist/cjs/test/test-plugins/index.js +1 -1
- package/dist/cjs/test-utils/index.js +1 -1
- package/dist/cjs/test-utils/mock-plugin-registry.js +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
- package/dist/components/CalculationSelector/index.js +1 -1
- package/dist/components/CalculationSelector/index.js.map +1 -1
- package/dist/components/DatasourceSelect.js +1 -1
- package/dist/components/DatasourceSelect.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +3 -24
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +5 -48
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/OptionsEditorTabs/TabPanel.js +1 -1
- package/dist/components/OptionsEditorTabs/TabPanel.js.map +1 -1
- package/dist/components/OptionsEditorTabs/index.js +1 -1
- package/dist/components/OptionsEditorTabs/index.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +1 -1
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/index.js +1 -1
- package/dist/components/PluginEditor/index.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/PluginKindSelect.js +1 -1
- package/dist/components/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/index.js +1 -1
- package/dist/components/PluginRegistry/index.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/PluginSpecEditor.d.ts.map +1 -1
- package/dist/components/PluginSpecEditor.js +40 -6
- package/dist/components/PluginSpecEditor.js.map +1 -1
- package/dist/components/TimeSeriesQueryEditor.js +1 -1
- package/dist/components/TimeSeriesQueryEditor.js.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model/calculations.d.ts +1 -1
- package/dist/model/calculations.d.ts.map +1 -1
- package/dist/model/calculations.js +9 -5
- package/dist/model/calculations.js.map +1 -1
- package/dist/model/datasource.js +1 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/index.d.ts +2 -2
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +3 -3
- package/dist/model/index.js.map +1 -1
- package/dist/model/panels.d.ts +14 -2
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js +2 -2
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugin-base.d.ts +1 -1
- package/dist/model/plugin-base.d.ts.map +1 -1
- package/dist/model/plugin-base.js +1 -1
- package/dist/model/plugin-base.js.map +1 -1
- package/dist/model/plugin-loading.js +1 -1
- package/dist/model/plugin-loading.js.map +1 -1
- package/dist/model/plugins.js +1 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/model/time-series-queries.d.ts +3 -4
- package/dist/model/time-series-queries.d.ts.map +1 -1
- package/dist/model/time-series-queries.js +1 -1
- package/dist/model/time-series-queries.js.map +1 -1
- package/dist/model/variables.js +1 -1
- package/dist/model/variables.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/index.js +1 -1
- package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
- package/dist/runtime/datasources.js +1 -1
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/plugin-registry.js +1 -1
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/template-variables.js +1 -1
- package/dist/runtime/template-variables.js.map +1 -1
- package/dist/runtime/time-series-queries.js +1 -1
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/test/index.js +1 -1
- package/dist/test/index.js.map +1 -1
- package/dist/test/render.js +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.js +1 -1
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
- package/dist/test/test-plugins/bert/index.js +33 -20
- package/dist/test/test-plugins/bert/index.js.map +1 -1
- package/dist/test/test-plugins/ernie/index.js +1 -1
- package/dist/test/test-plugins/ernie/index.js.map +1 -1
- package/dist/test/test-plugins/index.js +1 -1
- package/dist/test/test-plugins/index.js.map +1 -1
- package/dist/test-utils/index.js +1 -1
- package/dist/test-utils/index.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js +1 -1
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/package.json +5 -4
- package/dist/cjs/components/CalculationSelector/CalculationSelector.test.js +0 -65
- package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.test.js +0 -167
- package/dist/cjs/components/PluginEditor/PluginEditor.test.js +0 -150
- package/dist/cjs/components/PluginKindSelect.test.js +0 -86
- package/dist/cjs/components/PluginRegistry/PluginRegistry.test.js +0 -144
- package/dist/cjs/components/PluginSpecEditor.test.js +0 -70
- package/dist/components/CalculationSelector/CalculationSelector.test.d.ts +0 -2
- package/dist/components/CalculationSelector/CalculationSelector.test.d.ts.map +0 -1
- package/dist/components/CalculationSelector/CalculationSelector.test.js +0 -58
- package/dist/components/CalculationSelector/CalculationSelector.test.js.map +0 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.d.ts +0 -2
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.d.ts.map +0 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js +0 -160
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js.map +0 -1
- package/dist/components/PluginEditor/PluginEditor.test.d.ts +0 -2
- package/dist/components/PluginEditor/PluginEditor.test.d.ts.map +0 -1
- package/dist/components/PluginEditor/PluginEditor.test.js +0 -143
- package/dist/components/PluginEditor/PluginEditor.test.js.map +0 -1
- package/dist/components/PluginKindSelect.test.d.ts +0 -2
- package/dist/components/PluginKindSelect.test.d.ts.map +0 -1
- package/dist/components/PluginKindSelect.test.js +0 -79
- package/dist/components/PluginKindSelect.test.js.map +0 -1
- package/dist/components/PluginRegistry/PluginRegistry.test.d.ts +0 -2
- package/dist/components/PluginRegistry/PluginRegistry.test.d.ts.map +0 -1
- package/dist/components/PluginRegistry/PluginRegistry.test.js +0 -137
- package/dist/components/PluginRegistry/PluginRegistry.test.js.map +0 -1
- package/dist/components/PluginSpecEditor.test.d.ts +0 -2
- package/dist/components/PluginSpecEditor.test.d.ts.map +0 -1
- package/dist/components/PluginSpecEditor.test.js +0 -63
- package/dist/components/PluginSpecEditor.test.js.map +0 -1
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// Copyright 2022 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 { render, screen } from '@testing-library/react';
|
|
15
|
-
import userEvent from '@testing-library/user-event';
|
|
16
|
-
import { CalculationSelector } from './CalculationSelector';
|
|
17
|
-
describe('CalculationSelector', ()=>{
|
|
18
|
-
const renderCalculationSelector = (value, onChange = jest.fn())=>{
|
|
19
|
-
render(/*#__PURE__*/ _jsx("div", {
|
|
20
|
-
children: /*#__PURE__*/ _jsx(CalculationSelector, {
|
|
21
|
-
value: value,
|
|
22
|
-
onChange: onChange
|
|
23
|
-
})
|
|
24
|
-
}));
|
|
25
|
-
};
|
|
26
|
-
const getCalculationSelector = ()=>{
|
|
27
|
-
return screen.getByRole('combobox', {
|
|
28
|
-
name: 'Calculation'
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
it('can change the calculation by clicking', ()=>{
|
|
32
|
-
const onChange = jest.fn();
|
|
33
|
-
renderCalculationSelector('Last', onChange);
|
|
34
|
-
const calcSelector = getCalculationSelector();
|
|
35
|
-
userEvent.click(calcSelector);
|
|
36
|
-
const sumOption = screen.getByRole('option', {
|
|
37
|
-
name: 'Sum'
|
|
38
|
-
});
|
|
39
|
-
userEvent.click(sumOption);
|
|
40
|
-
expect(onChange).toHaveBeenCalledWith('Sum');
|
|
41
|
-
});
|
|
42
|
-
it('can change the calculation using a keyboard', ()=>{
|
|
43
|
-
const onChange = jest.fn();
|
|
44
|
-
renderCalculationSelector('First', onChange);
|
|
45
|
-
const calcSelector = getCalculationSelector();
|
|
46
|
-
userEvent.tab();
|
|
47
|
-
expect(calcSelector).toHaveFocus();
|
|
48
|
-
userEvent.clear(calcSelector);
|
|
49
|
-
userEvent.keyboard('first');
|
|
50
|
-
screen.getByRole('option', {
|
|
51
|
-
name: 'First'
|
|
52
|
-
});
|
|
53
|
-
userEvent.keyboard('{arrowup}{enter}');
|
|
54
|
-
expect(onChange).toHaveBeenCalledWith('First');
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
//# sourceMappingURL=CalculationSelector.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/CalculationSelector/CalculationSelector.test.tsx"],"sourcesContent":["// Copyright 2022 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 { render, screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { CalculationType } from '../../model/calculations';\nimport { CalculationSelector } from './CalculationSelector';\n\ndescribe('CalculationSelector', () => {\n const renderCalculationSelector = (value: CalculationType, onChange = jest.fn()) => {\n render(\n <div>\n <CalculationSelector value={value} onChange={onChange} />\n </div>\n );\n };\n\n const getCalculationSelector = () => {\n return screen.getByRole('combobox', { name: 'Calculation' });\n };\n\n it('can change the calculation by clicking', () => {\n const onChange = jest.fn();\n renderCalculationSelector('Last', onChange);\n\n const calcSelector = getCalculationSelector();\n userEvent.click(calcSelector);\n const sumOption = screen.getByRole('option', {\n name: 'Sum',\n });\n userEvent.click(sumOption);\n\n expect(onChange).toHaveBeenCalledWith('Sum');\n });\n\n it('can change the calculation using a keyboard', () => {\n const onChange = jest.fn();\n renderCalculationSelector('First', onChange);\n\n const calcSelector = getCalculationSelector();\n userEvent.tab();\n expect(calcSelector).toHaveFocus();\n\n userEvent.clear(calcSelector);\n userEvent.keyboard('first');\n screen.getByRole('option', {\n name: 'First',\n });\n\n userEvent.keyboard('{arrowup}{enter}');\n\n expect(onChange).toHaveBeenCalledWith('First');\n });\n});\n"],"names":["render","screen","userEvent","CalculationSelector","describe","renderCalculationSelector","value","onChange","jest","fn","div","getCalculationSelector","getByRole","name","it","calcSelector","click","sumOption","expect","toHaveBeenCalledWith","tab","toHaveFocus","clear","keyboard"],"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,SAASA,MAAM,EAAEC,MAAM,QAAQ,wBAAwB,CAAC;AACxD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AAEpD,SAASC,mBAAmB,QAAQ,uBAAuB,CAAC;AAE5DC,QAAQ,CAAC,qBAAqB,EAAE,IAAM;IACpC,MAAMC,yBAAyB,GAAG,CAACC,KAAsB,EAAEC,QAAQ,GAAGC,IAAI,CAACC,EAAE,EAAE,GAAK;QAClFT,MAAM,eACJ,KAACU,KAAG;sBACF,cAAA,KAACP,mBAAmB;gBAACG,KAAK,EAAEA,KAAK;gBAAEC,QAAQ,EAAEA,QAAQ;cAAI;UACrD,CACP,CAAC;IACJ,CAAC,AAAC;IAEF,MAAMI,sBAAsB,GAAG,IAAM;QACnC,OAAOV,MAAM,CAACW,SAAS,CAAC,UAAU,EAAE;YAAEC,IAAI,EAAE,aAAa;SAAE,CAAC,CAAC;IAC/D,CAAC,AAAC;IAEFC,EAAE,CAAC,wCAAwC,EAAE,IAAM;QACjD,MAAMP,QAAQ,GAAGC,IAAI,CAACC,EAAE,EAAE,AAAC;QAC3BJ,yBAAyB,CAAC,MAAM,EAAEE,QAAQ,CAAC,CAAC;QAE5C,MAAMQ,YAAY,GAAGJ,sBAAsB,EAAE,AAAC;QAC9CT,SAAS,CAACc,KAAK,CAACD,YAAY,CAAC,CAAC;QAC9B,MAAME,SAAS,GAAGhB,MAAM,CAACW,SAAS,CAAC,QAAQ,EAAE;YAC3CC,IAAI,EAAE,KAAK;SACZ,CAAC,AAAC;QACHX,SAAS,CAACc,KAAK,CAACC,SAAS,CAAC,CAAC;QAE3BC,MAAM,CAACX,QAAQ,CAAC,CAACY,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEHL,EAAE,CAAC,6CAA6C,EAAE,IAAM;QACtD,MAAMP,QAAQ,GAAGC,IAAI,CAACC,EAAE,EAAE,AAAC;QAC3BJ,yBAAyB,CAAC,OAAO,EAAEE,QAAQ,CAAC,CAAC;QAE7C,MAAMQ,YAAY,GAAGJ,sBAAsB,EAAE,AAAC;QAC9CT,SAAS,CAACkB,GAAG,EAAE,CAAC;QAChBF,MAAM,CAACH,YAAY,CAAC,CAACM,WAAW,EAAE,CAAC;QAEnCnB,SAAS,CAACoB,KAAK,CAACP,YAAY,CAAC,CAAC;QAC9Bb,SAAS,CAACqB,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC5BtB,MAAM,CAACW,SAAS,CAAC,QAAQ,EAAE;YACzBC,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;QAEHX,SAAS,CAACqB,QAAQ,CAAC,kBAAkB,CAAC,CAAC;QAEvCL,MAAM,CAACX,QAAQ,CAAC,CAACY,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OptionsEditorTabs.test.d.ts","sourceRoot":"","sources":["../../../src/components/OptionsEditorTabs/OptionsEditorTabs.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
// Copyright 2022 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 { screen, render, getAllByRole } from '@testing-library/react';
|
|
15
|
-
import userEvent from '@testing-library/user-event';
|
|
16
|
-
import { OptionsEditorTabs } from './OptionsEditorTabs';
|
|
17
|
-
describe('OptionsEditorTabs', ()=>{
|
|
18
|
-
const renderTabs = (otherTabs)=>{
|
|
19
|
-
render(/*#__PURE__*/ _jsx(OptionsEditorTabs, {
|
|
20
|
-
tabs: {
|
|
21
|
-
query: {
|
|
22
|
-
content: /*#__PURE__*/ _jsx("div", {
|
|
23
|
-
children: "Edit query configuration"
|
|
24
|
-
})
|
|
25
|
-
},
|
|
26
|
-
settings: {
|
|
27
|
-
content: /*#__PURE__*/ _jsx("div", {
|
|
28
|
-
children: "Edit settings configuration"
|
|
29
|
-
})
|
|
30
|
-
},
|
|
31
|
-
json: {
|
|
32
|
-
content: /*#__PURE__*/ _jsx("div", {
|
|
33
|
-
children: "JSON editor"
|
|
34
|
-
})
|
|
35
|
-
},
|
|
36
|
-
other: otherTabs
|
|
37
|
-
}
|
|
38
|
-
}));
|
|
39
|
-
};
|
|
40
|
-
const renderCustomTabs = ()=>{
|
|
41
|
-
renderTabs([
|
|
42
|
-
{
|
|
43
|
-
id: 'tableCols',
|
|
44
|
-
label: 'Table columns',
|
|
45
|
-
content: /*#__PURE__*/ _jsx("div", {
|
|
46
|
-
children: "custom table column"
|
|
47
|
-
})
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
id: 'tableOpts',
|
|
51
|
-
label: 'Table options',
|
|
52
|
-
content: /*#__PURE__*/ _jsx("div", {
|
|
53
|
-
children: "custom table options"
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
]);
|
|
57
|
-
};
|
|
58
|
-
it('renders all specified tabs in a tab list', ()=>{
|
|
59
|
-
renderTabs();
|
|
60
|
-
const tabList = screen.getByRole('tablist');
|
|
61
|
-
const tabs = getAllByRole(tabList, 'tab');
|
|
62
|
-
expect(tabs).toHaveLength(3);
|
|
63
|
-
expect(tabs[0]).toHaveTextContent('Query');
|
|
64
|
-
expect(tabs[1]).toHaveTextContent('Settings');
|
|
65
|
-
expect(tabs[2]).toHaveTextContent('JSON');
|
|
66
|
-
});
|
|
67
|
-
it('defaults to selecting the first tab', ()=>{
|
|
68
|
-
renderTabs();
|
|
69
|
-
const activeTab = screen.getByRole('tab', {
|
|
70
|
-
selected: true
|
|
71
|
-
});
|
|
72
|
-
expect(activeTab).toHaveTextContent('Query');
|
|
73
|
-
const activeTabPanel = screen.getByRole('tabpanel');
|
|
74
|
-
expect(activeTabPanel).toHaveTextContent('query configuration');
|
|
75
|
-
});
|
|
76
|
-
it('switches selected tab on click', ()=>{
|
|
77
|
-
renderTabs();
|
|
78
|
-
const jsonTab = screen.getByRole('tab', {
|
|
79
|
-
name: 'JSON'
|
|
80
|
-
});
|
|
81
|
-
userEvent.click(jsonTab);
|
|
82
|
-
const activeTab = screen.getByRole('tab', {
|
|
83
|
-
selected: true
|
|
84
|
-
});
|
|
85
|
-
expect(activeTab).toBe(jsonTab);
|
|
86
|
-
const activeTabPanel = screen.getByRole('tabpanel');
|
|
87
|
-
expect(activeTabPanel).toHaveTextContent('JSON editor');
|
|
88
|
-
});
|
|
89
|
-
it('switches selected tab on keyboard interactions', ()=>{
|
|
90
|
-
renderTabs();
|
|
91
|
-
const vizTab = screen.getByRole('tab', {
|
|
92
|
-
name: 'Settings'
|
|
93
|
-
});
|
|
94
|
-
userEvent.tab();
|
|
95
|
-
userEvent.keyboard('{arrowright}{space}');
|
|
96
|
-
const activeTab = screen.getByRole('tab', {
|
|
97
|
-
selected: true
|
|
98
|
-
});
|
|
99
|
-
expect(activeTab).toBe(vizTab);
|
|
100
|
-
const activeTabPanel = screen.getByRole('tabpanel');
|
|
101
|
-
expect(activeTabPanel).toHaveTextContent('settings configuration');
|
|
102
|
-
});
|
|
103
|
-
it('renders custom tabs between visual tabs and json editor', ()=>{
|
|
104
|
-
renderCustomTabs();
|
|
105
|
-
const tabList = screen.getByRole('tablist');
|
|
106
|
-
const tabs = getAllByRole(tabList, 'tab');
|
|
107
|
-
expect(tabs).toHaveLength(5);
|
|
108
|
-
expect(tabs[0]).toHaveTextContent('Query');
|
|
109
|
-
expect(tabs[1]).toHaveTextContent('Settings');
|
|
110
|
-
expect(tabs[2]).toHaveTextContent('Table column');
|
|
111
|
-
expect(tabs[3]).toHaveTextContent('Table options');
|
|
112
|
-
expect(tabs[4]).toHaveTextContent('JSON');
|
|
113
|
-
});
|
|
114
|
-
it('shows the correct content when selecting a custom tab', ()=>{
|
|
115
|
-
renderCustomTabs();
|
|
116
|
-
const tableColTab = screen.getByRole('tab', {
|
|
117
|
-
name: 'Table columns'
|
|
118
|
-
});
|
|
119
|
-
userEvent.click(tableColTab);
|
|
120
|
-
const activeTab = screen.getByRole('tab', {
|
|
121
|
-
selected: true
|
|
122
|
-
});
|
|
123
|
-
expect(activeTab).toBe(tableColTab);
|
|
124
|
-
const activeTabPanel = screen.getByRole('tabpanel');
|
|
125
|
-
expect(activeTabPanel).toHaveTextContent('custom table column');
|
|
126
|
-
});
|
|
127
|
-
it('only renders common tabs that are specified', ()=>{
|
|
128
|
-
render(/*#__PURE__*/ _jsx(OptionsEditorTabs, {
|
|
129
|
-
tabs: {
|
|
130
|
-
settings: {
|
|
131
|
-
content: /*#__PURE__*/ _jsx("div", {
|
|
132
|
-
children: "settings are alone"
|
|
133
|
-
})
|
|
134
|
-
},
|
|
135
|
-
json: {
|
|
136
|
-
content: /*#__PURE__*/ _jsx("div", {
|
|
137
|
-
children: "JSON is at the end"
|
|
138
|
-
})
|
|
139
|
-
},
|
|
140
|
-
other: [
|
|
141
|
-
{
|
|
142
|
-
id: 'custom',
|
|
143
|
-
label: 'Another tab',
|
|
144
|
-
content: /*#__PURE__*/ _jsx("div", {
|
|
145
|
-
children: "another tab content"
|
|
146
|
-
})
|
|
147
|
-
}
|
|
148
|
-
]
|
|
149
|
-
}
|
|
150
|
-
}));
|
|
151
|
-
const tabList = screen.getByRole('tablist');
|
|
152
|
-
const tabs = getAllByRole(tabList, 'tab');
|
|
153
|
-
expect(tabs).toHaveLength(3);
|
|
154
|
-
expect(tabs[0]).toHaveTextContent('Settings');
|
|
155
|
-
expect(tabs[1]).toHaveTextContent('Another tab');
|
|
156
|
-
expect(tabs[2]).toHaveTextContent('JSON');
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
//# sourceMappingURL=OptionsEditorTabs.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/OptionsEditorTabs/OptionsEditorTabs.test.tsx"],"sourcesContent":["// Copyright 2022 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 { screen, render, getAllByRole } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\n\nimport { OptionsEditorTabs, OptionsEditorTabsProps } from './OptionsEditorTabs';\n\ndescribe('OptionsEditorTabs', () => {\n const renderTabs = (otherTabs?: OptionsEditorTabsProps['tabs']['other']) => {\n render(\n <OptionsEditorTabs\n tabs={{\n query: {\n content: <div>Edit query configuration</div>,\n },\n settings: {\n content: <div>Edit settings configuration</div>,\n },\n json: {\n content: <div>JSON editor</div>,\n },\n other: otherTabs,\n }}\n />\n );\n };\n\n const renderCustomTabs = () => {\n renderTabs([\n {\n id: 'tableCols',\n label: 'Table columns',\n content: <div>custom table column</div>,\n },\n {\n id: 'tableOpts',\n label: 'Table options',\n content: <div>custom table options</div>,\n },\n ]);\n };\n\n it('renders all specified tabs in a tab list', () => {\n renderTabs();\n\n const tabList = screen.getByRole('tablist');\n const tabs = getAllByRole(tabList, 'tab');\n expect(tabs).toHaveLength(3);\n expect(tabs[0]).toHaveTextContent('Query');\n expect(tabs[1]).toHaveTextContent('Settings');\n expect(tabs[2]).toHaveTextContent('JSON');\n });\n\n it('defaults to selecting the first tab', () => {\n renderTabs();\n\n const activeTab = screen.getByRole('tab', {\n selected: true,\n });\n expect(activeTab).toHaveTextContent('Query');\n\n const activeTabPanel = screen.getByRole('tabpanel');\n expect(activeTabPanel).toHaveTextContent('query configuration');\n });\n\n it('switches selected tab on click', () => {\n renderTabs();\n const jsonTab = screen.getByRole('tab', { name: 'JSON' });\n userEvent.click(jsonTab);\n\n const activeTab = screen.getByRole('tab', {\n selected: true,\n });\n expect(activeTab).toBe(jsonTab);\n\n const activeTabPanel = screen.getByRole('tabpanel');\n expect(activeTabPanel).toHaveTextContent('JSON editor');\n });\n\n it('switches selected tab on keyboard interactions', () => {\n renderTabs();\n const vizTab = screen.getByRole('tab', { name: 'Settings' });\n userEvent.tab();\n userEvent.keyboard('{arrowright}{space}');\n\n const activeTab = screen.getByRole('tab', {\n selected: true,\n });\n expect(activeTab).toBe(vizTab);\n\n const activeTabPanel = screen.getByRole('tabpanel');\n expect(activeTabPanel).toHaveTextContent('settings configuration');\n });\n\n it('renders custom tabs between visual tabs and json editor', () => {\n renderCustomTabs();\n\n const tabList = screen.getByRole('tablist');\n const tabs = getAllByRole(tabList, 'tab');\n expect(tabs).toHaveLength(5);\n expect(tabs[0]).toHaveTextContent('Query');\n expect(tabs[1]).toHaveTextContent('Settings');\n expect(tabs[2]).toHaveTextContent('Table column');\n expect(tabs[3]).toHaveTextContent('Table options');\n expect(tabs[4]).toHaveTextContent('JSON');\n });\n\n it('shows the correct content when selecting a custom tab', () => {\n renderCustomTabs();\n\n const tableColTab = screen.getByRole('tab', { name: 'Table columns' });\n userEvent.click(tableColTab);\n\n const activeTab = screen.getByRole('tab', {\n selected: true,\n });\n expect(activeTab).toBe(tableColTab);\n\n const activeTabPanel = screen.getByRole('tabpanel');\n expect(activeTabPanel).toHaveTextContent('custom table column');\n });\n\n it('only renders common tabs that are specified', () => {\n render(\n <OptionsEditorTabs\n tabs={{\n settings: {\n content: <div>settings are alone</div>,\n },\n json: {\n content: <div>JSON is at the end</div>,\n },\n other: [\n {\n id: 'custom',\n label: 'Another tab',\n content: <div>another tab content</div>,\n },\n ],\n }}\n />\n );\n const tabList = screen.getByRole('tablist');\n const tabs = getAllByRole(tabList, 'tab');\n expect(tabs).toHaveLength(3);\n expect(tabs[0]).toHaveTextContent('Settings');\n expect(tabs[1]).toHaveTextContent('Another tab');\n expect(tabs[2]).toHaveTextContent('JSON');\n });\n});\n"],"names":["screen","render","getAllByRole","userEvent","OptionsEditorTabs","describe","renderTabs","otherTabs","tabs","query","content","div","settings","json","other","renderCustomTabs","id","label","it","tabList","getByRole","expect","toHaveLength","toHaveTextContent","activeTab","selected","activeTabPanel","jsonTab","name","click","toBe","vizTab","tab","keyboard","tableColTab"],"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,SAASA,MAAM,EAAEC,MAAM,EAAEC,YAAY,QAAQ,wBAAwB,CAAC;AACtE,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AAEpD,SAASC,iBAAiB,QAAgC,qBAAqB,CAAC;AAEhFC,QAAQ,CAAC,mBAAmB,EAAE,IAAM;IAClC,MAAMC,UAAU,GAAG,CAACC,SAAmD,GAAK;QAC1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M,CAACb,IAAI,CAAC,CAAC,CAAC,CAAC,CAACe,iBAAiB,CAAC,aAAa,CAAC,CAAC;QACjDF,MAAM,CAACb,IAAI,CAAC,CAAC,CAAC,CAAC,CAACe,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PluginEditor.test.d.ts","sourceRoot":"","sources":["../../../src/components/PluginEditor/PluginEditor.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
// Copyright 2022 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, waitFor } from '@testing-library/react';
|
|
16
|
-
import { useState } from 'react';
|
|
17
|
-
import { renderWithContext } from '../../test';
|
|
18
|
-
import { PluginEditor } from './PluginEditor';
|
|
19
|
-
describe('PluginEditor', ()=>{
|
|
20
|
-
const renderComponent = ({ pluginType ='Panel' , defaultPluginKinds , value } = {})=>{
|
|
21
|
-
const testValue = value || {
|
|
22
|
-
kind: 'BertPanel1',
|
|
23
|
-
spec: {
|
|
24
|
-
option1: 'Option1Value'
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
// A test helper component that includes the state that's controlled from outside
|
|
28
|
-
let onChange = jest.fn();
|
|
29
|
-
function TestHelperForm() {
|
|
30
|
-
const [value, setValue] = useState(testValue);
|
|
31
|
-
onChange = jest.fn((v)=>setValue(v));
|
|
32
|
-
return /*#__PURE__*/ _jsx(PluginEditor, {
|
|
33
|
-
pluginType: pluginType,
|
|
34
|
-
pluginKindLabel: "Panel Type",
|
|
35
|
-
value: value,
|
|
36
|
-
onChange: onChange
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
renderWithContext(/*#__PURE__*/ _jsx(TestHelperForm, {}), undefined, {
|
|
40
|
-
defaultPluginKinds
|
|
41
|
-
});
|
|
42
|
-
return {
|
|
43
|
-
onChange
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
// Opens the PluginKindSelect and waits for loading to finish (i.e. options to appear)
|
|
47
|
-
const openPluginKind = async ()=>{
|
|
48
|
-
const select = screen.getByRole('button', {
|
|
49
|
-
name: 'Panel Type'
|
|
50
|
-
});
|
|
51
|
-
userEvent.click(select);
|
|
52
|
-
const options = await screen.findAllByRole('option');
|
|
53
|
-
return options;
|
|
54
|
-
};
|
|
55
|
-
it('shows plugin kind and spec editor', async ()=>{
|
|
56
|
-
renderComponent();
|
|
57
|
-
const pluginKind = screen.getByRole('button', {
|
|
58
|
-
name: 'Panel Type'
|
|
59
|
-
});
|
|
60
|
-
await waitFor(()=>expect(pluginKind).toHaveTextContent('Bert Panel 1'));
|
|
61
|
-
const specEditor = await screen.findByLabelText('BertPanel1 editor');
|
|
62
|
-
expect(specEditor).toHaveValue('Option1Value');
|
|
63
|
-
});
|
|
64
|
-
it('initializes kind and spec together', async ()=>{
|
|
65
|
-
const { onChange } = renderComponent();
|
|
66
|
-
// Switch to a new plugin kind
|
|
67
|
-
await openPluginKind();
|
|
68
|
-
const newPluginKind = screen.getByRole('option', {
|
|
69
|
-
name: 'Bert Panel 2'
|
|
70
|
-
});
|
|
71
|
-
userEvent.click(newPluginKind);
|
|
72
|
-
// Wait for the editor of the other plugin
|
|
73
|
-
const newEditor = await screen.findByLabelText('BertPanel2 editor');
|
|
74
|
-
expect(newEditor).toBeInTheDocument();
|
|
75
|
-
expect(newEditor).toHaveValue('');
|
|
76
|
-
// Make sure onChange was only called once (i.e. initializes both kind and spec at the same time
|
|
77
|
-
expect(onChange).toHaveBeenCalledTimes(1);
|
|
78
|
-
expect(onChange).toHaveBeenCalledWith({
|
|
79
|
-
kind: 'BertPanel2',
|
|
80
|
-
spec: {
|
|
81
|
-
option2: ''
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
it('remembers previous spec values', async ()=>{
|
|
86
|
-
renderComponent();
|
|
87
|
-
// Use the current editor to make a change to the spec value
|
|
88
|
-
let editor = await screen.findByLabelText('BertPanel1 editor');
|
|
89
|
-
userEvent.clear(editor);
|
|
90
|
-
userEvent.type(editor, 'MyNewValue');
|
|
91
|
-
// Switch to a new plugin kind
|
|
92
|
-
await openPluginKind();
|
|
93
|
-
const newPluginKind = screen.getByRole('option', {
|
|
94
|
-
name: 'Bert Panel 2'
|
|
95
|
-
});
|
|
96
|
-
userEvent.click(newPluginKind);
|
|
97
|
-
// Wait for the other editor to appear, then switch back
|
|
98
|
-
const newEditor = await screen.findByLabelText('BertPanel2 editor');
|
|
99
|
-
expect(newEditor).toHaveValue('');
|
|
100
|
-
await openPluginKind();
|
|
101
|
-
const oldPluginKind = screen.getByRole('option', {
|
|
102
|
-
name: 'Bert Panel 1'
|
|
103
|
-
});
|
|
104
|
-
userEvent.click(oldPluginKind);
|
|
105
|
-
// Make sure the editor from the first plugin appears and has our modified value from before the switch
|
|
106
|
-
editor = await screen.findByLabelText('BertPanel1 editor');
|
|
107
|
-
expect(editor).toHaveValue('MyNewValue');
|
|
108
|
-
});
|
|
109
|
-
describe('when defaultPluginKinds specified in plugin registry', ()=>{
|
|
110
|
-
it('uses default kind when one is not provided', async ()=>{
|
|
111
|
-
renderComponent({
|
|
112
|
-
pluginType: 'Panel',
|
|
113
|
-
defaultPluginKinds: {
|
|
114
|
-
Panel: 'BertPanel2'
|
|
115
|
-
},
|
|
116
|
-
value: {
|
|
117
|
-
kind: '',
|
|
118
|
-
spec: {}
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
// Wait for default panel kind to load.
|
|
122
|
-
const pluginKind = screen.getByRole('button', {
|
|
123
|
-
name: 'Panel Type'
|
|
124
|
-
});
|
|
125
|
-
await waitFor(()=>expect(pluginKind).toHaveTextContent('Bert Panel 2'));
|
|
126
|
-
});
|
|
127
|
-
it('does not use default when kind is provided', async ()=>{
|
|
128
|
-
renderComponent({
|
|
129
|
-
pluginType: 'Panel',
|
|
130
|
-
defaultPluginKinds: {
|
|
131
|
-
Panel: 'BertPanel2'
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
// Wait for specified panel kind to load.
|
|
135
|
-
const pluginKind = screen.getByRole('button', {
|
|
136
|
-
name: 'Panel Type'
|
|
137
|
-
});
|
|
138
|
-
await waitFor(()=>expect(pluginKind).toHaveTextContent('Bert Panel 1'));
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
//# sourceMappingURL=PluginEditor.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PluginEditor/PluginEditor.test.tsx"],"sourcesContent":["// Copyright 2022 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, waitFor } from '@testing-library/react';\nimport { useState } from 'react';\nimport { renderWithContext } from '../../test';\nimport { DefaultPluginKinds } from '../../model';\nimport { PluginEditor } from './PluginEditor';\nimport { PluginEditorProps } from './plugin-editor-api';\n\ntype RenderComponentOptions = {\n pluginType?: PluginEditorProps['pluginType'];\n defaultPluginKinds?: DefaultPluginKinds;\n value?: PluginEditorProps['value'];\n};\n\ndescribe('PluginEditor', () => {\n const renderComponent = ({ pluginType = 'Panel', defaultPluginKinds, value }: RenderComponentOptions = {}) => {\n const testValue: PluginEditorProps['value'] = value || { kind: 'BertPanel1', spec: { option1: 'Option1Value' } };\n\n // A test helper component that includes the state that's controlled from outside\n let onChange: jest.Mocked<PluginEditorProps['onChange']> = jest.fn();\n function TestHelperForm() {\n const [value, setValue] = useState(testValue);\n onChange = jest.fn((v) => setValue(v));\n\n return <PluginEditor pluginType={pluginType} pluginKindLabel=\"Panel Type\" value={value} onChange={onChange} />;\n }\n\n renderWithContext(<TestHelperForm />, undefined, { defaultPluginKinds });\n return { onChange };\n };\n\n // Opens the PluginKindSelect and waits for loading to finish (i.e. options to appear)\n const openPluginKind = async () => {\n const select = screen.getByRole('button', { name: 'Panel Type' });\n userEvent.click(select);\n const options = await screen.findAllByRole('option');\n return options;\n };\n\n it('shows plugin kind and spec editor', async () => {\n renderComponent();\n\n const pluginKind = screen.getByRole('button', { name: 'Panel Type' });\n await waitFor(() => expect(pluginKind).toHaveTextContent('Bert Panel 1'));\n const specEditor = await screen.findByLabelText('BertPanel1 editor');\n expect(specEditor).toHaveValue('Option1Value');\n });\n\n it('initializes kind and spec together', async () => {\n const { onChange } = renderComponent();\n\n // Switch to a new plugin kind\n await openPluginKind();\n const newPluginKind = screen.getByRole('option', { name: 'Bert Panel 2' });\n userEvent.click(newPluginKind);\n\n // Wait for the editor of the other plugin\n const newEditor = await screen.findByLabelText('BertPanel2 editor');\n expect(newEditor).toBeInTheDocument();\n expect(newEditor).toHaveValue('');\n\n // Make sure onChange was only called once (i.e. initializes both kind and spec at the same time\n expect(onChange).toHaveBeenCalledTimes(1);\n expect(onChange).toHaveBeenCalledWith({ kind: 'BertPanel2', spec: { option2: '' } });\n });\n\n it('remembers previous spec values', async () => {\n renderComponent();\n\n // Use the current editor to make a change to the spec value\n let editor = await screen.findByLabelText('BertPanel1 editor');\n userEvent.clear(editor);\n userEvent.type(editor, 'MyNewValue');\n\n // Switch to a new plugin kind\n await openPluginKind();\n const newPluginKind = screen.getByRole('option', { name: 'Bert Panel 2' });\n userEvent.click(newPluginKind);\n\n // Wait for the other editor to appear, then switch back\n const newEditor = await screen.findByLabelText('BertPanel2 editor');\n expect(newEditor).toHaveValue('');\n await openPluginKind();\n const oldPluginKind = screen.getByRole('option', { name: 'Bert Panel 1' });\n userEvent.click(oldPluginKind);\n\n // Make sure the editor from the first plugin appears and has our modified value from before the switch\n editor = await screen.findByLabelText('BertPanel1 editor');\n expect(editor).toHaveValue('MyNewValue');\n });\n\n describe('when defaultPluginKinds specified in plugin registry', () => {\n it('uses default kind when one is not provided', async () => {\n renderComponent({\n pluginType: 'Panel',\n defaultPluginKinds: {\n Panel: 'BertPanel2',\n },\n value: { kind: '', spec: {} },\n });\n\n // Wait for default panel kind to load.\n const pluginKind = screen.getByRole('button', { name: 'Panel Type' });\n await waitFor(() => expect(pluginKind).toHaveTextContent('Bert Panel 2'));\n });\n\n it('does not use default when kind is provided', async () => {\n renderComponent({ pluginType: 'Panel', defaultPluginKinds: { Panel: 'BertPanel2' } });\n\n // Wait for specified panel kind to load.\n const pluginKind = screen.getByRole('button', { name: 'Panel Type' });\n await waitFor(() => expect(pluginKind).toHaveTextContent('Bert Panel 1'));\n });\n });\n});\n"],"names":["userEvent","screen","waitFor","useState","renderWithContext","PluginEditor","describe","renderComponent","pluginType","defaultPluginKinds","value","testValue","kind","spec","option1","onChange","jest","fn","TestHelperForm","setValue","v","pluginKindLabel","undefined","openPluginKind","select","getByRole","name","click","options","findAllByRole","it","pluginKind","expect","toHaveTextContent","specEditor","findByLabelText","toHaveValue","newPluginKind","newEditor","toBeInTheDocument","toHaveBeenCalledTimes","toHaveBeenCalledWith","option2","editor","clear","type","oldPluginKind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,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PluginKindSelect.test.d.ts","sourceRoot":"","sources":["../../src/components/PluginKindSelect.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// Copyright 2022 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 2022 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,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;QACxD,OAAOJ,iBAAiB,eAAC,KAACC,gBAAgB;YAAE,GAAGG,KAAK;UAAI,CAAC,CAAC;IAC5D,CAAC,AAAC;IAEF,4EAA4E;IAC5E,MAAMC,UAAU,GAAG,UAAY;QAC7B,MAAMC,MAAM,GAAGP,MAAM,CAACQ,SAAS,CAAC,QAAQ,CAAC,AAAC;QAC1CT,SAAS,CAACU,KAAK,CAACF,MAAM,CAAC,CAAC;QACxB,MAAMG,OAAO,GAAG,MAAMV,MAAM,CAACW,aAAa,CAAC,QAAQ,CAAC,AAAC;QACrD,OAAOD,OAAO,CAAC;IACjB,CAAC,AAAC;IAEFE,EAAE,CAAC,gDAAgD,EAAE,UAAY;QAC/DR,eAAe,CAAC;YACdS,UAAU,EAAE,OAAO;YACnBC,KAAK,EAAE,EAAE;SACV,CAAC,CAAC;QAEH,2EAA2E;QAC3E,MAAMJ,OAAO,GAAG,MAAMJ,UAAU,EAAE,AAAC;QACnCS,MAAM,CAACL,OAAO,CAAC,CAACM,YAAY,CAAC,CA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,CAAC;QAE3Bd,MAAM,CAACS,QAAQ,CAAC,CAACM,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAC1Cf,MAAM,CAACO,aAAa,CAAC,CAACS,IAAI,CAAC,cAAc,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PluginRegistry.test.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/PluginRegistry.test.tsx"],"names":[],"mappings":""}
|