Skip to content

Commit

Permalink
Fix: Streaming Backend Websocket DS provisioning (#341)
Browse files Browse the repository at this point in the history
* chore(repo): add empty tsconfig.json so VScode doesn't choke when opening the project

* fix(ds-streambkend-websocket): provide valid datasource provisioning

* test(ds-streambkend-websocket): add e2e test to validate provisioning works out the box
  • Loading branch information
jackw authored Jul 12, 2024
1 parent 9e40718 commit 2e4fde4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ apiVersion: 1
datasources:
- name: Streaming websocket datasource
type: example-websocket-backend-datasource
uid: PA8F7D06AF7AEED65
access: proxy
isDefault: true
orgId: 1
version: 1
editable: true
url: 'ws://host.docker.internal:8080'
jsonData:
path: '/resources'
defaultTimeField:
secureJsonData:
apiKey: 'api-key'
uri: 'ws://host.docker.internal:8080'
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import { test, expect } from '@grafana/plugin-e2e';
import { BasicDataSourceOptions, BasicSecureJsonData } from '../src/types';
import { MyDataSourceOptions } from '../src/types';

test('Provisioned data source with valid credentials should return a 200 status code', async ({
readProvisionedDataSource,
gotoDataSourceConfigPage,
}) => {
const datasource = await readProvisionedDataSource({ fileName: 'datasources.yml' });
const configPage = await gotoDataSourceConfigPage(datasource.uid);
await expect(configPage.saveAndTest()).toBeOK();
});

test('"Save & test" should be successful when configuration is valid', async ({
createDataSourceConfigPage,
readProvisionedDataSource,
page,
}) => {
const ds = await readProvisionedDataSource<BasicDataSourceOptions, BasicSecureJsonData>({
const ds = await readProvisionedDataSource<MyDataSourceOptions>({
fileName: 'datasources.yml',
});
const configPage = await createDataSourceConfigPage({ type: ds.type });
Expand All @@ -20,7 +29,7 @@ test('"Save & test" should fail when configuration is invalid', async ({
readProvisionedDataSource,
page,
}) => {
const ds = await readProvisionedDataSource<BasicDataSourceOptions, BasicSecureJsonData>({
const ds = await readProvisionedDataSource<MyDataSourceOptions>({
fileName: 'datasources.yml',
});
const configPage = await createDataSourceConfigPage({ type: ds.type });
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// This file exists so opening the entire repo in VS Code doesn't show a warning about no tsconfig.json file

0 comments on commit 2e4fde4

Please sign in to comment.