@perses-dev/dashboards 0.23.0 → 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.
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +7 -3
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +2 -7
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +2 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +8 -4
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/package.json +7 -6
- package/dist/cjs/components/Panel/Panel.test.js +0 -137
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +0 -131
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +0 -87
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +0 -95
- package/dist/cjs/components/Variables/variable-model.test.js +0 -106
- package/dist/cjs/context/TemplateVariableProvider/query-params.test.js +0 -82
- package/dist/cjs/utils/panelUtils.test.js +0 -195
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +0 -110
- package/dist/components/Panel/Panel.test.d.ts +0 -2
- package/dist/components/Panel/Panel.test.d.ts.map +0 -1
- package/dist/components/Panel/Panel.test.js +0 -130
- package/dist/components/Panel/Panel.test.js.map +0 -1
- package/dist/components/PanelDrawer/PanelDrawer.test.d.ts +0 -2
- package/dist/components/PanelDrawer/PanelDrawer.test.d.ts.map +0 -1
- package/dist/components/PanelDrawer/PanelDrawer.test.js +0 -124
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +0 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.d.ts +0 -2
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.d.ts.map +0 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +0 -80
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +0 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.d.ts +0 -2
- package/dist/components/TimeRangeControls/TimeRangeControls.test.d.ts.map +0 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +0 -88
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +0 -1
- package/dist/components/Variables/variable-model.test.d.ts +0 -2
- package/dist/components/Variables/variable-model.test.d.ts.map +0 -1
- package/dist/components/Variables/variable-model.test.js +0 -104
- package/dist/components/Variables/variable-model.test.js.map +0 -1
- package/dist/context/TemplateVariableProvider/query-params.test.d.ts +0 -2
- package/dist/context/TemplateVariableProvider/query-params.test.d.ts.map +0 -1
- package/dist/context/TemplateVariableProvider/query-params.test.js +0 -80
- package/dist/context/TemplateVariableProvider/query-params.test.js.map +0 -1
- package/dist/utils/panelUtils.test.d.ts +0 -2
- package/dist/utils/panelUtils.test.d.ts.map +0 -1
- package/dist/utils/panelUtils.test.js +0 -193
- package/dist/utils/panelUtils.test.js.map +0 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts +0 -2
- package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts.map +0 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +0 -103
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +0 -1
|
@@ -1,130 +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 { screen, waitFor } from '@testing-library/react';
|
|
15
|
-
import userEvent from '@testing-library/user-event';
|
|
16
|
-
import { renderWithContext } from '../../test';
|
|
17
|
-
import { Panel } from './Panel';
|
|
18
|
-
describe('Panel', ()=>{
|
|
19
|
-
const createTestPanel = ()=>({
|
|
20
|
-
kind: 'Panel',
|
|
21
|
-
spec: {
|
|
22
|
-
display: {
|
|
23
|
-
name: 'Fake Panel Title',
|
|
24
|
-
description: 'This is a fake panel'
|
|
25
|
-
},
|
|
26
|
-
plugin: {
|
|
27
|
-
kind: 'TimeSeriesChart',
|
|
28
|
-
spec: {}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
// Helper to render the panel with some context set
|
|
33
|
-
const renderPanel = (definition, editHandlers)=>{
|
|
34
|
-
definition !== null && definition !== void 0 ? definition : definition = createTestPanel();
|
|
35
|
-
renderWithContext(/*#__PURE__*/ _jsx(Panel, {
|
|
36
|
-
definition: definition,
|
|
37
|
-
editHandlers: editHandlers
|
|
38
|
-
}));
|
|
39
|
-
};
|
|
40
|
-
// Helper to get the panel once rendered
|
|
41
|
-
const getPanel = ()=>screen.getByRole('region', {
|
|
42
|
-
name: 'Fake Panel Title'
|
|
43
|
-
});
|
|
44
|
-
it('should render panel', async ()=>{
|
|
45
|
-
renderPanel();
|
|
46
|
-
const panel = getPanel();
|
|
47
|
-
expect(panel).toBeInTheDocument();
|
|
48
|
-
// Should diplay header with panel's title
|
|
49
|
-
const header = screen.getByRole('banner');
|
|
50
|
-
expect(header).toHaveTextContent('Fake Panel Title');
|
|
51
|
-
// Should display chart's content from the fake panel plugin
|
|
52
|
-
const content = screen.getByRole('figure');
|
|
53
|
-
await waitFor(()=>{
|
|
54
|
-
expect(content).toHaveTextContent('TimeSeriesChart panel');
|
|
55
|
-
});
|
|
56
|
-
expect(content);
|
|
57
|
-
});
|
|
58
|
-
it('shows panel description', async ()=>{
|
|
59
|
-
renderPanel();
|
|
60
|
-
const panel = getPanel();
|
|
61
|
-
// Description button should not be visible until hover on panel
|
|
62
|
-
const missingButton = screen.queryByRole('button', {
|
|
63
|
-
name: /description/i
|
|
64
|
-
});
|
|
65
|
-
expect(missingButton).not.toBeInTheDocument();
|
|
66
|
-
userEvent.hover(panel);
|
|
67
|
-
const descriptionButton = screen.getByRole('button', {
|
|
68
|
-
name: /description/i
|
|
69
|
-
});
|
|
70
|
-
expect(descriptionButton).toBeInTheDocument();
|
|
71
|
-
// Can hover to see panel description in tooltip
|
|
72
|
-
userEvent.hover(descriptionButton);
|
|
73
|
-
const tooltip = await screen.findByRole('tooltip');
|
|
74
|
-
expect(tooltip).toHaveTextContent('This is a fake panel');
|
|
75
|
-
});
|
|
76
|
-
it('does not show description when panel does not have one', ()=>{
|
|
77
|
-
// Render a panel without a description set
|
|
78
|
-
const withoutDescription = createTestPanel();
|
|
79
|
-
withoutDescription.spec.display.description = undefined;
|
|
80
|
-
renderPanel(withoutDescription);
|
|
81
|
-
const panel = getPanel();
|
|
82
|
-
userEvent.hover(panel);
|
|
83
|
-
const descriptionButton = screen.queryByRole('button', {
|
|
84
|
-
name: /description/i
|
|
85
|
-
});
|
|
86
|
-
expect(descriptionButton).not.toBeInTheDocument();
|
|
87
|
-
});
|
|
88
|
-
it('does not show description in edit mode', ()=>{
|
|
89
|
-
renderPanel(undefined, {
|
|
90
|
-
onEditPanelClick: jest.fn(),
|
|
91
|
-
onDeletePanelClick: jest.fn(),
|
|
92
|
-
onDuplicatePanelClick: jest.fn()
|
|
93
|
-
});
|
|
94
|
-
const panel = getPanel();
|
|
95
|
-
userEvent.hover(panel);
|
|
96
|
-
const descriptionButton = screen.queryByRole('button', {
|
|
97
|
-
name: /description/i
|
|
98
|
-
});
|
|
99
|
-
expect(descriptionButton).not.toBeInTheDocument();
|
|
100
|
-
});
|
|
101
|
-
it('can trigger panel actions in edit mode', ()=>{
|
|
102
|
-
const onEditPanelClick = jest.fn();
|
|
103
|
-
const onDeletePanelClick = jest.fn();
|
|
104
|
-
const onDuplicatePanelClick = jest.fn();
|
|
105
|
-
renderPanel(undefined, {
|
|
106
|
-
onEditPanelClick,
|
|
107
|
-
onDeletePanelClick,
|
|
108
|
-
onDuplicatePanelClick
|
|
109
|
-
});
|
|
110
|
-
const panel = getPanel();
|
|
111
|
-
userEvent.hover(panel);
|
|
112
|
-
const editButton = screen.getByRole('button', {
|
|
113
|
-
name: /edit/i
|
|
114
|
-
});
|
|
115
|
-
userEvent.click(editButton);
|
|
116
|
-
const deleteButton = screen.getByRole('button', {
|
|
117
|
-
name: /delete/i
|
|
118
|
-
});
|
|
119
|
-
userEvent.click(deleteButton);
|
|
120
|
-
const duplicateButton = screen.getByRole('button', {
|
|
121
|
-
name: /duplicate/i
|
|
122
|
-
});
|
|
123
|
-
userEvent.click(duplicateButton);
|
|
124
|
-
expect(onEditPanelClick).toHaveBeenCalledTimes(1);
|
|
125
|
-
expect(onDeletePanelClick).toHaveBeenCalledTimes(1);
|
|
126
|
-
expect(onDuplicatePanelClick).toHaveBeenCalledTimes(1);
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
//# sourceMappingURL=Panel.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Panel/Panel.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 { screen, waitFor } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { PanelDefinition } from '@perses-dev/core';\nimport { renderWithContext } from '../../test';\nimport { Panel, PanelProps } from './Panel';\n\ndescribe('Panel', () => {\n const createTestPanel = (): PanelDefinition => ({\n kind: 'Panel',\n spec: {\n display: {\n name: 'Fake Panel Title',\n description: 'This is a fake panel',\n },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {},\n },\n },\n });\n\n // Helper to render the panel with some context set\n const renderPanel = (definition?: PanelDefinition, editHandlers?: PanelProps['editHandlers']) => {\n definition ??= createTestPanel();\n\n renderWithContext(<Panel definition={definition} editHandlers={editHandlers} />);\n };\n\n // Helper to get the panel once rendered\n const getPanel = () => screen.getByRole('region', { name: 'Fake Panel Title' });\n\n it('should render panel', async () => {\n renderPanel();\n\n const panel = getPanel();\n expect(panel).toBeInTheDocument();\n\n // Should diplay header with panel's title\n const header = screen.getByRole('banner');\n expect(header).toHaveTextContent('Fake Panel Title');\n\n // Should display chart's content from the fake panel plugin\n const content = screen.getByRole('figure');\n await waitFor(() => {\n expect(content).toHaveTextContent('TimeSeriesChart panel');\n });\n expect(content);\n });\n\n it('shows panel description', async () => {\n renderPanel();\n\n const panel = getPanel();\n\n // Description button should not be visible until hover on panel\n const missingButton = screen.queryByRole('button', { name: /description/i });\n expect(missingButton).not.toBeInTheDocument();\n userEvent.hover(panel);\n const descriptionButton = screen.getByRole('button', { name: /description/i });\n expect(descriptionButton).toBeInTheDocument();\n\n // Can hover to see panel description in tooltip\n userEvent.hover(descriptionButton);\n const tooltip = await screen.findByRole('tooltip');\n expect(tooltip).toHaveTextContent('This is a fake panel');\n });\n\n it('does not show description when panel does not have one', () => {\n // Render a panel without a description set\n const withoutDescription = createTestPanel();\n withoutDescription.spec.display.description = undefined;\n renderPanel(withoutDescription);\n\n const panel = getPanel();\n userEvent.hover(panel);\n const descriptionButton = screen.queryByRole('button', { name: /description/i });\n expect(descriptionButton).not.toBeInTheDocument();\n });\n\n it('does not show description in edit mode', () => {\n renderPanel(undefined, {\n onEditPanelClick: jest.fn(),\n onDeletePanelClick: jest.fn(),\n onDuplicatePanelClick: jest.fn(),\n });\n\n const panel = getPanel();\n userEvent.hover(panel);\n const descriptionButton = screen.queryByRole('button', { name: /description/i });\n expect(descriptionButton).not.toBeInTheDocument();\n });\n\n it('can trigger panel actions in edit mode', () => {\n const onEditPanelClick = jest.fn();\n const onDeletePanelClick = jest.fn();\n const onDuplicatePanelClick = jest.fn();\n renderPanel(undefined, { onEditPanelClick, onDeletePanelClick, onDuplicatePanelClick });\n\n const panel = getPanel();\n userEvent.hover(panel);\n\n const editButton = screen.getByRole('button', { name: /edit/i });\n userEvent.click(editButton);\n\n const deleteButton = screen.getByRole('button', { name: /delete/i });\n userEvent.click(deleteButton);\n\n const duplicateButton = screen.getByRole('button', { name: /duplicate/i });\n userEvent.click(duplicateButton);\n\n expect(onEditPanelClick).toHaveBeenCalledTimes(1);\n expect(onDeletePanelClick).toHaveBeenCalledTimes(1);\n expect(onDuplicatePanelClick).toHaveBeenCalledTimes(1);\n });\n});\n"],"names":["screen","waitFor","userEvent","renderWithContext","Panel","describe","createTestPanel","kind","spec","display","name","description","plugin","renderPanel","definition","editHandlers","getPanel","getByRole","it","panel","expect","toBeInTheDocument","header","toHaveTextContent","content","missingButton","queryByRole","not","hover","descriptionButton","tooltip","findByRole","withoutDescription","undefined","onEditPanelClick","jest","fn","onDeletePanelClick","onDuplicatePanelClick","editButton","click","deleteButton","duplicateButton","toHaveBeenCalledTimes"],"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,OAAO,QAAQ,wBAAwB,CAAC;AACzD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AAEpD,SAASC,iBAAiB,QAAQ,YAAY,CAAC;AAC/C,SAASC,KAAK,QAAoB,SAAS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,AAAC;QACjER,SAAS,CAACsC,KAAK,CAACD,UAAU,CAAC,CAAC;QAE5B,MAAME,YAAY,GAAGzC,MAAM,CAACiB,SAAS,CAAC,QAAQ,EAAE;YAAEP,IAAI,WAAW;SAAE,CAAC,AAAC;QACrER,SAAS,CAACsC,KAAK,CAACC,YAAY,CAAC,CAAC;QAE9B,MAAMC,eAAe,GAAG1C,MAAM,CAACiB,SAAS,CAAC,QAAQ,EAAE;YAAEP,IAAI,cAAc;SAAE,CAAC,AAAC;QAC3ER,SAAS,CAACsC,KAAK,CAACE,eAAe,CAAC,CAAC;QAEjCtB,MAAM,CAACc,gBAAgB,CAAC,CAACS,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAClDvB,MAAM,CAACiB,kBAAkB,CAAC,CAACM,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACpDvB,MAAM,CAACkB,qBAAqB,CAAC,CAACK,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PanelDrawer.test.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelDrawer.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,124 +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 { screen } from '@testing-library/react';
|
|
15
|
-
import userEvent from '@testing-library/user-event';
|
|
16
|
-
import { act } from 'react-dom/test-utils';
|
|
17
|
-
import { createDashboardProviderSpy, getTestDashboard, renderWithContext } from '../../test';
|
|
18
|
-
import { DashboardProvider } from '../../context/DashboardProvider';
|
|
19
|
-
import { PanelDrawer } from './PanelDrawer';
|
|
20
|
-
describe('Panel Drawer', ()=>{
|
|
21
|
-
const renderPanelDrawer = ()=>{
|
|
22
|
-
const { store , DashboardProviderSpy } = createDashboardProviderSpy();
|
|
23
|
-
renderWithContext(/*#__PURE__*/ _jsxs(DashboardProvider, {
|
|
24
|
-
initialState: {
|
|
25
|
-
dashboardResource: getTestDashboard(),
|
|
26
|
-
isEditMode: true
|
|
27
|
-
},
|
|
28
|
-
children: [
|
|
29
|
-
/*#__PURE__*/ _jsx(DashboardProviderSpy, {}),
|
|
30
|
-
/*#__PURE__*/ _jsx(PanelDrawer, {})
|
|
31
|
-
]
|
|
32
|
-
}));
|
|
33
|
-
const { value: storeApi } = store;
|
|
34
|
-
if (storeApi === undefined) {
|
|
35
|
-
throw new Error('Expected dashboard store to be set after initial render');
|
|
36
|
-
}
|
|
37
|
-
return storeApi;
|
|
38
|
-
};
|
|
39
|
-
it('should add new panel', async ()=>{
|
|
40
|
-
const storeApi = renderPanelDrawer();
|
|
41
|
-
// Open the drawer for a new panel
|
|
42
|
-
act(()=>storeApi.getState().openAddPanel());
|
|
43
|
-
const nameInput = await screen.findByLabelText(/Name/);
|
|
44
|
-
userEvent.type(nameInput, 'New Panel');
|
|
45
|
-
userEvent.click(screen.getByText('Add'));
|
|
46
|
-
// TODO: Assert drawer is closed?
|
|
47
|
-
const panels = storeApi.getState().panels;
|
|
48
|
-
expect(panels).toMatchObject({
|
|
49
|
-
// Should have the new panel in the store
|
|
50
|
-
NewPanel: {
|
|
51
|
-
kind: 'Panel',
|
|
52
|
-
spec: {
|
|
53
|
-
display: {
|
|
54
|
-
name: 'New Panel'
|
|
55
|
-
},
|
|
56
|
-
plugin: {
|
|
57
|
-
kind: '',
|
|
58
|
-
spec: {}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
it('should add panel with duplicate panel name', async ()=>{
|
|
65
|
-
const storeApi = renderPanelDrawer();
|
|
66
|
-
act(()=>storeApi.getState().openAddPanel());
|
|
67
|
-
const nameInput = await screen.findByLabelText(/Name/);
|
|
68
|
-
userEvent.type(nameInput, 'cpu');
|
|
69
|
-
userEvent.click(screen.getByText('Add'));
|
|
70
|
-
const panels = storeApi.getState().panels;
|
|
71
|
-
expect(panels).toMatchObject({
|
|
72
|
-
// make sure we don't have duplicate panel key by appending "-1"
|
|
73
|
-
'cpu-1': {
|
|
74
|
-
kind: 'Panel',
|
|
75
|
-
spec: {
|
|
76
|
-
display: {
|
|
77
|
-
name: 'cpu'
|
|
78
|
-
},
|
|
79
|
-
plugin: {
|
|
80
|
-
kind: '',
|
|
81
|
-
spec: {}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
it('should edit an existing panel', async ()=>{
|
|
88
|
-
const storeApi = renderPanelDrawer();
|
|
89
|
-
// Open the drawer for an existing panel
|
|
90
|
-
const group = Object.values(storeApi.getState().panelGroups).find((group)=>group.title === 'CPU Stats');
|
|
91
|
-
if (group === undefined) {
|
|
92
|
-
throw new Error('Test group not found');
|
|
93
|
-
}
|
|
94
|
-
const layout = Object.entries(group.itemPanelKeys).find(([, panelKey])=>panelKey === 'cpu');
|
|
95
|
-
if (layout === undefined) {
|
|
96
|
-
throw new Error('Test panel not found');
|
|
97
|
-
}
|
|
98
|
-
act(()=>storeApi.getState().openEditPanel({
|
|
99
|
-
panelGroupId: group.id,
|
|
100
|
-
panelGroupItemLayoutId: layout[0]
|
|
101
|
-
}));
|
|
102
|
-
const nameInput = await screen.findByLabelText(/Name/);
|
|
103
|
-
userEvent.clear(nameInput);
|
|
104
|
-
userEvent.type(nameInput, 'cpu usage');
|
|
105
|
-
userEvent.click(screen.getByText('Apply'));
|
|
106
|
-
const panels = storeApi.getState().panels;
|
|
107
|
-
expect(panels).toMatchObject({
|
|
108
|
-
cpu: {
|
|
109
|
-
kind: 'Panel',
|
|
110
|
-
spec: {
|
|
111
|
-
display: {
|
|
112
|
-
name: 'cpu usage'
|
|
113
|
-
},
|
|
114
|
-
plugin: {
|
|
115
|
-
kind: 'TimeSeriesChart',
|
|
116
|
-
spec: {}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
//# sourceMappingURL=PanelDrawer.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelDrawer.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 { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { act } from 'react-dom/test-utils';\nimport { createDashboardProviderSpy, getTestDashboard, renderWithContext } from '../../test';\nimport { DashboardProvider } from '../../context/DashboardProvider';\nimport { PanelDrawer } from './PanelDrawer';\n\ndescribe('Panel Drawer', () => {\n const renderPanelDrawer = () => {\n const { store, DashboardProviderSpy } = createDashboardProviderSpy();\n\n renderWithContext(\n <DashboardProvider initialState={{ dashboardResource: getTestDashboard(), isEditMode: true }}>\n <DashboardProviderSpy />\n <PanelDrawer />\n </DashboardProvider>\n );\n\n const { value: storeApi } = store;\n if (storeApi === undefined) {\n throw new Error('Expected dashboard store to be set after initial render');\n }\n\n return storeApi;\n };\n\n it('should add new panel', async () => {\n const storeApi = renderPanelDrawer();\n\n // Open the drawer for a new panel\n act(() => storeApi.getState().openAddPanel());\n\n const nameInput = await screen.findByLabelText(/Name/);\n userEvent.type(nameInput, 'New Panel');\n userEvent.click(screen.getByText('Add'));\n\n // TODO: Assert drawer is closed?\n const panels = storeApi.getState().panels;\n expect(panels).toMatchObject({\n // Should have the new panel in the store\n NewPanel: {\n kind: 'Panel',\n spec: {\n display: { name: 'New Panel' },\n plugin: {\n kind: '',\n spec: {},\n },\n },\n },\n });\n });\n\n it('should add panel with duplicate panel name', async () => {\n const storeApi = renderPanelDrawer();\n\n act(() => storeApi.getState().openAddPanel());\n\n const nameInput = await screen.findByLabelText(/Name/);\n userEvent.type(nameInput, 'cpu');\n userEvent.click(screen.getByText('Add'));\n\n const panels = storeApi.getState().panels;\n expect(panels).toMatchObject({\n // make sure we don't have duplicate panel key by appending \"-1\"\n 'cpu-1': {\n kind: 'Panel',\n spec: {\n display: { name: 'cpu' },\n plugin: {\n kind: '',\n spec: {},\n },\n },\n },\n });\n });\n\n it('should edit an existing panel', async () => {\n const storeApi = renderPanelDrawer();\n\n // Open the drawer for an existing panel\n const group = Object.values(storeApi.getState().panelGroups).find((group) => group.title === 'CPU Stats');\n if (group === undefined) {\n throw new Error('Test group not found');\n }\n const layout = Object.entries(group.itemPanelKeys).find(([, panelKey]) => panelKey === 'cpu');\n if (layout === undefined) {\n throw new Error('Test panel not found');\n }\n act(() => storeApi.getState().openEditPanel({ panelGroupId: group.id, panelGroupItemLayoutId: layout[0] }));\n\n const nameInput = await screen.findByLabelText(/Name/);\n userEvent.clear(nameInput);\n userEvent.type(nameInput, 'cpu usage');\n userEvent.click(screen.getByText('Apply'));\n\n const panels = storeApi.getState().panels;\n expect(panels).toMatchObject({\n cpu: {\n kind: 'Panel',\n spec: {\n display: { name: 'cpu usage' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {},\n },\n },\n },\n });\n });\n});\n"],"names":["screen","userEvent","act","createDashboardProviderSpy","getTestDashboard","renderWithContext","DashboardProvider","PanelDrawer","describe","renderPanelDrawer","store","DashboardProviderSpy","initialState","dashboardResource","isEditMode","value","storeApi","undefined","Error","it","getState","openAddPanel","nameInput","findByLabelText","type","click","getByText","panels","expect","toMatchObject","NewPanel","kind","spec","display","name","plugin","group","Object","values","panelGroups","find","title","layout","entries","itemPanelKeys","panelKey","openEditPanel","panelGroupId","id","panelGroupItemLayoutId","clear","cpu"],"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,QAAQ,wBAAwB,CAAC;AAChD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,GAAG,QAAQ,sBAAsB,CAAC;AAC3C,SAASC,0BAA0B,EAAEC,gBAAgB,EAAEC,iBAAiB,QAAQ,YAAY,CAAC;AAC7F,SAASC,iBAAiB,QAAQ,iCAAiC,CAAC;AACpE,SAASC,WAAW,QAAQ,eAAe,CAAC;AAE5CC,QAAQ,CAAC,cAAc,EAAE,IAAM;IAC7B,MAAMC,iBAAiB,GAAG,IAAM;QAC9B,MAAM,EAAEC,KAAK,CAAA,EAAEC,oBAAoB,CAAA,EAAE,GAAGR,0BAA0B,EAAE,AAAC;QAErEE,iBAAiB,eACf,MAACC,iBAAiB;YAACM,YAAY,EAAE;gBAAEC,iBAAiB,EAAET,gBAAgB,EAAE;gBAAEU,UAAU,EAAE,IAAI;aAAE;;8BAC1F,KAACH,oBAAoB,KAAG;8BACxB,KAACJ,WAAW,KAAG;;UACG,CACrB,CAAC;QAEF,MAAM,EAAEQ,KAAK,EAAEC,QAAQ,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AC0B,aAAa,CAAC;gBAAEC,YAAY,EAAEX,KAAK,CAACY,EAAE;gBAAEC,sBAAsB,EAAEP,MAAM,CAAC,CAAC,CAAC;aAAE,CAAC,CAAC,CAAC;QAE5G,MAAMpB,SAAS,GAAG,MAAMtB,MAAM,CAACuB,eAAe,QAAQ,AAAC;QACvDtB,SAAS,CAACiD,KAAK,CAAC5B,SAAS,CAAC,CAAC;QAC3BrB,SAAS,CAACuB,IAAI,CAACF,SAAS,EAAE,WAAW,CAAC,CAAC;QACvCrB,SAAS,CAACwB,KAAK,CAACzB,MAAM,CAAC0B,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAE3C,MAAMC,MAAM,GAAGX,QAAQ,CAACI,QAAQ,EAAE,CAACO,MAAM,AAAC;QAC1CC,MAAM,CAACD,MAAM,CAAC,CAACE,aAAa,CAAC;YAC3BsB,GAAG,EAAE;gBACHpB,IAAI,EAAE,OAAO;gBACbC,IAAI,EAAE;oBACJC,OAAO,EAAE;wBAAEC,IAAI,EAAE,WAAW;qBAAE;oBAC9BC,MAAM,EAAE;wBACNJ,IAAI,EAAE,iBAAiB;wBACvBC,IAAI,EAAE,EAAE;qBACT;iBACF;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PanelGroupDialog.test.d.ts","sourceRoot":"","sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,80 +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 { screen } from '@testing-library/react';
|
|
15
|
-
import userEvent from '@testing-library/user-event';
|
|
16
|
-
import { act } from 'react-dom/test-utils';
|
|
17
|
-
import { DashboardProvider } from '../../context';
|
|
18
|
-
import { createDashboardProviderSpy, getTestDashboard, renderWithContext } from '../../test';
|
|
19
|
-
import { PanelGroupDialog } from './PanelGroupDialog';
|
|
20
|
-
describe('Add Panel Group', ()=>{
|
|
21
|
-
const renderDialog = ()=>{
|
|
22
|
-
const { store , DashboardProviderSpy } = createDashboardProviderSpy();
|
|
23
|
-
renderWithContext(/*#__PURE__*/ _jsxs(DashboardProvider, {
|
|
24
|
-
initialState: {
|
|
25
|
-
dashboardResource: getTestDashboard(),
|
|
26
|
-
isEditMode: true
|
|
27
|
-
},
|
|
28
|
-
children: [
|
|
29
|
-
/*#__PURE__*/ _jsx(DashboardProviderSpy, {}),
|
|
30
|
-
/*#__PURE__*/ _jsx(PanelGroupDialog, {})
|
|
31
|
-
]
|
|
32
|
-
}));
|
|
33
|
-
const { value: storeApi } = store;
|
|
34
|
-
if (storeApi === undefined) {
|
|
35
|
-
throw new Error('Expected dashboard store to be set after initial render');
|
|
36
|
-
}
|
|
37
|
-
return storeApi;
|
|
38
|
-
};
|
|
39
|
-
it('should add new panel group', async ()=>{
|
|
40
|
-
const storeApi = renderDialog();
|
|
41
|
-
// Open the dialog for a new panel group
|
|
42
|
-
act(()=>storeApi.getState().openAddPanelGroup());
|
|
43
|
-
const nameInput = await screen.findByLabelText(/Name/);
|
|
44
|
-
userEvent.type(nameInput, 'New Panel Group');
|
|
45
|
-
userEvent.click(screen.getByText('Add'));
|
|
46
|
-
// TODO: Figure out how to test this without coupling to the store state
|
|
47
|
-
const panelGroups = Object.values(storeApi.getState().panelGroups);
|
|
48
|
-
expect(panelGroups).toContainEqual({
|
|
49
|
-
id: expect.any(Number),
|
|
50
|
-
title: 'New Panel Group',
|
|
51
|
-
isCollapsed: false,
|
|
52
|
-
itemLayouts: expect.any(Array),
|
|
53
|
-
itemPanelKeys: expect.any(Object)
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
it('should edit existing panel group', async ()=>{
|
|
57
|
-
const storeApi = renderDialog();
|
|
58
|
-
// Open the dialog for an existing panel group
|
|
59
|
-
const group = Object.values(storeApi.getState().panelGroups).find((group)=>group.title === 'CPU Stats');
|
|
60
|
-
if (group === undefined) {
|
|
61
|
-
throw new Error('Missing test group');
|
|
62
|
-
}
|
|
63
|
-
act(()=>storeApi.getState().openEditPanelGroup(group.id));
|
|
64
|
-
const nameInput = await screen.findByLabelText(/Name/);
|
|
65
|
-
userEvent.clear(nameInput);
|
|
66
|
-
userEvent.type(nameInput, 'New Name');
|
|
67
|
-
userEvent.click(screen.getByText('Apply'));
|
|
68
|
-
// TODO: Figure out how to test this without coupling to the store state
|
|
69
|
-
const panelGroups = storeApi.getState().panelGroups;
|
|
70
|
-
expect(panelGroups).toMatchObject({
|
|
71
|
-
[group.id]: {
|
|
72
|
-
id: group.id,
|
|
73
|
-
title: 'New Name',
|
|
74
|
-
isCollapsed: false
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
//# sourceMappingURL=PanelGroupDialog.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.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 { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { act } from 'react-dom/test-utils';\nimport { DashboardProvider } from '../../context';\nimport { createDashboardProviderSpy, getTestDashboard, renderWithContext } from '../../test';\nimport { PanelGroupDialog } from './PanelGroupDialog';\n\ndescribe('Add Panel Group', () => {\n const renderDialog = () => {\n const { store, DashboardProviderSpy } = createDashboardProviderSpy();\n\n renderWithContext(\n <DashboardProvider initialState={{ dashboardResource: getTestDashboard(), isEditMode: true }}>\n <DashboardProviderSpy />\n <PanelGroupDialog />\n </DashboardProvider>\n );\n\n const { value: storeApi } = store;\n if (storeApi === undefined) {\n throw new Error('Expected dashboard store to be set after initial render');\n }\n\n return storeApi;\n };\n\n it('should add new panel group', async () => {\n const storeApi = renderDialog();\n\n // Open the dialog for a new panel group\n act(() => storeApi.getState().openAddPanelGroup());\n\n const nameInput = await screen.findByLabelText(/Name/);\n userEvent.type(nameInput, 'New Panel Group');\n userEvent.click(screen.getByText('Add'));\n\n // TODO: Figure out how to test this without coupling to the store state\n const panelGroups = Object.values(storeApi.getState().panelGroups);\n expect(panelGroups).toContainEqual({\n id: expect.any(Number),\n title: 'New Panel Group',\n isCollapsed: false,\n itemLayouts: expect.any(Array),\n itemPanelKeys: expect.any(Object),\n });\n });\n\n it('should edit existing panel group', async () => {\n const storeApi = renderDialog();\n\n // Open the dialog for an existing panel group\n const group = Object.values(storeApi.getState().panelGroups).find((group) => group.title === 'CPU Stats');\n if (group === undefined) {\n throw new Error('Missing test group');\n }\n act(() => storeApi.getState().openEditPanelGroup(group.id));\n\n const nameInput = await screen.findByLabelText(/Name/);\n userEvent.clear(nameInput);\n userEvent.type(nameInput, 'New Name');\n userEvent.click(screen.getByText('Apply'));\n\n // TODO: Figure out how to test this without coupling to the store state\n const panelGroups = storeApi.getState().panelGroups;\n expect(panelGroups).toMatchObject({\n [group.id]: {\n id: group.id,\n title: 'New Name',\n isCollapsed: false,\n },\n });\n });\n});\n"],"names":["screen","userEvent","act","DashboardProvider","createDashboardProviderSpy","getTestDashboard","renderWithContext","PanelGroupDialog","describe","renderDialog","store","DashboardProviderSpy","initialState","dashboardResource","isEditMode","value","storeApi","undefined","Error","it","getState","openAddPanelGroup","nameInput","findByLabelText","type","click","getByText","panelGroups","Object","values","expect","toContainEqual","id","any","Number","title","isCollapsed","itemLayouts","Array","itemPanelKeys","group","find","openEditPanelGroup","clear","toMatchObject"],"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,QAAQ,wBAAwB,CAAC;AAChD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,GAAG,QAAQ,sBAAsB,CAAC;AAC3C,SAASC,iBAAiB,QAAQ,eAAe,CAAC;AAClD,SAASC,0BAA0B,EAAEC,gBAAgB,EAAEC,iBAAiB,QAAQ,YAAY,CAAC;AAC7F,SAASC,gBAAgB,QAAQ,oBAAoB,CAAC;AAEtDC,QAAQ,CAAC,iBAAiB,EAAE,IAAM;IAChC,MAAMC,YAAY,GAAG,IAAM;QACzB,MAAM,EAAEC,KAAK,CAAA,EAAEC,oBAAoB,CAAA,EAAE,GAAGP,0BAA0B,EAAE,AAAC;QAErEE,iBAAiB,eACf,MAACH,iBAAiB;YAACS,YAAY,EAAE;gBAAEC,iBAAiB,EAAER,gBAAgB,EAAE;gBAAES,UAAU,EAAE,IAAI;aAAE;;8BAC1F,KAACH,oBAAoB,KAAG;8BACxB,KAACJ,gBAAgB,KAAG;;UACF,CACrB,CAAC;QAEF,MAAM,EAAEQ,KAAK,EAAEC,QAAQ,CAAA,E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D,KAAK,GAAKA,KAAK,CAACL,KAAK,KAAK,WAAW,CAAC,AAAC;QAC1G,IAAIK,KAAK,KAAKvB,SAAS,EAAE;YACvB,MAAM,IAAIC,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACxC,CAAC;QACDhB,GAAG,CAAC,IAAMc,QAAQ,CAACI,QAAQ,EAAE,CAACsB,kBAAkB,CAACF,KAAK,CAACR,EAAE,CAAC,CAAC,CAAC;QAE5D,MAAMV,SAAS,GAAG,MAAMtB,MAAM,CAACuB,eAAe,QAAQ,AAAC;QACvDtB,SAAS,CAAC0C,KAAK,CAACrB,SAAS,CAAC,CAAC;QAC3BrB,SAAS,CAACuB,IAAI,CAACF,SAAS,EAAE,UAAU,CAAC,CAAC;QACtCrB,SAAS,CAACwB,KAAK,CAACzB,MAAM,CAAC0B,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAE3C,wEAAwE;QACxE,MAAMC,WAAW,GAAGX,QAAQ,CAACI,QAAQ,EAAE,CAACO,WAAW,AAAC;QACpDG,MAAM,CAACH,WAAW,CAAC,CAACiB,aAAa,CAAC;YAChC,CAACJ,KAAK,CAACR,EAAE,CAAC,EAAE;gBACVA,EAAE,EAAEQ,KAAK,CAACR,EAAE;gBACZG,KAAK,EAAE,UAAU;gBACjBC,WAAW,EAAE,KAAK;aACnB;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TimeRangeControls.test.d.ts","sourceRoot":"","sources":["../../../src/components/TimeRangeControls/TimeRangeControls.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,88 +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 { generatePath } from 'react-router';
|
|
15
|
-
import { createMemoryHistory } from 'history';
|
|
16
|
-
import userEvent from '@testing-library/user-event';
|
|
17
|
-
import { screen, act } from '@testing-library/react';
|
|
18
|
-
import { TimeRangeProvider } from '@perses-dev/plugin-system';
|
|
19
|
-
import { renderWithContext } from '../../test';
|
|
20
|
-
import testDashboard from '../../test/testDashboard';
|
|
21
|
-
import { DashboardProvider } from '../../context';
|
|
22
|
-
import { TimeRangeControls } from './TimeRangeControls';
|
|
23
|
-
const history = createMemoryHistory({
|
|
24
|
-
initialEntries: [
|
|
25
|
-
generatePath('/home'),
|
|
26
|
-
generatePath('/dashboards/:id', {
|
|
27
|
-
id: 'test'
|
|
28
|
-
})
|
|
29
|
-
]
|
|
30
|
-
});
|
|
31
|
-
describe('TimeRangeControls', ()=>{
|
|
32
|
-
let initialState;
|
|
33
|
-
const testDefaultTimeRange = {
|
|
34
|
-
pastDuration: testDashboard.spec.duration
|
|
35
|
-
};
|
|
36
|
-
beforeEach(()=>{
|
|
37
|
-
initialState = {
|
|
38
|
-
dashboardResource: testDashboard
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
const renderTimeRangeControls = (testURLParams)=>{
|
|
42
|
-
renderWithContext(/*#__PURE__*/ _jsx(DashboardProvider, {
|
|
43
|
-
initialState: initialState,
|
|
44
|
-
children: /*#__PURE__*/ _jsx(TimeRangeProvider, {
|
|
45
|
-
initialTimeRange: testDefaultTimeRange,
|
|
46
|
-
enabledURLParams: testURLParams,
|
|
47
|
-
children: /*#__PURE__*/ _jsx(TimeRangeControls, {})
|
|
48
|
-
})
|
|
49
|
-
}), undefined, history);
|
|
50
|
-
};
|
|
51
|
-
it('should default to dashboard duration and update selected time option when clicked', async ()=>{
|
|
52
|
-
renderTimeRangeControls(false);
|
|
53
|
-
expect(screen.getByText('Last 30 minutes')).toBeInTheDocument();
|
|
54
|
-
const dateButton = screen.getByRole('button', {
|
|
55
|
-
name: /time range/i
|
|
56
|
-
});
|
|
57
|
-
userEvent.click(dateButton);
|
|
58
|
-
const firstSelected = screen.getByRole('option', {
|
|
59
|
-
name: 'Last 5 minutes'
|
|
60
|
-
});
|
|
61
|
-
userEvent.click(firstSelected);
|
|
62
|
-
expect(dateButton).toHaveTextContent(/5 minutes/i);
|
|
63
|
-
});
|
|
64
|
-
it('should update URL params with correct time range values', ()=>{
|
|
65
|
-
renderTimeRangeControls(true);
|
|
66
|
-
const dateButton = screen.getByRole('button', {
|
|
67
|
-
name: /time range/i
|
|
68
|
-
});
|
|
69
|
-
userEvent.click(dateButton);
|
|
70
|
-
const firstSelected = screen.getByRole('option', {
|
|
71
|
-
name: 'Last 5 minutes'
|
|
72
|
-
});
|
|
73
|
-
userEvent.click(firstSelected);
|
|
74
|
-
expect(history.location.search).toEqual('?start=5m');
|
|
75
|
-
// pick another option from TimeRangeSelector dropdown
|
|
76
|
-
const secondSelected = screen.getByText('Last 12 hours');
|
|
77
|
-
userEvent.click(secondSelected);
|
|
78
|
-
expect(history.location.search).toEqual('?start=12h');
|
|
79
|
-
// back button should return to previous page selected
|
|
80
|
-
act(()=>{
|
|
81
|
-
history.back();
|
|
82
|
-
});
|
|
83
|
-
expect(history.location.pathname).toEqual('/home');
|
|
84
|
-
});
|
|
85
|
-
// TODO: add additional tests for absolute time selection, other inputs, form validation, etc.
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
//# sourceMappingURL=TimeRangeControls.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.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 { generatePath } from 'react-router';\nimport { createMemoryHistory } from 'history';\nimport userEvent from '@testing-library/user-event';\nimport { screen, act } from '@testing-library/react';\nimport { TimeRangeProvider } from '@perses-dev/plugin-system';\nimport { renderWithContext } from '../../test';\nimport testDashboard from '../../test/testDashboard';\nimport { DashboardProvider, DashboardStoreProps } from '../../context';\nimport { TimeRangeControls } from './TimeRangeControls';\n\nconst history = createMemoryHistory({\n initialEntries: [generatePath('/home'), generatePath('/dashboards/:id', { id: 'test' })],\n});\n\ndescribe('TimeRangeControls', () => {\n let initialState: DashboardStoreProps;\n const testDefaultTimeRange = { pastDuration: testDashboard.spec.duration };\n\n beforeEach(() => {\n initialState = {\n dashboardResource: testDashboard,\n };\n });\n\n const renderTimeRangeControls = (testURLParams: boolean) => {\n renderWithContext(\n <DashboardProvider initialState={initialState}>\n <TimeRangeProvider initialTimeRange={testDefaultTimeRange} enabledURLParams={testURLParams}>\n <TimeRangeControls />\n </TimeRangeProvider>\n </DashboardProvider>,\n undefined,\n history\n );\n };\n\n it('should default to dashboard duration and update selected time option when clicked', async () => {\n renderTimeRangeControls(false);\n expect(screen.getByText('Last 30 minutes')).toBeInTheDocument();\n const dateButton = screen.getByRole('button', { name: /time range/i });\n userEvent.click(dateButton);\n const firstSelected = screen.getByRole('option', { name: 'Last 5 minutes' });\n userEvent.click(firstSelected);\n expect(dateButton).toHaveTextContent(/5 minutes/i);\n });\n\n it('should update URL params with correct time range values', () => {\n renderTimeRangeControls(true);\n const dateButton = screen.getByRole('button', { name: /time range/i });\n userEvent.click(dateButton);\n const firstSelected = screen.getByRole('option', { name: 'Last 5 minutes' });\n userEvent.click(firstSelected);\n expect(history.location.search).toEqual('?start=5m');\n\n // pick another option from TimeRangeSelector dropdown\n const secondSelected = screen.getByText('Last 12 hours');\n userEvent.click(secondSelected);\n expect(history.location.search).toEqual('?start=12h');\n\n // back button should return to previous page selected\n act(() => {\n history.back();\n });\n expect(history.location.pathname).toEqual('/home');\n });\n\n // TODO: add additional tests for absolute time selection, other inputs, form validation, etc.\n});\n"],"names":["generatePath","createMemoryHistory","userEvent","screen","act","TimeRangeProvider","renderWithContext","testDashboard","DashboardProvider","TimeRangeControls","history","initialEntries","id","describe","initialState","testDefaultTimeRange","pastDuration","spec","duration","beforeEach","dashboardResource","renderTimeRangeControls","testURLParams","initialTimeRange","enabledURLParams","undefined","it","expect","getByText","toBeInTheDocument","dateButton","getByRole","name","click","firstSelected","toHaveTextContent","location","search","toEqual","secondSelected","back","pathname"],"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,YAAY,QAAQ,cAAc,CAAC;AAC5C,SAASC,mBAAmB,QAAQ,SAAS,CAAC;AAC9C,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,MAAM,EAAEC,GAAG,QAAQ,wBAAwB,CAAC;AACrD,SAASC,iBAAiB,QAAQ,2BAA2B,CAAC;AAC9D,SAASC,iBAAiB,QAAQ,YAAY,CAAC;AAC/C,OAAOC,aAAa,MAAM,0BAA0B,CAAC;AACrD,SAASC,iBAAiB,QAA6B,eAAe,CAAC;AACvE,SAASC,iBAAiB,QAAQ,qBAAqB,CAAC;AAExD,MAAMC,OAAO,GAAGT,mBAAmB,CAAC;IAClCU,cAAc,EAAE;QAACX,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iB,cAAc,CAAC;IACrD,CAAC,CAAC,CAAC;IAEHT,EAAE,CAAC,yDAAyD,EAAE,IAAM;QAClEL,uBAAuB,CAAC,IAAI,CAAC,CAAC;QAC9B,MAAMS,UAAU,GAAG3B,MAAM,CAAC4B,SAAS,CAAC,QAAQ,EAAE;YAAEC,IAAI,eAAe;SAAE,CAAC,AAAC;QACvE9B,SAAS,CAAC+B,KAAK,CAACH,UAAU,CAAC,CAAC;QAC5B,MAAMI,aAAa,GAAG/B,MAAM,CAAC4B,SAAS,CAAC,QAAQ,EAAE;YAAEC,IAAI,EAAE,gBAAgB;SAAE,CAAC,AAAC;QAC7E9B,SAAS,CAAC+B,KAAK,CAACC,aAAa,CAAC,CAAC;QAC/BP,MAAM,CAACjB,OAAO,CAAC0B,QAAQ,CAACC,MAAM,CAAC,CAACC,OAAO,CAAC,WAAW,CAAC,CAAC;QAErD,sDAAsD;QACtD,MAAMC,cAAc,GAAGpC,MAAM,CAACyB,SAAS,CAAC,eAAe,CAAC,AAAC;QACzD1B,SAAS,CAAC+B,KAAK,CAACM,cAAc,CAAC,CAAC;QAChCZ,MAAM,CAACjB,OAAO,CAAC0B,QAAQ,CAACC,MAAM,CAAC,CAACC,OAAO,CAAC,YAAY,CAAC,CAAC;QAEtD,sDAAsD;QACtDlC,GAAG,CAAC,IAAM;YACRM,OAAO,CAAC8B,IAAI,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;QACHb,MAAM,CAACjB,OAAO,CAAC0B,QAAQ,CAACK,QAAQ,CAAC,CAACH,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AAEH,8FAA8F;AAChG,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variable-model.test.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/variable-model.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,104 +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 { filterVariableList } from './variable-model';
|
|
14
|
-
describe('filterVariableList', ()=>{
|
|
15
|
-
const testSuite = [
|
|
16
|
-
{
|
|
17
|
-
title: 'basic case',
|
|
18
|
-
capturing_regexp: /([^-]*)-host-([^-]*)/g,
|
|
19
|
-
originalValues: [
|
|
20
|
-
{
|
|
21
|
-
label: 'l1',
|
|
22
|
-
value: 'us1-host-ahdix'
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
label: 'l2',
|
|
26
|
-
value: 'us1-host-diua'
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
label: 'l3',
|
|
30
|
-
value: 'eu1-host-adf'
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
label: 'l4',
|
|
34
|
-
value: 'bar'
|
|
35
|
-
}
|
|
36
|
-
],
|
|
37
|
-
result: [
|
|
38
|
-
{
|
|
39
|
-
label: 'l1',
|
|
40
|
-
value: 'us1ahdix'
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
label: 'l2',
|
|
44
|
-
value: 'us1diua'
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
label: 'l3',
|
|
48
|
-
value: 'eu1adf'
|
|
49
|
-
}
|
|
50
|
-
]
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
title: 'duplicate captured value',
|
|
54
|
-
capturing_regexp: /prometheus-(.+):\d+/g,
|
|
55
|
-
originalValues: [
|
|
56
|
-
{
|
|
57
|
-
label: 'l1',
|
|
58
|
-
value: 'prometheus-app:9090'
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
label: 'l2',
|
|
62
|
-
value: 'prometheus-app:9091'
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
label: 'l3',
|
|
66
|
-
value: 'prometheus-platform:9091'
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
label: 'l4',
|
|
70
|
-
value: 'prometheus-database:9091'
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
label: 'l5',
|
|
74
|
-
value: 'prometheus-perses:9091'
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
|
-
result: [
|
|
78
|
-
{
|
|
79
|
-
label: 'l1',
|
|
80
|
-
value: 'app'
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
label: 'l3',
|
|
84
|
-
value: 'platform'
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
label: 'l4',
|
|
88
|
-
value: 'database'
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
label: 'l5',
|
|
92
|
-
value: 'perses'
|
|
93
|
-
}
|
|
94
|
-
]
|
|
95
|
-
}
|
|
96
|
-
];
|
|
97
|
-
testSuite.forEach(({ title , capturing_regexp , originalValues , result })=>{
|
|
98
|
-
it(title, ()=>{
|
|
99
|
-
expect(filterVariableList(originalValues, capturing_regexp)).toEqual(result);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
//# sourceMappingURL=variable-model.test.js.map
|