mirror of
https://github.com/apache/superset.git
synced 2026-07-25 08:02:28 +00:00
36 tests across 4 charts exercising different defineChart features:
Pie/Pie.test.ts (11 tests)
Plugin metadata (name, category, behaviors: Drill*), controlPanel
auto-generation (Query + Chart Options sections, _glyphArgs),
custom buildQuery (contribution post-processing, conditional
orderby), loaders presence.
Timeseries/Line/Line.test.ts (9 tests)
Plugin metadata, supportedAnnotationTypes pass-through (Event,
Formula, Interval, Timeseries), formDataOverrides preservation
(ExtraControls + getStandardizedControls pattern), thumbnails,
_glyphArgs, loaders.
Sunburst/Sunburst.test.ts (8 tests)
Plugin metadata, Drill behaviors, formDataOverrides preservation,
additionalControlOverrides merging into controlPanel.controlOverrides,
_glyphArgs, loaders. Sunburst exercises the complex cross-filter
useCallback render pattern, which we don't deeply unit-test here
(would require full Redux + React rendering); plugin-level shape
is verified.
BigNumber/BigNumberPeriodOverPeriod.test.ts (8 tests)
Plugin metadata, additionalSections append-after-Chart-Options
semantics (Time Comparison section), additional section has its
own controlSetRows, controlOverrides merging, _glyphArgs, loaders.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
115 lines
4.2 KiB
TypeScript
115 lines
4.2 KiB
TypeScript
/**
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
* or more contributor license agreements. See the NOTICE file
|
|
* distributed with this work for additional information
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
* to you under the Apache License, Version 2.0 (the
|
|
* "License"); you may not use this file except in compliance
|
|
* with the License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing,
|
|
* software distributed under the License is distributed on an
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
* KIND, either express or implied. See the License for the
|
|
* specific language governing permissions and limitations
|
|
* under the License.
|
|
*/
|
|
import { AnnotationType, Behavior, ChartPlugin } from '@superset-ui/core';
|
|
import EchartsTimeseriesLineChartPlugin from '../../../src/Timeseries/Line';
|
|
|
|
describe('Timeseries Line - plugin metadata', () => {
|
|
test('is a ChartPlugin subclass', () => {
|
|
const plugin = new EchartsTimeseriesLineChartPlugin();
|
|
expect(plugin).toBeInstanceOf(ChartPlugin);
|
|
});
|
|
|
|
test('has the expected name and category', () => {
|
|
const plugin = new EchartsTimeseriesLineChartPlugin();
|
|
const metadata = (plugin as unknown as { metadata: Record<string, unknown> })
|
|
.metadata;
|
|
expect(metadata.name).toBe('Line Chart');
|
|
expect(metadata.category).toBe('Evolution');
|
|
});
|
|
|
|
test('declares cross-filter behaviors', () => {
|
|
const plugin = new EchartsTimeseriesLineChartPlugin();
|
|
const metadata = (plugin as unknown as {
|
|
metadata: { behaviors: string[] };
|
|
}).metadata;
|
|
expect(metadata.behaviors).toEqual(
|
|
expect.arrayContaining([
|
|
Behavior.InteractiveChart,
|
|
Behavior.DrillToDetail,
|
|
Behavior.DrillBy,
|
|
]),
|
|
);
|
|
});
|
|
|
|
test('declares supportedAnnotationTypes (Event, Formula, Interval, Timeseries)', () => {
|
|
const plugin = new EchartsTimeseriesLineChartPlugin();
|
|
const metadata = (plugin as unknown as {
|
|
metadata: { supportedAnnotationTypes: string[] };
|
|
}).metadata;
|
|
expect(metadata.supportedAnnotationTypes).toEqual(
|
|
expect.arrayContaining([
|
|
AnnotationType.Event,
|
|
AnnotationType.Formula,
|
|
AnnotationType.Interval,
|
|
AnnotationType.Timeseries,
|
|
]),
|
|
);
|
|
});
|
|
|
|
test('has thumbnails and an example gallery', () => {
|
|
const plugin = new EchartsTimeseriesLineChartPlugin();
|
|
const metadata = (plugin as unknown as {
|
|
metadata: { thumbnail?: string; exampleGallery?: unknown[] };
|
|
}).metadata;
|
|
expect(metadata.thumbnail).toBeTruthy();
|
|
expect(metadata.exampleGallery?.length).toBeGreaterThan(0);
|
|
});
|
|
});
|
|
|
|
describe('Timeseries Line - controlPanel + additionalControls', () => {
|
|
test('controlPanel has the Query section auto-generated', () => {
|
|
const plugin = new EchartsTimeseriesLineChartPlugin();
|
|
const cp = (plugin as unknown as { controlPanel: Record<string, unknown> })
|
|
.controlPanel;
|
|
const sections = cp.controlPanelSections as Array<{ label?: string }>;
|
|
expect(sections.some(s => s?.label === 'Query')).toBe(true);
|
|
});
|
|
|
|
test('formDataOverrides is present (ExtraControls/standardize pattern)', () => {
|
|
const plugin = new EchartsTimeseriesLineChartPlugin();
|
|
const cp = (plugin as unknown as {
|
|
controlPanel: { formDataOverrides?: unknown };
|
|
}).controlPanel;
|
|
expect(typeof cp.formDataOverrides).toBe('function');
|
|
});
|
|
|
|
test('_glyphArgs is attached', () => {
|
|
const plugin = new EchartsTimeseriesLineChartPlugin();
|
|
const cp = (plugin as unknown as {
|
|
controlPanel: { _glyphArgs?: Record<string, unknown> };
|
|
}).controlPanel;
|
|
expect(cp._glyphArgs).toBeDefined();
|
|
});
|
|
});
|
|
|
|
describe('Timeseries Line - plugin loaders', () => {
|
|
test('exposes loadChart / loadTransformProps / loadBuildQuery', () => {
|
|
const plugin = new EchartsTimeseriesLineChartPlugin();
|
|
expect(
|
|
(plugin as unknown as { loadChart?: unknown }).loadChart,
|
|
).toBeDefined();
|
|
expect(
|
|
(plugin as unknown as { loadTransformProps?: unknown }).loadTransformProps,
|
|
).toBeDefined();
|
|
expect(
|
|
(plugin as unknown as { loadBuildQuery?: unknown }).loadBuildQuery,
|
|
).toBeDefined();
|
|
});
|
|
});
|