Skip to content

Commit 7e7167f

Browse files
authored
Upgrade to Grafana 8.0.0 (#67)
* Upgrade to Grafana 8.0.0 * Fix tests
1 parent bbb9373 commit 7e7167f

File tree

25 files changed

+1759
-2065
lines changed

25 files changed

+1759
-2065
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Change Log
22

3-
## 1.3.0 (IN PROGRESS)
3+
## 2.0.0 (IN PROGRESS)
44

55
### Bug fixes
66

77
- "Available Requirements" panel should be set to $redis datasource #63
88
- Cannot read property 'v1' of undefined (theme.v1) in the Grafana8 #65
9+
- Upgrade to Grafana 8.0.2
910

1011
## 1.2.0 (2021-05-11)
1112

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ All dashboards are available from the application's icon in the left side menu.
4343

4444
### Requirements
4545

46-
Only **Grafana 7.1+** with a new Backend plug-in platform supports Redis plug-ins.
46+
- **Grafana 8.0** is required for Redis Application 2.X.
47+
- **Grafana 7.1+** is required for Redis Application 1.X.
4748

4849
## Getting Started
4950

appveyor.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

config/jest-setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { configure } from 'enzyme';
2-
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
2+
import Adapter from 'enzyme-adapter-react-16';
33

44
/**
55
* Configure for React

docker-compose/dev-7.2.1.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
"author": "RedisGrafana",
33
"description": "Redis Application for Grafana",
44
"devDependencies": {
5-
"@grafana/data": "7.5.4",
6-
"@grafana/runtime": "7.5.4",
7-
"@grafana/toolkit": "7.5.4",
8-
"@grafana/ui": "7.5.4",
9-
"@monaco-editor/react": "^4.1.1",
5+
"@grafana/data": "8.0.2",
6+
"@grafana/runtime": "8.0.2",
7+
"@grafana/toolkit": "8.0.2",
8+
"@grafana/ui": "8.0.2",
9+
"@monaco-editor/react": "^4.2.0",
1010
"@types/enzyme": "^3.10.8",
11-
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.1",
12-
"emotion": "10.0.27",
11+
"@types/enzyme-adapter-react-16": "^1.0.6",
12+
"emotion": "11.0.0",
1313
"enzyme": "^3.11.0",
14-
"tslib": "^2.2.0"
14+
"enzyme-adapter-react-16": "^1.15.6",
15+
"tslib": "^2.3.0"
1516
},
1617
"engines": {
1718
"node": ">=12"
@@ -25,13 +26,12 @@
2526
"sign": "grafana-toolkit plugin:sign",
2627
"start": "docker-compose up",
2728
"start:dev": "docker-compose -f docker-compose/dev.yml up",
28-
"start:dev-7.2.1": "docker-compose -f docker-compose/dev-7.2.1.yml up",
2929
"start:master": "docker-compose -f docker-compose/master.yml pull && docker-compose -f docker-compose/master.yml up",
3030
"stop": "docker-compose down",
3131
"stop:dev": "docker-compose -f docker-compose/dev.yml down",
3232
"test": "grafana-toolkit plugin:test --coverage",
3333
"upgrade": "yarn upgrade --latest",
3434
"watch": "grafana-toolkit plugin:dev --watch"
3535
},
36-
"version": "1.3.0"
36+
"version": "2.0.0"
3737
}
Lines changed: 13 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import React from 'react';
2-
import { config, setLocationSrv } from '@grafana/runtime';
31
import { shallow } from 'enzyme';
2+
import React from 'react';
3+
import { setLocationSrv } from '@grafana/runtime';
4+
import { ApplicationRoot } from '../../constants';
45
import { Config } from './config';
56

67
/*
@@ -18,8 +19,6 @@ const getPlugin = (overridePlugin: any = { meta: {} }) => ({
1819
Config
1920
*/
2021
describe('Config', () => {
21-
let initialDataSources = config.datasources;
22-
2322
beforeAll(() => {
2423
jest.spyOn(Config, 'getLocation').mockImplementation((): any => ({
2524
assign: jest.fn(),
@@ -31,67 +30,41 @@ describe('Config', () => {
3130
Initialization
3231
*/
3332
describe('Initialization', () => {
34-
it('If plugin is not enabled, state should have isEnabled = false and isConfigured = false', () => {
35-
const plugin = getPlugin({ meta: { enabled: false } });
36-
config.datasources = {
37-
redis: {
38-
type: 'redis-datasource',
39-
} as any,
40-
};
33+
it('If plugin is not enabled and meta is not set, state should have isEnabled = false', () => {
34+
const plugin = getPlugin({});
4135
const wrapper = shallow<Config>(<Config plugin={plugin} query={null as any} />);
42-
expect(wrapper.state().isEnabled).toBeFalsy();
43-
expect(wrapper.state().isConfigured).toBeFalsy();
36+
expect(wrapper.state().isEnabled).toBeTruthy();
4437
});
4538

46-
it('If plugin is enabled but config does not have needed datasources, state should have isEnabled = true and isConfigured = false', () => {
47-
const plugin = getPlugin({ meta: { enabled: true } });
48-
config.datasources = {};
39+
it('If plugin is not enabled, state should have isEnabled = false', () => {
40+
const plugin = getPlugin({ meta: { enabled: false } });
4941
const wrapper = shallow<Config>(<Config plugin={plugin} query={null as any} />);
50-
expect(wrapper.state().isEnabled).toBeTruthy();
51-
expect(wrapper.state().isConfigured).toBeFalsy();
42+
expect(wrapper.state().isEnabled).toBeFalsy();
5243
});
5344

54-
it('If plugin is enabled and config has needed datasources, state should have isEnabled = true and isConfigured = true', () => {
45+
it('If plugin is enabled, state should have isEnabled = true', () => {
5546
const plugin = getPlugin({ meta: { enabled: true } });
56-
config.datasources = {
57-
redis: {
58-
type: 'redis-datasource',
59-
} as any,
60-
};
6147
const wrapper = shallow<Config>(<Config plugin={plugin} query={null as any} />);
6248
expect(wrapper.state().isEnabled).toBeTruthy();
63-
expect(wrapper.state().isConfigured).toBeTruthy();
6449
});
6550
});
6651

6752
/*
6853
Rendering
6954
*/
7055
describe('rendering', () => {
71-
beforeAll(() => {
72-
config.datasources = {
73-
redis: {
74-
type: 'redis-datasource',
75-
} as any,
76-
};
77-
});
78-
79-
it('If plugin is not configured, should show only enable button', () => {
56+
it('If plugin is not configured, should show enable button', () => {
8057
const plugin = getPlugin({ meta: { enabled: false } });
8158
const wrapper = shallow<Config>(<Config plugin={plugin} query={null as any} />);
8259
const enableButton = wrapper.findWhere((node) => node.name() === 'Button' && node.text() === 'Enable');
83-
const updateButton = wrapper.findWhere((node) => node.name() === 'Button' && node.text() === 'Update');
8460
expect(enableButton.exists()).toBeTruthy();
85-
expect(updateButton.exists()).not.toBeTruthy();
8661
});
8762

88-
it('If plugin is configured, should show update and disable buttons', () => {
63+
it('If plugin is configured, should show disable buttons', () => {
8964
const plugin = getPlugin({ meta: { enabled: true } });
9065
const wrapper = shallow<Config>(<Config plugin={plugin} query={null as any} />);
9166
const disableButton = wrapper.findWhere((node) => node.name() === 'Button' && node.text() === 'Disable');
92-
const updateButton = wrapper.findWhere((node) => node.name() === 'Button' && node.text() === 'Update');
9367
expect(disableButton.exists()).toBeTruthy();
94-
expect(updateButton.exists()).toBeTruthy();
9568
});
9669

9770
it('Enable button should call onEnable method', () => {
@@ -113,38 +86,12 @@ describe('Config', () => {
11386
disableButton.simulate('click');
11487
expect(testedMethod).toHaveBeenCalled();
11588
});
116-
117-
it('Update button should call onUpdate method', () => {
118-
const plugin = getPlugin({ meta: { enabled: true } });
119-
const wrapper = shallow<Config>(<Config plugin={plugin} query={null as any} />);
120-
const testedMethod = jest.spyOn(wrapper.instance(), 'onUpdate').mockImplementation(() => null);
121-
wrapper.instance().forceUpdate();
122-
const updateButton = wrapper.findWhere((node) => node.name() === 'Button' && node.text() === 'Update');
123-
updateButton.simulate('click');
124-
expect(testedMethod).toHaveBeenCalled();
125-
});
12689
});
12790

12891
/*
12992
Methods
13093
*/
13194
describe('Methods', () => {
132-
it('onUpdate should call goHome method', () => {
133-
const plugin = getPlugin({ meta: { enabled: true } });
134-
const wrapper = shallow<Config>(<Config plugin={plugin} query={null as any} />);
135-
const testedMethod = jest.spyOn(wrapper.instance(), 'goHome').mockImplementation();
136-
wrapper.instance().onUpdate();
137-
expect(testedMethod).toHaveBeenCalled();
138-
});
139-
140-
it('onUpdate should not call goHome method if enabled=false', () => {
141-
const plugin = getPlugin({ meta: { enabled: false } });
142-
const wrapper = shallow<Config>(<Config plugin={plugin} query={null as any} />);
143-
const testedMethod = jest.spyOn(wrapper.instance(), 'goHome').mockImplementation();
144-
wrapper.instance().onUpdate();
145-
expect(testedMethod).not.toHaveBeenCalled();
146-
});
147-
14895
it('onDisable should call updatePluginSettings method', () => {
14996
const plugin = getPlugin({ meta: { enabled: true } });
15097
const wrapper = shallow<Config>(<Config plugin={plugin} query={null as any} />);
@@ -186,14 +133,13 @@ describe('Config', () => {
186133
const wrapper = shallow<Config>(<Config plugin={plugin} query={null as any} />);
187134
wrapper.instance().goHome();
188135
expect(updateLocationMock).toHaveBeenCalledWith({
189-
path: 'a/redis-app/',
136+
path: ApplicationRoot,
190137
partial: false,
191138
});
192139
});
193140
});
194141

195142
afterAll(() => {
196-
config.datasources = initialDataSources;
197143
jest.resetAllMocks();
198144
});
199145
});

0 commit comments

Comments
 (0)