Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from VolkovLabs/feat/add-tests
Browse files Browse the repository at this point in the history
Fix tests and update README
  • Loading branch information
mikhail-vl authored Dec 1, 2021
2 parents c96c421 + 9335976 commit 5e600b4
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ jobs:
echo "::set-output name=checksum::$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)"
- name: Lint plugin
continue-on-error: true
run: |
git clone https://github.com/grafana/plugin-validator
pushd ./plugin-validator/pkg/cmd/plugincheck
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Change Log

## 1.0.0 (IN PROGRESS)
## 1.0.0 (2021-12-01)

### Features / Enhancements

Expand Down
30 changes: 25 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,50 @@
# Abc panel plugin for Grafana
# Template to create a new Grafana panel plugin

[![Grafana 8](https://img.shields.io/badge/Grafana-8-orange)](https://www.grafana.com)
![CI](https://github.com/volkovlabs/grafana-abc-panel/workflows/CI/badge.svg)
[![codecov](https://codecov.io/gh/VolkovLabs/grafana-abc-panel/branch/main/graph/badge.svg?token=0m6f0ktUar)](https://codecov.io/gh/VolkovLabs/grafana-abc-panel)

## Introduction

The ABC Panel is a template to create new panel plugin for Grafana.
The ABC Panel is a template to create a new panel plugin for Grafana.

### Requirements

Grafana 8.0 is required.

## Getting Started

Use the `grafana-cli` tool to install from the command line:
1. Install packages

```bash
grafana-cli plugins install abc-panel
yarn install
```

2. Build the plugin

```bash
yarn build
```

3. Sign the plugins

```
export GRAFANA_API_KEY=erXXXX==
yarn sign
```

4. Start Docker container

```bash
yarn run start
```

## Features

- Use `docker-compose` to start development environment with provisioned datasource and dashboard.
- Use `docker-compose` to start development environment with provisioned data source and dashboard.
- Provides unit test configuration.
- Based on the latest version of Grafana.
- Includes GitHub Actions for CI and Release.

## Feedback

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"engines": {
"node": ">=14"
},
"name": "abc-panel",
"name": "grafana-abc-panel",
"scripts": {
"build": "grafana-toolkit plugin:build --coverage",
"dev": "grafana-toolkit plugin:dev",
Expand Down
28 changes: 27 additions & 1 deletion src/abc-panel/abc-panel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,34 @@ describe('Panel', () => {
return <AbcPanel data={data} {...restProps} options={options} />;
};

const wrapper = shallow(getComponent({ date: { series: [] } }));
const wrapper = shallow(getComponent({}));
const div = wrapper.find('div');
expect(div.exists()).toBeTruthy();
});

it('Should get the latest value', async () => {
const getComponent = ({ options = { name: 'data' }, ...restProps }: any) => {
const data = {
series: [
toDataFrame({
name: 'data',
refId: 'A',
fields: [
{
name: 'data',
type: 'string',
values: ['Hello World!'],
},
],
}),
],
};
return <AbcPanel data={data} {...restProps} options={options} />;
};

const wrapper = shallow(getComponent({}));
const div = wrapper.find('div');
expect(div.exists()).toBeTruthy();
expect(div.text()).toEqual('Hello World!');
});
});
4 changes: 3 additions & 1 deletion src/module.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ describe('plugin', () => {
addFieldNamePicker: jest.fn().mockImplementation(() => builder),
};

plugin['registerOptionEditors'](builder);

/**
* Inputs
*/
plugin['registerOptionEditors'](builder);
expect(builder.addFieldNamePicker).toHaveBeenCalled();
});
});

0 comments on commit 5e600b4

Please sign in to comment.