mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 21:19:28 -06:00
f45eb309ef
* Fix: make webpack pickup workers written in TS * Add comlink to dependencies * Temporary fix: copy paste `toDataQueryError` from @grafana/runtime to avoid web dependencies * Implemented comlink-based centrifuge worker & worker proxy * Temporary fix: implement comlink transferHandlers for subscriptions and streamingdataframes * Move liveTimer filtering from CentrifugeService into GrafanaLiveService * Switch from CentrifugeService to CentrifugeServiceWorkerProxy in GrafanaLive * Naming fix * Refactor: move liveTimer-based data filtering from GrafanaLiveService to CentrifugeServiceWorker * observe dataStream on an async scheduler * Fix: - Unsubscribe is now propagated from the main thread to the worker, - improve worker&workerProxy types * Fix: Prettify types * Fix: Add error & complete observers * Docs: Add comment explaining the `subscriberTransferHandler` * Fix: Replace `StreamingDataFrameHandler` with explicitly converting StreamingDataFrame to a DataFrameDTO * Refactor: move liveTimer filtering to service.ts to make it easy to implement a `live-service-web-worker` feature flag * Feat: add `live-service-web-worker` feature flag * Fix: extract toDataQueryError.ts to a separate file within `@grafana-runtime` to avoid having a dependency from webworker to the whole package (@grafana-runtime/index.ts) * Update public/app/features/dashboard/dashgrid/liveTimer.ts Co-authored-by: Leon Sorokin <leeoniya@gmail.com> * Fix: fixed default import class in worker file * Fix: cast worker as Endpoint * Migrate from worker-loader to webpack native worker support v1 - broken prod build * Fix: Use custom path in HtmlWebpackPlugin * Fix: Loading workers from CDNs * Fix: Avoid issues with jest ESM support by mocking `createWorker` files * Fix: move the custom mockWorker rendering layout to `test/mocks` Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
72 lines
1.9 KiB
TypeScript
72 lines
1.9 KiB
TypeScript
import { configure } from 'enzyme';
|
|
import { EventBusSrv } from '@grafana/data';
|
|
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
|
|
import $ from 'jquery';
|
|
import 'mutationobserver-shim';
|
|
import './mocks/workers';
|
|
|
|
const testAppEvents = new EventBusSrv();
|
|
const global = window as any;
|
|
global.$ = global.jQuery = $;
|
|
|
|
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
|
|
Object.defineProperty(global, 'matchMedia', {
|
|
writable: true,
|
|
value: jest.fn().mockImplementation((query) => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: jest.fn(), // deprecated
|
|
removeListener: jest.fn(), // deprecated
|
|
addEventListener: jest.fn(),
|
|
removeEventListener: jest.fn(),
|
|
dispatchEvent: jest.fn(),
|
|
})),
|
|
});
|
|
|
|
import '../vendor/flot/jquery.flot';
|
|
import '../vendor/flot/jquery.flot.time';
|
|
import angular from 'angular';
|
|
|
|
angular.module('grafana', ['ngRoute']);
|
|
angular.module('grafana.services', ['ngRoute', '$strap.directives']);
|
|
angular.module('grafana.panels', []);
|
|
angular.module('grafana.controllers', []);
|
|
angular.module('grafana.directives', []);
|
|
angular.module('grafana.filters', []);
|
|
angular.module('grafana.routes', ['ngRoute']);
|
|
|
|
jest.mock('../app/core/core', () => ({ appEvents: testAppEvents }));
|
|
jest.mock('../app/angular/partials', () => ({}));
|
|
jest.mock('../app/features/plugins/plugin_loader', () => ({}));
|
|
|
|
configure({ adapter: new Adapter() });
|
|
|
|
const localStorageMock = (() => {
|
|
let store: any = {};
|
|
return {
|
|
getItem: (key: string) => {
|
|
return store[key];
|
|
},
|
|
setItem: (key: string, value: any) => {
|
|
store[key] = value.toString();
|
|
},
|
|
clear: () => {
|
|
store = {};
|
|
},
|
|
removeItem: (key: string) => {
|
|
delete store[key];
|
|
},
|
|
};
|
|
})();
|
|
|
|
global.localStorage = localStorageMock;
|
|
|
|
const throwUnhandledRejections = () => {
|
|
process.on('unhandledRejection', (err) => {
|
|
throw err;
|
|
});
|
|
};
|
|
|
|
throwUnhandledRejections();
|