level_0
int64
0
10k
index
int64
0
0
repo_id
stringlengths
22
152
file_path
stringlengths
41
203
content
stringlengths
11
11.5M
7,270
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/CrossFilters
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/CrossFilters/ScopingModal/ScopingModal.test.tsx
/** * 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 React from 'react'; import fetchMock from 'fetch-mock'; import userEvent from '@testing-library/user-event'; import { render, screen, waitFor, within } from 'spec/helpers/testing-library'; import { CHART_TYPE, DASHBOARD_ROOT_TYPE, } from 'src/dashboard/util/componentTypes'; import { DASHBOARD_ROOT_ID } from 'src/dashboard/util/constants'; import { ScopingModal, ScopingModalProps } from './ScopingModal'; const INITIAL_STATE = { charts: { 1: { id: 1 }, 2: { id: 2 }, 3: { id: 3 }, 4: { id: 4 }, }, dashboardInfo: { id: 1, metadata: { chart_configuration: { 1: { id: 1, crossFilters: { scope: 'global' as const, chartsInScope: [2, 3, 4], }, }, 2: { id: 2, crossFilters: { scope: 'global' as const, chartsInScope: [1, 3, 4], }, }, 3: { id: 3, crossFilters: { scope: { rootPath: ['ROOT_ID'], excluded: [1, 3], }, chartsInScope: [2, 4], }, }, 4: { id: 4, crossFilters: { scope: { rootPath: ['ROOT_ID'], excluded: [1, 4], }, chartsInScope: [2, 3], }, }, }, global_chart_configuration: { scope: { rootPath: ['ROOT_ID'], excluded: [] }, chartsInScope: [1, 2, 3, 4], }, }, }, dashboardLayout: { past: [], future: [], present: { [DASHBOARD_ROOT_ID]: { type: DASHBOARD_ROOT_TYPE, id: DASHBOARD_ROOT_ID, children: ['CHART_1', 'CHART_2', 'CHART_3', 'CHART_4'], }, CHART_1: { id: 'CHART_1', type: CHART_TYPE, meta: { chartId: 1, sliceName: 'chart 1', }, parents: ['ROOT_ID'], }, CHART_2: { id: 'CHART_2', type: CHART_TYPE, meta: { chartId: 2, sliceName: 'chart 2', }, parents: ['ROOT_ID'], }, CHART_3: { id: 'CHART_3', type: CHART_TYPE, meta: { chartId: 3, sliceName: 'chart 3', sliceNameOverride: 'Chart 3', }, parents: ['ROOT_ID'], }, CHART_4: { id: 'CHART_4', type: CHART_TYPE, meta: { chartId: 4, sliceName: 'chart 4', }, parents: ['ROOT_ID'], }, }, }, }; const DEFAULT_PROPS: ScopingModalProps = { closeModal: jest.fn(), initialChartId: undefined, isVisible: true, }; const setup = (props = DEFAULT_PROPS) => render(<ScopingModal {...props} />, { useRedux: true, initialState: INITIAL_STATE, }); const DASHBOARD_UPDATE_URL = 'glob:*api/v1/dashboard/1'; beforeEach(() => { fetchMock.put(DASHBOARD_UPDATE_URL, 200); }); afterEach(() => { fetchMock.restore(); }); it('renders modal', () => { setup(); expect(screen.getByRole('dialog')).toBeVisible(); expect(screen.getByTestId('scoping-tree-panel')).toBeInTheDocument(); expect(screen.getByTestId('scoping-list-panel')).toBeInTheDocument(); }); it('switch currently edited chart scoping', async () => { setup(); const withinScopingList = within(screen.getByTestId('scoping-list-panel')); expect(withinScopingList.getByText('All charts/global scoping')).toHaveClass( 'active', ); userEvent.click(withinScopingList.getByText('Chart 3')); await waitFor(() => { expect(withinScopingList.getByText('Chart 3')).toHaveClass('active'); expect( withinScopingList.getByText('All charts/global scoping'), ).not.toHaveClass('active'); }); }); it('scoping tree global and custom checks', () => { setup(); expect( document.querySelectorAll( '[data-test="scoping-tree-panel"] .ant-tree-checkbox-checked', ), ).toHaveLength(5); userEvent.click( within(screen.getByTestId('scoping-list-panel')).getByText('Chart 3'), ); expect( document.querySelectorAll( '[data-test="scoping-tree-panel"] .ant-tree-checkbox-checked', ), ).toHaveLength(2); }); it('add new custom scoping', async () => { setup(); userEvent.click(screen.getByText('Add custom scoping')); expect(screen.getByText('[new custom scoping]')).toBeInTheDocument(); expect(screen.getByText('[new custom scoping]')).toHaveClass('active'); await waitFor(() => userEvent.click(screen.getByRole('combobox', { name: 'Select chart' })), ); await waitFor(() => { userEvent.click( within(document.querySelector('.rc-virtual-list')!).getByText('chart 1'), ); }); expect( within(document.querySelector('.ant-select-selection-item')!).getByText( 'chart 1', ), ).toBeInTheDocument(); expect( document.querySelectorAll( '[data-test="scoping-tree-panel"] .ant-tree-checkbox-checked', ), ).toHaveLength(4); userEvent.click( within(document.querySelector('.ant-tree')!).getByText('chart 2'), ); expect( document.querySelectorAll( '[data-test="scoping-tree-panel"] .ant-tree-checkbox-checked', ), ).toHaveLength(2); }); it('edit scope and save', async () => { setup(); // unselect chart 2 in global scoping userEvent.click( within(document.querySelector('.ant-tree')!).getByText('chart 2'), ); userEvent.click( within(screen.getByTestId('scoping-list-panel')).getByText('Chart 3'), ); // select chart 1 in chart 3's custom scoping userEvent.click( within(document.querySelector('.ant-tree')!).getByText('chart 1'), ); // create custom scoping for chart 1 with unselected chart 2 (from global) and chart 4 userEvent.click(screen.getByText('Add custom scoping')); await waitFor(() => userEvent.click(screen.getByRole('combobox', { name: 'Select chart' })), ); await waitFor(() => { userEvent.click( within(document.querySelector('.rc-virtual-list')!).getByText('chart 1'), ); }); userEvent.click( within(document.querySelector('.ant-tree')!).getByText('chart 4'), ); // remove custom scoping for chart 4 userEvent.click( within( within(screen.getByTestId('scoping-list-panel')) .getByText('chart 4') .closest('div')!, ).getByLabelText('trash'), ); expect( within(screen.getByTestId('scoping-list-panel')).queryByText('chart 4'), ).not.toBeInTheDocument(); userEvent.click(screen.getByText('Save')); await waitFor(() => fetchMock.called(DASHBOARD_UPDATE_URL)); expect( JSON.parse( JSON.parse(fetchMock.lastCall()?.[1]?.body as string).json_metadata, ), ).toEqual({ chart_configuration: { '1': { id: 1, crossFilters: { scope: { rootPath: ['ROOT_ID'], excluded: [1, 2, 4] }, chartsInScope: [3], }, }, '2': { id: 2, crossFilters: { scope: 'global', chartsInScope: [1, 3, 4], }, }, '3': { id: 3, crossFilters: { scope: { rootPath: ['ROOT_ID'], excluded: [3] }, chartsInScope: [1, 2, 4], }, }, '4': { id: 4, crossFilters: { scope: 'global', chartsInScope: [1, 3], }, }, }, global_chart_configuration: { scope: { rootPath: ['ROOT_ID'], excluded: [2] }, chartsInScope: [1, 3, 4], }, }); });
7,275
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/CrossFilters
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/CrossFilters/ScopingModal/useCrossFiltersScopingModal.test.ts
/** * 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 { ReactElement } from 'react'; import { renderHook } from '@testing-library/react-hooks'; import { createWrapper, render } from 'spec/helpers/testing-library'; import { useCrossFiltersScopingModal } from './useCrossFiltersScopingModal'; test('Renders modal after calling method open', async () => { const { result } = renderHook(() => useCrossFiltersScopingModal(), { wrapper: createWrapper(), }); const [openModal, Modal] = result.current; expect(Modal).toBeNull(); openModal(); const { getByText } = render(result.current[1] as ReactElement, { useRedux: true, }); expect(getByText('Cross-filtering scoping')).toBeInTheDocument(); });
7,277
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBarSettings/FilterBarSettings.test.tsx
/** * 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 React from 'react'; import fetchMock from 'fetch-mock'; import { waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { render, screen, within } from 'spec/helpers/testing-library'; import { DashboardInfo, FilterBarOrientation } from 'src/dashboard/types'; import * as mockedMessageActions from 'src/components/MessageToasts/actions'; import { FeatureFlag } from '@superset-ui/core'; import FilterBarSettings from '.'; const initialState: { dashboardInfo: DashboardInfo } = { dashboardInfo: { id: 1, userId: '1', metadata: { native_filter_configuration: {}, chart_configuration: {}, global_chart_configuration: { scope: { rootPath: ['ROOT_ID'], excluded: [] }, chartsInScope: [], }, color_scheme: '', color_namespace: '', color_scheme_domain: [], label_colors: {}, shared_label_colors: {}, cross_filters_enabled: false, }, json_metadata: '', dash_edit_perm: true, filterBarOrientation: FilterBarOrientation.VERTICAL, common: { conf: {}, flash_messages: [], }, crossFiltersEnabled: true, }, }; const setup = (dashboardInfoOverride: Partial<DashboardInfo> = {}) => waitFor(() => render(<FilterBarSettings />, { useRedux: true, initialState: { ...initialState, dashboardInfo: { ...initialState.dashboardInfo, ...dashboardInfoOverride, }, }, }), ); test('Dropdown trigger renders with FF HORIZONTAL_FILTER_BAR on', async () => { // @ts-ignore global.featureFlags = { [FeatureFlag.HORIZONTAL_FILTER_BAR]: true, }; await setup(); expect(screen.getByLabelText('gear')).toBeVisible(); }); test('Dropdown trigger does not render with FF HORIZONTAL_FILTER_BAR off', async () => { // @ts-ignore global.featureFlags = { [FeatureFlag.HORIZONTAL_FILTER_BAR]: false, }; await setup(); expect(screen.queryByLabelText('gear')).not.toBeInTheDocument(); }); test('Dropdown trigger renders with dashboard edit permissions', async () => { // @ts-ignore global.featureFlags = { [FeatureFlag.HORIZONTAL_FILTER_BAR]: true, }; await setup({ dash_edit_perm: true, }); expect(screen.getByRole('img', { name: 'gear' })).toBeInTheDocument(); }); test('Dropdown trigger does not render without dashboard edit permissions', async () => { // @ts-ignore global.featureFlags = { [FeatureFlag.HORIZONTAL_FILTER_BAR]: true, }; await setup({ dash_edit_perm: false, }); expect(screen.queryByRole('img', { name: 'gear' })).not.toBeInTheDocument(); }); test('Dropdown trigger renders with FF DASHBOARD_CROSS_FILTERS on', async () => { // @ts-ignore global.featureFlags = { [FeatureFlag.DASHBOARD_CROSS_FILTERS]: true, }; await setup(); expect(screen.getByRole('img', { name: 'gear' })).toBeInTheDocument(); }); test('Dropdown trigger does not render with FF DASHBOARD_CROSS_FILTERS off', async () => { // @ts-ignore global.featureFlags = { [FeatureFlag.DASHBOARD_CROSS_FILTERS]: false, }; await setup(); expect(screen.queryByRole('img', { name: 'gear' })).not.toBeInTheDocument(); }); test('Popover shows cross-filtering option on by default', async () => { // @ts-ignore global.featureFlags = { [FeatureFlag.DASHBOARD_CROSS_FILTERS]: true, }; await setup(); userEvent.click(screen.getByLabelText('gear')); expect(screen.getByText('Enable cross-filtering')).toBeInTheDocument(); expect(screen.getByRole('checkbox')).toBeChecked(); }); test('Can enable/disable cross-filtering', async () => { // @ts-ignore global.featureFlags = { [FeatureFlag.DASHBOARD_CROSS_FILTERS]: true, }; fetchMock.reset(); fetchMock.put('glob:*/api/v1/dashboard/1', { result: {}, }); await setup(); userEvent.click(screen.getByLabelText('gear')); const checkbox = screen.getByRole('checkbox'); expect(checkbox).toBeChecked(); userEvent.click(checkbox); userEvent.click(screen.getByLabelText('gear')); expect(checkbox).not.toBeChecked(); }); test('Popover opens with "Vertical" selected', async () => { // @ts-ignore global.featureFlags = { [FeatureFlag.HORIZONTAL_FILTER_BAR]: true, }; await setup(); userEvent.click(screen.getByLabelText('gear')); userEvent.hover(screen.getByText('Orientation of filter bar')); expect(await screen.findByText('Vertical (Left)')).toBeInTheDocument(); expect(screen.getByText('Horizontal (Top)')).toBeInTheDocument(); expect( within(screen.getAllByRole('menuitem')[1]).getByLabelText('check'), ).toBeInTheDocument(); }); test('Popover opens with "Horizontal" selected', async () => { // @ts-ignore global.featureFlags = { [FeatureFlag.HORIZONTAL_FILTER_BAR]: true, }; await setup({ filterBarOrientation: FilterBarOrientation.HORIZONTAL }); userEvent.click(screen.getByLabelText('gear')); userEvent.hover(screen.getByText('Orientation of filter bar')); expect(await screen.findByText('Vertical (Left)')).toBeInTheDocument(); expect(screen.getByText('Horizontal (Top)')).toBeInTheDocument(); expect( within(screen.getAllByRole('menuitem')[2]).getByLabelText('check'), ).toBeInTheDocument(); }); test('On selection change, send request and update checked value', async () => { // @ts-ignore global.featureFlags = { [FeatureFlag.HORIZONTAL_FILTER_BAR]: true, }; fetchMock.reset(); fetchMock.put('glob:*/api/v1/dashboard/1', { result: { json_metadata: JSON.stringify({ ...initialState.dashboardInfo.metadata, filter_bar_orientation: 'HORIZONTAL', }), }, }); await setup(); userEvent.click(screen.getByLabelText('gear')); userEvent.hover(screen.getByText('Orientation of filter bar')); expect(await screen.findByText('Vertical (Left)')).toBeInTheDocument(); expect(screen.getByText('Horizontal (Top)')).toBeInTheDocument(); expect( within(screen.getAllByRole('menuitem')[1]).getByLabelText('check'), ).toBeInTheDocument(); expect( within(screen.getAllByRole('menuitem')[2]).queryByLabelText('check'), ).not.toBeInTheDocument(); userEvent.click(screen.getByText('Horizontal (Top)')); // 1st check - checkmark appears immediately after click expect( await within(screen.getAllByRole('menuitem')[2]).findByLabelText('check'), ).toBeInTheDocument(); expect( within(screen.getAllByRole('menuitem')[1]).queryByLabelText('check'), ).not.toBeInTheDocument(); // successful query await waitFor(() => expect(fetchMock.lastCall()?.[1]?.body).toEqual( JSON.stringify({ json_metadata: JSON.stringify({ ...initialState.dashboardInfo.metadata, filter_bar_orientation: 'HORIZONTAL', }), }), ), ); // 2nd check - checkmark stays after successful query expect( await within(screen.getAllByRole('menuitem')[2]).findByLabelText('check'), ).toBeInTheDocument(); expect( within(screen.getAllByRole('menuitem')[1]).queryByLabelText('check'), ).not.toBeInTheDocument(); fetchMock.reset(); }); test('On failed request, restore previous selection', async () => { // @ts-ignore global.featureFlags = { [FeatureFlag.HORIZONTAL_FILTER_BAR]: true, }; fetchMock.reset(); fetchMock.put('glob:*/api/v1/dashboard/1', 400); const dangerToastSpy = jest.spyOn(mockedMessageActions, 'addDangerToast'); await setup(); userEvent.click(screen.getByLabelText('gear')); userEvent.hover(screen.getByText('Orientation of filter bar')); expect(await screen.findByText('Vertical (Left)')).toBeInTheDocument(); expect(screen.getByText('Horizontal (Top)')).toBeInTheDocument(); expect( within(screen.getAllByRole('menuitem')[1]).getByLabelText('check'), ).toBeInTheDocument(); expect( within(screen.getAllByRole('menuitem')[2]).queryByLabelText('check'), ).not.toBeInTheDocument(); userEvent.click(await screen.findByText('Horizontal (Top)')); await waitFor(() => { expect(dangerToastSpy).toHaveBeenCalledWith( 'Sorry, there was an error saving this dashboard: Unknown Error', ); }); userEvent.click(screen.getByLabelText('gear')); userEvent.hover(screen.getByText('Orientation of filter bar')); expect(await screen.findByText('Vertical (Left)')).toBeInTheDocument(); // checkmark gets rolled back to the original selection after successful query expect( await within(screen.getAllByRole('menuitem')[1]).findByLabelText('check'), ).toBeInTheDocument(); expect( within(screen.getAllByRole('menuitem')[2]).queryByLabelText('check'), ).not.toBeInTheDocument(); fetchMock.reset(); });
7,279
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterConfigurationLink/FilterConfigurationLink.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import FilterConfigurationLink from '.'; test('should render', () => { const { container } = render( <FilterConfigurationLink>Config link</FilterConfigurationLink>, { useRedux: true, }, ); expect(container).toBeInTheDocument(); }); test('should render the config link text', () => { render(<FilterConfigurationLink>Config link</FilterConfigurationLink>, { useRedux: true, }); expect(screen.getByText('Config link')).toBeInTheDocument(); }); test('should render the modal on click', () => { render(<FilterConfigurationLink>Config link</FilterConfigurationLink>, { useRedux: true, }); const configLink = screen.getByText('Config link'); expect(screen.queryByRole('dialog')).not.toBeInTheDocument(); userEvent.click(configLink); expect(screen.getByRole('dialog')).toBeInTheDocument(); });
7,284
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterDivider.test.tsx
/** * 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 userEvent from '@testing-library/user-event'; import React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import { FilterBarOrientation } from 'src/dashboard/types'; import FilterDivider from './FilterDivider'; const SAMPLE_TITLE = 'Sample title'; const SAMPLE_DESCRIPTION = 'Sample description that is even longer, it goes on and on and on and on and on and on and on and on and on and on.'; test('vertical mode, title', () => { render(<FilterDivider title={SAMPLE_TITLE} description="" />); const title = screen.getByRole('heading', { name: SAMPLE_TITLE }); expect(title).toBeVisible(); expect(title).toHaveTextContent(SAMPLE_TITLE); const description = screen.queryByTestId('divider-description'); expect(description).not.toBeInTheDocument(); const descriptionIcon = screen.queryByTestId('divider-description-icon'); expect(descriptionIcon).not.toBeInTheDocument(); }); test('vertical mode, title and description', () => { render( <FilterDivider title={SAMPLE_TITLE} description={SAMPLE_DESCRIPTION} />, ); const title = screen.getByRole('heading', { name: SAMPLE_TITLE }); expect(title).toBeVisible(); expect(title).toHaveTextContent(SAMPLE_TITLE); const description = screen.getByTestId('divider-description'); expect(description).toBeVisible(); expect(description).toHaveTextContent(SAMPLE_DESCRIPTION); const descriptionIcon = screen.queryByTestId('divider-description-icon'); expect(descriptionIcon).not.toBeInTheDocument(); }); test('horizontal mode, title', () => { render( <FilterDivider orientation={FilterBarOrientation.HORIZONTAL} title={SAMPLE_TITLE} description="" overflow />, ); const title = screen.getByRole('heading', { name: SAMPLE_TITLE }); expect(title).toBeVisible(); expect(title).toHaveTextContent(SAMPLE_TITLE); const description = screen.queryByTestId('divider-description'); expect(description).not.toBeInTheDocument(); const descriptionIcon = screen.queryByTestId('divider-description-icon'); expect(descriptionIcon).not.toBeInTheDocument(); }); test('horizontal mode, title and description', async () => { render( <FilterDivider orientation={FilterBarOrientation.HORIZONTAL} title={SAMPLE_TITLE} description={SAMPLE_DESCRIPTION} />, ); const title = screen.getByRole('heading', { name: SAMPLE_TITLE }); expect(title).toBeVisible(); expect(title).toHaveTextContent(SAMPLE_TITLE); const description = screen.queryByTestId('divider-description'); expect(description).not.toBeInTheDocument(); const descriptionIcon = screen.getByTestId('divider-description-icon'); expect(descriptionIcon).toBeVisible(); userEvent.hover(descriptionIcon); const tooltip = await screen.findByRole('tooltip'); expect(tooltip).toBeInTheDocument(); expect(tooltip).toHaveTextContent(SAMPLE_DESCRIPTION); }); test('horizontal overflow mode, title', () => { render( <FilterDivider orientation={FilterBarOrientation.HORIZONTAL} overflow title={SAMPLE_TITLE} description="" />, ); const title = screen.getByRole('heading', { name: SAMPLE_TITLE }); expect(title).toBeVisible(); expect(title).toHaveTextContent(SAMPLE_TITLE); const description = screen.queryByTestId('divider-description'); expect(description).not.toBeInTheDocument(); const descriptionIcon = screen.queryByTestId('divider-description-icon'); expect(descriptionIcon).not.toBeInTheDocument(); }); test('horizontal overflow mode, title and description', () => { render( <FilterDivider orientation={FilterBarOrientation.HORIZONTAL} overflow title={SAMPLE_TITLE} description={SAMPLE_DESCRIPTION} />, ); const title = screen.getByRole('heading', { name: SAMPLE_TITLE }); expect(title).toBeVisible(); expect(title).toHaveTextContent(SAMPLE_TITLE); const description = screen.queryByTestId('divider-description'); expect(description).toBeVisible(); expect(description).toHaveTextContent(SAMPLE_DESCRIPTION); const descriptionIcon = screen.queryByTestId('divider-description-icon'); expect(descriptionIcon).not.toBeInTheDocument(); });
7,290
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets/EditSection.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import { mockStore } from 'spec/fixtures/mockStore'; import { Provider } from 'react-redux'; import EditSection, { EditSectionProps } from './EditSection'; const createProps = () => ({ filterSetId: 1, dataMaskSelected: { DefaultsID: { filterState: { value: 'value', }, }, }, onCancel: jest.fn(), disabled: false, }); const setup = (props: EditSectionProps) => ( <Provider store={mockStore}> <EditSection {...props} /> </Provider> ); test('should render', () => { const mockedProps = createProps(); const { container } = render(setup(mockedProps)); expect(container).toBeInTheDocument(); }); test('should render the title', () => { const mockedProps = createProps(); render(setup(mockedProps)); expect(screen.getByText('Editing filter set:')).toBeInTheDocument(); }); test('should render the set name', () => { const mockedProps = createProps(); render(setup(mockedProps)); expect(screen.getByText('Set name')).toBeInTheDocument(); }); test('should render a textbox', () => { const mockedProps = createProps(); render(setup(mockedProps)); expect(screen.getByRole('textbox')).toBeInTheDocument(); }); test('should change the set name', () => { const mockedProps = createProps(); render(setup(mockedProps)); const textbox = screen.getByRole('textbox'); userEvent.clear(textbox); userEvent.type(textbox, 'New name'); expect(textbox).toHaveValue('New name'); }); test('should render the enter icon', () => { const mockedProps = createProps(); render(setup(mockedProps)); expect(screen.getByRole('img', { name: 'enter' })).toBeInTheDocument(); }); test('should render the Cancel button', () => { const mockedProps = createProps(); render(setup(mockedProps)); expect(screen.getByText('Cancel')).toBeInTheDocument(); }); test('should cancel', () => { const mockedProps = createProps(); render(setup(mockedProps)); const cancelBtn = screen.getByText('Cancel'); expect(mockedProps.onCancel).not.toHaveBeenCalled(); userEvent.click(cancelBtn); expect(mockedProps.onCancel).toHaveBeenCalled(); }); test('should render the Save button', () => { const mockedProps = createProps(); render(setup(mockedProps)); expect(screen.getByText('Save')).toBeInTheDocument(); }); test('should render the Save button as disabled', () => { const mockedProps = createProps(); const saveDisabledProps = { ...mockedProps, disabled: true, }; render(setup(saveDisabledProps)); expect(screen.getByText('Save').parentElement).toBeDisabled(); });
7,292
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets/FilterSetUnit.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import { mockStore } from 'spec/fixtures/mockStore'; import { Provider } from 'react-redux'; import userEvent from '@testing-library/user-event'; import FilterSetUnit, { FilterSetUnitProps } from './FilterSetUnit'; const createProps = () => ({ editMode: true, setFilterSetName: jest.fn(), onDelete: jest.fn(), onEdit: jest.fn(), onRebuild: jest.fn(), }); function openDropdown() { const dropdownIcon = screen.getAllByRole('img', { name: '' })[0]; userEvent.click(dropdownIcon); } const setup = (props: FilterSetUnitProps) => ( <Provider store={mockStore}> <FilterSetUnit {...props} /> </Provider> ); test('should render', () => { const mockedProps = createProps(); const { container } = render(setup(mockedProps)); expect(container).toBeInTheDocument(); }); test('should render the edit button', () => { const mockedProps = createProps(); const editModeOffProps = { ...mockedProps, editMode: false, }; render(setup(editModeOffProps)); expect(screen.getByRole('button', { name: 'Edit' })).toBeInTheDocument(); }); test('should render the menu', () => { const mockedProps = createProps(); render(setup(mockedProps)); openDropdown(); expect(screen.getByRole('menu')).toBeInTheDocument(); expect(screen.getAllByRole('menuitem')).toHaveLength(3); expect(screen.getByText('Edit')).toBeInTheDocument(); expect(screen.getByText('Rebuild')).toBeInTheDocument(); expect(screen.getByText('Delete')).toBeInTheDocument(); }); test('should edit', () => { const mockedProps = createProps(); render(setup(mockedProps)); openDropdown(); const editBtn = screen.getByText('Edit'); expect(mockedProps.onEdit).not.toHaveBeenCalled(); userEvent.click(editBtn); expect(mockedProps.onEdit).toHaveBeenCalled(); }); test('should delete', () => { const mockedProps = createProps(); render(setup(mockedProps)); openDropdown(); const deleteBtn = screen.getByText('Delete'); expect(mockedProps.onDelete).not.toHaveBeenCalled(); userEvent.click(deleteBtn); expect(mockedProps.onDelete).toHaveBeenCalled(); }); test('should rebuild', () => { const mockedProps = createProps(); render(setup(mockedProps)); openDropdown(); const rebuildBtn = screen.getByText('Rebuild'); expect(mockedProps.onRebuild).not.toHaveBeenCalled(); userEvent.click(rebuildBtn); expect(mockedProps.onRebuild).toHaveBeenCalled(); });
7,294
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets/FilterSets.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import { mockStore } from 'spec/fixtures/mockStore'; import { Provider } from 'react-redux'; import FilterSets, { FilterSetsProps } from '.'; import { TabIds } from '../types'; const createProps = () => ({ disabled: false, tab: TabIds.FilterSets, dataMaskSelected: { DefaultsID: { filterState: { value: 'value', }, }, }, onEditFilterSet: jest.fn(), onFilterSelectionChange: jest.fn(), }); const setup = (props: FilterSetsProps) => ( <Provider store={mockStore}> <FilterSets {...props} /> </Provider> ); test('should render', () => { const mockedProps = createProps(); const { container } = render(setup(mockedProps)); expect(container).toBeInTheDocument(); }); test('should render the default title', () => { const mockedProps = createProps(); render(setup(mockedProps)); expect(screen.getByText('New filter set')).toBeInTheDocument(); }); test('should render the right number of filters', () => { const mockedProps = createProps(); render(setup(mockedProps)); expect(screen.getByText('Filters (1)')).toBeInTheDocument(); }); test('should render the filters', () => { const mockedProps = createProps(); render(setup(mockedProps)); expect(screen.getByText('Set name')).toBeInTheDocument(); });
7,295
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets/FiltersHeader.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import { mockStore } from 'spec/fixtures/mockStore'; import { Provider } from 'react-redux'; import FiltersHeader, { FiltersHeaderProps } from './FiltersHeader'; const mockedProps = { dataMask: { DefaultsID: { filterState: { value: 'value', }, }, }, }; const setup = (props: FiltersHeaderProps) => ( <Provider store={mockStore}> <FiltersHeader {...props} /> </Provider> ); test('should render', () => { const { container } = render(setup(mockedProps)); expect(container).toBeInTheDocument(); }); test('should render the right number of filters', () => { render(setup(mockedProps)); expect(screen.getByText('Filters (1)')).toBeInTheDocument(); }); test('should render the name and value', () => { render(setup(mockedProps)); expect(screen.getByText('test:')).toBeInTheDocument(); expect(screen.getByText('value')).toBeInTheDocument(); });
7,297
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets/Footer.test.tsx
/** * 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 React from 'react'; import userEvent from '@testing-library/user-event'; import { render, screen } from 'spec/helpers/testing-library'; import Footer from './Footer'; const createProps = () => ({ filterSetName: 'Set name', disabled: false, editMode: false, onCancel: jest.fn(), onEdit: jest.fn(), onCreate: jest.fn(), }); const editModeProps = { ...createProps(), editMode: true, }; test('should render', () => { const mockedProps = createProps(); const { container } = render(<Footer {...mockedProps} />, { useRedux: true }); expect(container).toBeInTheDocument(); }); test('should render a button', () => { const mockedProps = createProps(); render(<Footer {...mockedProps} />, { useRedux: true }); expect(screen.getByRole('button')).toBeInTheDocument(); expect(screen.getByText('Create new filter set')).toBeInTheDocument(); }); test('should render a disabled button', () => { const mockedProps = createProps(); const disabledProps = { ...mockedProps, disabled: true, }; render(<Footer {...disabledProps} />, { useRedux: true }); expect(screen.getByRole('button')).toBeDisabled(); }); test('should edit', () => { const mockedProps = createProps(); render(<Footer {...mockedProps} />, { useRedux: true }); const btn = screen.getByRole('button'); expect(mockedProps.onEdit).not.toHaveBeenCalled(); userEvent.click(btn); expect(mockedProps.onEdit).toHaveBeenCalled(); }); test('should render the Create button', () => { render(<Footer {...editModeProps} />, { useRedux: true }); expect(screen.getByText('Create')).toBeInTheDocument(); }); test('should create', () => { render(<Footer {...editModeProps} />, { useRedux: true }); const createBtn = screen.getByText('Create'); expect(editModeProps.onCreate).not.toHaveBeenCalled(); userEvent.click(createBtn); expect(editModeProps.onCreate).toHaveBeenCalled(); }); test('should render the Cancel button', () => { render(<Footer {...editModeProps} />, { useRedux: true }); expect(screen.getByText('Cancel')).toBeInTheDocument(); }); test('should cancel', () => { render(<Footer {...editModeProps} />, { useRedux: true }); const cancelBtn = screen.getByText('Cancel'); expect(editModeProps.onCancel).not.toHaveBeenCalled(); userEvent.click(cancelBtn); expect(editModeProps.onCancel).toHaveBeenCalled(); });
7,301
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets/utils/findExistingFilterSet.test.ts
/** * 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 { FilterSet } from '@superset-ui/core'; import { findExistingFilterSet } from '.'; const createDataMaskSelected = () => ({ filterId: { filterState: { value: 'value-1' } }, filterId2: { filterState: { value: 'value-2' } }, }); test('Should find correct filter', () => { const dataMaskSelected = createDataMaskSelected(); const filterSetFilterValues: FilterSet[] = [ { id: 1, name: 'name-01', nativeFilters: {}, dataMask: { filterId: { id: 'filterId', filterState: { value: 'value-1' } }, filterId2: { id: 'filterId2', filterState: { value: 'value-2' } }, } as any, }, ]; const response = findExistingFilterSet({ filterSetFilterValues, dataMaskSelected, }); expect(response).toEqual({ dataMask: { filterId: { id: 'filterId', filterState: { value: 'value-1' } }, filterId2: { id: 'filterId2', filterState: { value: 'value-2' } }, }, id: 1, name: 'name-01', nativeFilters: {}, }); }); test('Should return undefined when nativeFilters has less values', () => { const dataMaskSelected = createDataMaskSelected(); const filterSetFilterValues = [ { id: 1, name: 'name-01', nativeFilters: {}, dataMask: { filterId: { id: 'filterId', filterState: { value: 'value-1' } }, } as any, }, ]; const response = findExistingFilterSet({ filterSetFilterValues, dataMaskSelected, }); expect(response).toBeUndefined(); }); test('Should return undefined when nativeFilters has different values', () => { const dataMaskSelected = createDataMaskSelected(); const filterSetFilterValues: FilterSet[] = [ { id: 1, name: 'name-01', nativeFilters: {}, dataMask: { filterId: { id: 'filterId', filterState: { value: 'value-1' } }, filterId2: { id: 'filterId2', filterState: { value: 'value-1' } }, }, }, ]; const response = findExistingFilterSet({ filterSetFilterValues, dataMaskSelected, }); expect(response).toBeUndefined(); }); test('Should return undefined when dataMask:{}', () => { const dataMaskSelected = createDataMaskSelected(); const filterSetFilterValues = [ { id: 1, name: 'name-01', nativeFilters: {}, dataMask: {}, }, ]; const response = findExistingFilterSet({ filterSetFilterValues, dataMaskSelected, }); expect(response).toBeUndefined(); }); test('Should return undefined when dataMask is empty}', () => { const dataMaskSelected = createDataMaskSelected(); const filterSetFilterValues: FilterSet[] = [ { id: 1, name: 'name-01', nativeFilters: {}, dataMask: {}, }, ]; const response = findExistingFilterSet({ filterSetFilterValues, dataMaskSelected, }); expect(response).toBeUndefined(); }); test('Should return undefined when filterSetFilterValues is []', () => { const dataMaskSelected = createDataMaskSelected(); const filterSetFilterValues: FilterSet[] = []; const response = findExistingFilterSet({ filterSetFilterValues, dataMaskSelected, }); expect(response).toBeUndefined(); });
7,302
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets/utils/generateFiltersSetId.test.ts
/** * 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 { generateFiltersSetId } from '.'; test('Should follow the pattern "FILTERS_SET-"', () => { const id = generateFiltersSetId(); expect(id.startsWith('FILTERS_SET-', 0)).toBe(true); });
7,303
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets/utils/getFilterValueForDisplay.test.ts
/** * 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 { getFilterValueForDisplay } from '.'; test('Should return "" when value is null or undefined', () => { expect(getFilterValueForDisplay(null)).toBe(''); expect(getFilterValueForDisplay(undefined)).toBe(''); expect(getFilterValueForDisplay()).toBe(''); }); test('Should return "string value" when value is string or number', () => { expect(getFilterValueForDisplay(123)).toBe('123'); expect(getFilterValueForDisplay('123')).toBe('123'); }); test('Should return a string with values ​​separated by commas', () => { expect(getFilterValueForDisplay(['a', 'b', 'c'])).toBe('a, b, c'); }); test('Should return a JSON.stringify from objects', () => { expect(getFilterValueForDisplay({ any: 'value' })).toBe('{"any":"value"}'); }); test('Should return an error message when the type is invalid', () => { expect(getFilterValueForDisplay(true as any)).toBe('Unknown value'); });
7,307
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/Header/Header.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import Header from './index'; const createProps = () => ({ toggleFiltersBar: jest.fn(), }); test('should render', () => { const mockedProps = createProps(); const { container } = render(<Header {...mockedProps} />, { useRedux: true }); expect(container).toBeInTheDocument(); }); test('should render the "Filters" heading', () => { const mockedProps = createProps(); render(<Header {...mockedProps} />, { useRedux: true }); expect(screen.getByText('Filters')).toBeInTheDocument(); }); test('should render the expand button', () => { const mockedProps = createProps(); render(<Header {...mockedProps} />, { useRedux: true }); expect(screen.getByRole('button', { name: 'expand' })).toBeInTheDocument(); }); test('should toggle', () => { const mockedProps = createProps(); render(<Header {...mockedProps} />, { useRedux: true }); const expandBtn = screen.getByRole('button', { name: 'expand' }); expect(mockedProps.toggleFiltersBar).not.toHaveBeenCalled(); userEvent.click(expandBtn); expect(mockedProps.toggleFiltersBar).toHaveBeenCalled(); });
7,310
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FilterCard/FilterCard.test.tsx
/** * 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 React from 'react'; import * as reactRedux from 'react-redux'; import { Filter, NativeFilterType } from '@superset-ui/core'; import userEvent from '@testing-library/user-event'; import { render, screen } from 'spec/helpers/testing-library'; import { DASHBOARD_ROOT_ID } from 'src/dashboard/util/constants'; import { SET_DIRECT_PATH } from 'src/dashboard/actions/dashboardState'; import { FilterCardContent } from './FilterCardContent'; const baseInitialState = { dashboardInfo: {}, nativeFilters: { filters: { 'NATIVE_FILTER-1': { id: 'NATIVE_FILTER-1', controlValues: {}, name: 'Native filter 1', filterType: 'filter_select', targets: [ { datasetId: 1, column: { name: 'gender', }, }, ], defaultDataMask: {}, cascadeParentIds: [], scope: { rootPath: [DASHBOARD_ROOT_ID], excluded: [], }, type: NativeFilterType.NATIVE_FILTER, description: '', }, 'NATIVE_FILTER-2': { id: 'NATIVE_FILTER-2', controlValues: {}, name: 'Native filter 2', filterType: 'filter_select', targets: [ { datasetId: 1, column: { name: 'gender', }, }, ], defaultDataMask: {}, cascadeParentIds: [], scope: { rootPath: [DASHBOARD_ROOT_ID], excluded: [], }, type: NativeFilterType.NATIVE_FILTER, description: '', }, }, }, charts: { '1': { id: 1, }, '2': { id: 2, }, '3': { id: 3, }, }, dashboardLayout: { past: [], future: [], present: { ROOT_ID: { children: ['TABS-1'], id: 'ROOT_ID', type: 'ROOT', }, 'TABS-1': { children: ['TAB-1', 'TAB-2'], id: 'TABS-1', meta: {}, parents: ['ROOT_ID'], type: 'TABS', }, 'TAB-1': { children: [], id: 'TAB-1', meta: { defaultText: 'Tab title', placeholder: 'Tab title', text: 'Tab 1', }, parents: ['ROOT_ID', 'TABS-1'], type: 'TAB', }, 'TAB-2': { children: [], id: 'TAB-2', meta: { defaultText: 'Tab title', placeholder: 'Tab title', text: 'Tab 2', }, parents: ['ROOT_ID', 'TABS-1'], type: 'TAB', }, 'CHART-1': { children: [], id: 'CHART-1', meta: { chartId: 1, sliceName: 'Test chart', }, parents: ['ROOT_ID', 'TABS-1', 'TAB-1'], type: 'CHART', }, 'CHART-2': { children: [], id: 'CHART-2', meta: { chartId: 2, sliceName: 'Test chart 2', }, parents: ['ROOT_ID', 'TABS-1', 'TAB-1'], type: 'CHART', }, 'CHART-3': { children: [], id: 'CHART-3', meta: { chartId: 3, sliceName: 'Test chart 3', }, parents: ['ROOT_ID', 'TABS-1', 'TAB-1'], type: 'CHART', }, 'CHART-4': { children: [], id: 'CHART-4', meta: { chartId: 4, sliceName: 'Test chart 4', }, parents: ['ROOT_ID', 'TABS-1', 'TAB-2'], type: 'CHART', }, }, }, }; const baseFilter: Filter = { id: 'NATIVE_FILTER-1', controlValues: {}, name: 'Native filter 1', filterType: 'filter_select', targets: [ { datasetId: 1, column: { name: 'gender', }, }, ], defaultDataMask: {}, cascadeParentIds: [], scope: { rootPath: [DASHBOARD_ROOT_ID], excluded: [], }, type: NativeFilterType.NATIVE_FILTER, description: '', }; jest.mock('@superset-ui/core', () => ({ // @ts-ignore ...jest.requireActual('@superset-ui/core'), getChartMetadataRegistry: () => ({ get: (type: string) => { if (type === 'filter_select') { return { name: 'Select filter' }; } return undefined; }, }), })); // extract text from embedded html tags // source: https://polvara.me/posts/five-things-you-didnt-know-about-testing-library const getTextInHTMLTags = (target: string | RegExp) => (content: string, node: Element) => { const hasText = (node: Element) => node.textContent === target; const nodeHasText = hasText(node); const childrenDontHaveText = Array.from(node.children).every( child => !hasText(child), ); return nodeHasText && childrenDontHaveText; }; const hidePopover = jest.fn(); const renderContent = (filter = baseFilter, initialState = baseInitialState) => render(<FilterCardContent filter={filter} hidePopover={hidePopover} />, { useRedux: true, initialState, }); test('filter card title, type, scope, dependencies', () => { renderContent(); expect(screen.getByText('Native filter 1')).toBeVisible(); expect(screen.getByLabelText('filter-small')).toBeVisible(); expect(screen.getByText('Filter type')).toBeVisible(); expect(screen.getByText('Select filter')).toBeVisible(); expect(screen.getByText('Scope')).toBeVisible(); expect(screen.getByText('All charts')).toBeVisible(); expect(screen.queryByText('Dependencies')).not.toBeInTheDocument(); }); test('filter card scope with excluded', () => { const filter = { ...baseFilter, scope: { rootPath: [DASHBOARD_ROOT_ID], excluded: [1, 4] }, }; renderContent(filter); expect(screen.getByText('Scope')).toBeVisible(); expect( screen.getByText(getTextInHTMLTags('Test chart 2, Test chart 3')), ).toBeVisible(); }); test('filter card scope with top level tab as root', () => { const filter = { ...baseFilter, scope: { rootPath: ['TAB-1', 'TAB-2'], excluded: [1, 2] }, }; renderContent(filter); expect(screen.getByText('Scope')).toBeVisible(); expect( screen.getByText(getTextInHTMLTags('Tab 2, Test chart 3')), ).toBeVisible(); }); test('filter card empty scope', () => { const filter = { ...baseFilter, scope: { rootPath: [], excluded: [1, 2, 3, 4] }, }; renderContent(filter); expect(screen.getByText('Scope')).toBeVisible(); expect(screen.getByText('None')).toBeVisible(); }); test('filter card with dependency', () => { const filter = { ...baseFilter, cascadeParentIds: ['NATIVE_FILTER-2'], }; renderContent(filter); expect(screen.getByText('Dependent on')).toBeVisible(); expect(screen.getByText('Native filter 2')).toBeVisible(); }); test('focus filter on filter card dependency click', () => { const useDispatchMock = jest.spyOn(reactRedux, 'useDispatch'); const dummyDispatch = jest.fn(); useDispatchMock.mockReturnValue(dummyDispatch); const filter = { ...baseFilter, cascadeParentIds: ['NATIVE_FILTER-2'], }; renderContent(filter); userEvent.click(screen.getByText('Native filter 2')); expect(dummyDispatch).toHaveBeenCalledWith({ type: SET_DIRECT_PATH, path: ['NATIVE_FILTER-2'], }); }); test('edit filter button for dashboard viewer', () => { renderContent(); expect( screen.queryByRole('button', { name: /edit/i }), ).not.toBeInTheDocument(); }); test('edit filter button for dashboard editor', () => { renderContent(baseFilter, { ...baseInitialState, dashboardInfo: { dash_edit_perm: true }, }); expect(screen.getByRole('button', { name: /edit/i })).toBeVisible(); }); test('open modal on edit filter button click', async () => { renderContent(baseFilter, { ...baseInitialState, dashboardInfo: { dash_edit_perm: true }, }); const editButton = screen.getByRole('button', { name: /edit/i }); userEvent.click(editButton); expect( await screen.findByRole('dialog', { name: /add and edit filters/i }), ).toBeVisible(); });
7,323
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FilterConfigPane.test.tsx
/** * 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 React from 'react'; import { dashboardLayout } from 'spec/fixtures/mockDashboardLayout'; import { buildNativeFilter } from 'spec/fixtures/mockNativeFilters'; import { act, fireEvent, render, screen } from 'spec/helpers/testing-library'; import FilterConfigPane from './FilterConfigurePane'; const scrollMock = jest.fn(); Element.prototype.scroll = scrollMock; const defaultProps = { getFilterTitle: (id: string) => id, onChange: jest.fn(), onAdd: jest.fn(), onRemove: jest.fn(), onRearrange: jest.fn(), restoreFilter: jest.fn(), currentFilterId: 'NATIVE_FILTER-1', filters: ['NATIVE_FILTER-1', 'NATIVE_FILTER-2', 'NATIVE_FILTER-3'], removedFilters: {}, erroredFilters: [], }; const defaultState = { dashboardInfo: { metadata: { native_filter_configuration: [ buildNativeFilter('NATIVE_FILTER-1', 'state', ['NATIVE_FILTER-2']), buildNativeFilter('NATIVE_FILTER-2', 'country', []), buildNativeFilter('NATIVE_FILTER-3', 'product', []), ], }, }, dashboardLayout, }; function defaultRender(initialState: any = defaultState, props = defaultProps) { return render(<FilterConfigPane {...props} />, { initialState, useDnd: true, useRedux: true, }); } beforeEach(() => { scrollMock.mockClear(); }); test('drag and drop', async () => { defaultRender(); // Drag the state and country filter above the product filter const [countryStateFilter, productFilter] = document.querySelectorAll( 'div[draggable=true]', ); // const productFilter = await screen.findByText('NATIVE_FILTER-3'); await act(async () => { fireEvent.dragStart(productFilter); fireEvent.dragEnter(countryStateFilter); fireEvent.dragOver(countryStateFilter); fireEvent.drop(countryStateFilter); fireEvent.dragLeave(countryStateFilter); fireEvent.dragEnd(productFilter); }); expect(defaultProps.onRearrange).toHaveBeenCalledTimes(1); }); test('remove filter', async () => { defaultRender(); // First trash icon const removeFilterIcon = document.querySelector("[alt='RemoveFilter']")!; await act(async () => { fireEvent( removeFilterIcon, new MouseEvent('click', { bubbles: true, cancelable: true, }), ); }); expect(defaultProps.onRemove).toHaveBeenCalledWith('NATIVE_FILTER-1'); }); test('add filter', async () => { defaultRender(); // First trash icon const addButton = screen.getByText('Add filters and dividers')!; fireEvent.mouseOver(addButton); const addFilterButton = await screen.findByText('Filter'); await act(async () => { fireEvent( addFilterButton, new MouseEvent('click', { bubbles: true, cancelable: true, }), ); }); expect(defaultProps.onAdd).toHaveBeenCalledWith('NATIVE_FILTER'); }); test('add divider', async () => { defaultRender(); const addButton = screen.getByText('Add filters and dividers')!; fireEvent.mouseOver(addButton); const addFilterButton = await screen.findByText('Divider'); await act(async () => { fireEvent( addFilterButton, new MouseEvent('click', { bubbles: true, cancelable: true, }), ); }); expect(defaultProps.onAdd).toHaveBeenCalledWith('DIVIDER'); }); test('filter container should scroll to bottom when adding items', async () => { const state = { dashboardInfo: { metadata: { native_filter_configuration: new Array(35) .fill(0) .map((_, index) => buildNativeFilter(`NATIVE_FILTER-${index}`, `filter-${index}`, []), ), }, }, dashboardLayout, }; const props = { ...defaultProps, filters: new Array(35).fill(0).map((_, index) => `NATIVE_FILTER-${index}`), }; defaultRender(state, props); const addButton = screen.getByText('Add filters and dividers')!; fireEvent.mouseOver(addButton); const addFilterButton = await screen.findByText('Filter'); await act(async () => { fireEvent( addFilterButton, new MouseEvent('click', { bubbles: true, cancelable: true, }), ); }); const containerElement = screen.getByTestId('filter-title-container'); expect(containerElement.scroll).toHaveBeenCalled(); });
7,327
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigModal.test.tsx
/** * 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 { Preset } from '@superset-ui/core'; import userEvent, { specialChars } from '@testing-library/user-event'; import fetchMock from 'fetch-mock'; import React from 'react'; import chartQueries from 'spec/fixtures/mockChartQueries'; import { dashboardLayout } from 'spec/fixtures/mockDashboardLayout'; import mockDatasource, { datasourceId, id } from 'spec/fixtures/mockDatasource'; import { buildNativeFilter } from 'spec/fixtures/mockNativeFilters'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; import { RangeFilterPlugin, SelectFilterPlugin, TimeColumnFilterPlugin, TimeFilterPlugin, TimeGrainFilterPlugin, } from 'src/filters/components'; import FiltersConfigModal, { FiltersConfigModalProps, } from './FiltersConfigModal'; class MainPreset extends Preset { constructor() { super({ name: 'Legacy charts', plugins: [ new SelectFilterPlugin().configure({ key: 'filter_select' }), new RangeFilterPlugin().configure({ key: 'filter_range' }), new TimeFilterPlugin().configure({ key: 'filter_time' }), new TimeColumnFilterPlugin().configure({ key: 'filter_timecolumn' }), new TimeGrainFilterPlugin().configure({ key: 'filter_timegrain' }), ], }); } } const defaultState = () => ({ datasources: { ...mockDatasource }, charts: chartQueries, }); const noTemporalColumnsState = () => { const state = defaultState(); return { charts: { ...state.charts, }, datasources: { ...state.datasources, [datasourceId]: { ...state.datasources[datasourceId], column_types: [0, 1], }, }, }; }; const datasetResult = (id: number) => ({ description_columns: {}, id, label_columns: { columns: 'Columns', table_name: 'Table Name', }, result: { metrics: [], columns: [ { column_name: 'Column A', id: 1, }, ], table_name: 'birth_names', id, }, show_columns: ['id', 'table_name'], }); fetchMock.get('glob:*/api/v1/dataset/1', datasetResult(1)); fetchMock.get(`glob:*/api/v1/dataset/${id}`, datasetResult(id)); fetchMock.post('glob:*/api/v1/chart/data', { result: [ { status: 'success', data: [ { name: 'Aaron', count: 453 }, { name: 'Abigail', count: 228 }, { name: 'Adam', count: 454 }, ], applied_filters: [{ column: 'name' }], }, ], }); const FILTER_TYPE_REGEX = /^filter type$/i; const FILTER_NAME_REGEX = /^filter name$/i; const DATASET_REGEX = /^dataset$/i; const COLUMN_REGEX = /^column$/i; const VALUE_REGEX = /^value$/i; const NUMERICAL_RANGE_REGEX = /^numerical range$/i; const TIME_RANGE_REGEX = /^time range$/i; const TIME_COLUMN_REGEX = /^time column$/i; const TIME_GRAIN_REGEX = /^time grain$/i; const FILTER_SETTINGS_REGEX = /^filter settings$/i; const DEFAULT_VALUE_REGEX = /^filter has default value$/i; const MULTIPLE_REGEX = /^can select multiple values$/i; const REQUIRED_REGEX = /^filter value is required$/i; const DEPENDENCIES_REGEX = /^values are dependent on other filters$/i; const FIRST_VALUE_REGEX = /^select first filter value by default$/i; const INVERSE_SELECTION_REGEX = /^inverse selection$/i; const SEARCH_ALL_REGEX = /^dynamically search all filter values$/i; const PRE_FILTER_REGEX = /^pre-filter available values$/i; const SORT_REGEX = /^sort filter values$/i; const SAVE_REGEX = /^save$/i; const NAME_REQUIRED_REGEX = /^name is required$/i; const COLUMN_REQUIRED_REGEX = /^column is required$/i; const DEFAULT_VALUE_REQUIRED_REGEX = /^default value is required$/i; const PRE_FILTER_REQUIRED_REGEX = /^pre-filter is required$/i; const FILL_REQUIRED_FIELDS_REGEX = /fill all required fields to enable/; const TIME_RANGE_PREFILTER_REGEX = /^time range$/i; const props: FiltersConfigModalProps = { isOpen: true, createNewOnOpen: true, onSave: jest.fn(), onCancel: jest.fn(), }; beforeAll(() => { new MainPreset().register(); }); function defaultRender(initialState: any = defaultState(), modalProps = props) { return render(<FiltersConfigModal {...modalProps} />, { initialState, useDnd: true, useRedux: true, }); } function getCheckbox(name: RegExp) { return screen.getByRole('checkbox', { name }); } function queryCheckbox(name: RegExp) { return screen.queryByRole('checkbox', { name }); } test('renders a value filter type', () => { defaultRender(); userEvent.click(screen.getByText(FILTER_SETTINGS_REGEX)); expect(screen.getByText(FILTER_TYPE_REGEX)).toBeInTheDocument(); expect(screen.getByText(FILTER_NAME_REGEX)).toBeInTheDocument(); expect(screen.getByText(DATASET_REGEX)).toBeInTheDocument(); expect(screen.getByText(COLUMN_REGEX)).toBeInTheDocument(); expect(getCheckbox(DEFAULT_VALUE_REGEX)).not.toBeChecked(); expect(getCheckbox(REQUIRED_REGEX)).not.toBeChecked(); expect(queryCheckbox(DEPENDENCIES_REGEX)).not.toBeInTheDocument(); expect(getCheckbox(FIRST_VALUE_REGEX)).not.toBeChecked(); expect(getCheckbox(INVERSE_SELECTION_REGEX)).not.toBeChecked(); expect(getCheckbox(SEARCH_ALL_REGEX)).not.toBeChecked(); expect(getCheckbox(PRE_FILTER_REGEX)).not.toBeChecked(); expect(getCheckbox(SORT_REGEX)).not.toBeChecked(); expect(getCheckbox(MULTIPLE_REGEX)).toBeChecked(); }); test('renders a numerical range filter type', async () => { defaultRender(); userEvent.click(screen.getByText(VALUE_REGEX)); await waitFor(() => userEvent.click(screen.getByText(NUMERICAL_RANGE_REGEX))); userEvent.click(screen.getByText(FILTER_SETTINGS_REGEX)); expect(screen.getByText(FILTER_TYPE_REGEX)).toBeInTheDocument(); expect(screen.getByText(FILTER_NAME_REGEX)).toBeInTheDocument(); expect(screen.getByText(DATASET_REGEX)).toBeInTheDocument(); expect(screen.getByText(COLUMN_REGEX)).toBeInTheDocument(); expect(screen.getByText(REQUIRED_REGEX)).toBeInTheDocument(); expect(getCheckbox(DEFAULT_VALUE_REGEX)).not.toBeChecked(); expect(getCheckbox(PRE_FILTER_REGEX)).not.toBeChecked(); expect(queryCheckbox(MULTIPLE_REGEX)).not.toBeInTheDocument(); expect(queryCheckbox(DEPENDENCIES_REGEX)).not.toBeInTheDocument(); expect(queryCheckbox(FIRST_VALUE_REGEX)).not.toBeInTheDocument(); expect(queryCheckbox(INVERSE_SELECTION_REGEX)).not.toBeInTheDocument(); expect(queryCheckbox(SEARCH_ALL_REGEX)).not.toBeInTheDocument(); expect(queryCheckbox(SORT_REGEX)).not.toBeInTheDocument(); }); test('renders a time range filter type', async () => { defaultRender(); userEvent.click(screen.getByText(VALUE_REGEX)); await waitFor(() => userEvent.click(screen.getByText(TIME_RANGE_REGEX))); expect(screen.getByText(FILTER_TYPE_REGEX)).toBeInTheDocument(); expect(screen.getByText(FILTER_NAME_REGEX)).toBeInTheDocument(); expect(screen.queryByText(DATASET_REGEX)).not.toBeInTheDocument(); expect(screen.queryByText(COLUMN_REGEX)).not.toBeInTheDocument(); expect(getCheckbox(DEFAULT_VALUE_REGEX)).not.toBeChecked(); }); test('renders a time column filter type', async () => { defaultRender(); userEvent.click(screen.getByText(VALUE_REGEX)); await waitFor(() => userEvent.click(screen.getByText(TIME_COLUMN_REGEX))); expect(screen.getByText(FILTER_TYPE_REGEX)).toBeInTheDocument(); expect(screen.getByText(FILTER_NAME_REGEX)).toBeInTheDocument(); expect(screen.getByText(DATASET_REGEX)).toBeInTheDocument(); expect(screen.queryByText(COLUMN_REGEX)).not.toBeInTheDocument(); expect(getCheckbox(DEFAULT_VALUE_REGEX)).not.toBeChecked(); }); test('renders a time grain filter type', async () => { defaultRender(); userEvent.click(screen.getByText(VALUE_REGEX)); await waitFor(() => userEvent.click(screen.getByText(TIME_GRAIN_REGEX))); expect(screen.getByText(FILTER_TYPE_REGEX)).toBeInTheDocument(); expect(screen.getByText(FILTER_NAME_REGEX)).toBeInTheDocument(); expect(screen.getByText(DATASET_REGEX)).toBeInTheDocument(); expect(screen.queryByText(COLUMN_REGEX)).not.toBeInTheDocument(); expect(getCheckbox(DEFAULT_VALUE_REGEX)).not.toBeChecked(); }); test('render time filter types as disabled if there are no temporal columns in the dataset', async () => { defaultRender(noTemporalColumnsState()); userEvent.click(screen.getByText(VALUE_REGEX)); const timeRange = await screen.findByText(TIME_RANGE_REGEX); const timeGrain = await screen.findByText(TIME_GRAIN_REGEX); const timeColumn = await screen.findByText(TIME_COLUMN_REGEX); const disabledClass = '.ant-select-item-option-disabled'; expect(timeRange.closest(disabledClass)).toBeInTheDocument(); expect(timeGrain.closest(disabledClass)).toBeInTheDocument(); expect(timeColumn.closest(disabledClass)).toBeInTheDocument(); }); test('validates the name', async () => { defaultRender(); userEvent.click(screen.getByRole('button', { name: SAVE_REGEX })); expect(await screen.findByText(NAME_REQUIRED_REGEX)).toBeInTheDocument(); }); test('validates the column', async () => { defaultRender(); userEvent.click(screen.getByRole('button', { name: SAVE_REGEX })); expect(await screen.findByText(COLUMN_REQUIRED_REGEX)).toBeInTheDocument(); }); // eslint-disable-next-line jest/no-disabled-tests test.skip('validates the default value', async () => { defaultRender(noTemporalColumnsState()); expect(await screen.findByText('birth_names')).toBeInTheDocument(); userEvent.type(screen.getByRole('combobox'), `Column A${specialChars.enter}`); userEvent.click(getCheckbox(DEFAULT_VALUE_REGEX)); await waitFor(() => { expect( screen.queryByText(FILL_REQUIRED_FIELDS_REGEX), ).not.toBeInTheDocument(); }); expect( await screen.findByText(DEFAULT_VALUE_REQUIRED_REGEX), ).toBeInTheDocument(); }); test('validates the pre-filter value', async () => { defaultRender(); userEvent.click(screen.getByText(FILTER_SETTINGS_REGEX)); userEvent.click(getCheckbox(PRE_FILTER_REGEX)); expect( await screen.findByText(PRE_FILTER_REQUIRED_REGEX), ).toBeInTheDocument(); }); // eslint-disable-next-line jest/no-disabled-tests test.skip("doesn't render time range pre-filter if there are no temporal columns in datasource", async () => { defaultRender(noTemporalColumnsState()); userEvent.click(screen.getByText(DATASET_REGEX)); await waitFor(() => { expect(screen.queryByLabelText('Loading')).not.toBeInTheDocument(); userEvent.click(screen.getByText('birth_names')); }); userEvent.click(screen.getByText(FILTER_SETTINGS_REGEX)); userEvent.click(getCheckbox(PRE_FILTER_REGEX)); await waitFor(() => expect( screen.queryByText(TIME_RANGE_PREFILTER_REGEX), ).not.toBeInTheDocument(), ); }); test('filters are draggable', async () => { const nativeFilterState = [ buildNativeFilter('NATIVE_FILTER-1', 'state', ['NATIVE_FILTER-2']), buildNativeFilter('NATIVE_FILTER-2', 'country', []), buildNativeFilter('NATIVE_FILTER-3', 'product', []), ]; const state = { ...defaultState(), dashboardInfo: { metadata: { native_filter_configuration: nativeFilterState }, }, dashboardLayout, }; defaultRender(state, { ...props, createNewOnOpen: false }); const draggables = document.querySelectorAll('div[draggable=true]'); expect(draggables.length).toBe(3); }); /* TODO adds a new value filter type with all fields filled adds a new numerical range filter type with all fields filled adds a new time range filter type with all fields filled adds a new time column filter type with all fields filled adds a new time grain filter type with all fields filled collapsible controls opens by default when it is checked advanced section opens by default when it has an option checked disables the default value when default to first item is checked changes the default value options when the column changes switches to configuration tab when validation fails displays cancel message when there are pending operations do not displays cancel message when there are no pending operations */ test('deletes a filter', async () => { const nativeFilterState = [ buildNativeFilter('NATIVE_FILTER-1', 'state', ['NATIVE_FILTER-2']), buildNativeFilter('NATIVE_FILTER-2', 'country', []), buildNativeFilter('NATIVE_FILTER-3', 'product', []), ]; const state = { ...defaultState(), dashboardInfo: { metadata: { native_filter_configuration: nativeFilterState }, }, dashboardLayout, }; const onSave = jest.fn(); defaultRender(state, { ...props, createNewOnOpen: false, onSave, }); const removeButtons = screen.getAllByRole('img', { name: 'trash' }); // remove NATIVE_FILTER-3 which isn't a dependancy of any other filter userEvent.click(removeButtons[2]); userEvent.click(screen.getByRole('button', { name: SAVE_REGEX })); await waitFor(() => expect(onSave).toHaveBeenCalledWith( expect.arrayContaining([ expect.objectContaining({ type: 'NATIVE_FILTER', id: 'NATIVE_FILTER-1', cascadeParentIds: ['NATIVE_FILTER-2'], }), expect.objectContaining({ type: 'NATIVE_FILTER', id: 'NATIVE_FILTER-2', cascadeParentIds: [], }), ]), ), ); }); test('deletes a filter including dependencies', async () => { const nativeFilterState = [ buildNativeFilter('NATIVE_FILTER-1', 'state', ['NATIVE_FILTER-2']), buildNativeFilter('NATIVE_FILTER-2', 'country', []), buildNativeFilter('NATIVE_FILTER-3', 'product', []), ]; const state = { ...defaultState(), dashboardInfo: { metadata: { native_filter_configuration: nativeFilterState }, }, dashboardLayout, }; const onSave = jest.fn(); defaultRender(state, { ...props, createNewOnOpen: false, onSave, }); const removeButtons = screen.getAllByRole('img', { name: 'trash' }); // remove NATIVE_FILTER-2 which is a dependancy of NATIVE_FILTER-1 userEvent.click(removeButtons[1]); userEvent.click(screen.getByRole('button', { name: SAVE_REGEX })); await waitFor(() => expect(onSave).toHaveBeenCalledWith( expect.arrayContaining([ expect.objectContaining({ type: 'NATIVE_FILTER', id: 'NATIVE_FILTER-1', cascadeParentIds: [], }), expect.objectContaining({ type: 'NATIVE_FILTER', id: 'NATIVE_FILTER-3', cascadeParentIds: [], }), ]), ), ); });
7,329
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/NativeFiltersModal.test.tsx
/** * 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 { ReactWrapper } from 'enzyme'; import React from 'react'; import { DndProvider } from 'react-dnd'; import { HTML5Backend } from 'react-dnd-html5-backend'; import { act } from 'react-dom/test-utils'; import { Provider } from 'react-redux'; import { mockStore } from 'spec/fixtures/mockStore'; import { styledMount as mount } from 'spec/helpers/theming'; import waitForComponentToPaint from 'spec/helpers/waitForComponentToPaint'; import { AntdDropdown } from 'src/components'; import { Menu } from 'src/components/Menu'; import Alert from 'src/components/Alert'; import FiltersConfigModal from 'src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigModal'; Object.defineProperty(window, '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(), })), }); jest.mock('@superset-ui/core', () => ({ // @ts-ignore ...jest.requireActual('@superset-ui/core'), getChartMetadataRegistry: () => ({ items: { filter_select: { value: { datasourceCount: 1, behaviors: ['NATIVE_FILTER'], }, }, }, }), })); describe('FiltersConfigModal', () => { const mockedProps = { isOpen: true, initialFilterId: 'NATIVE_FILTER-1', createNewOnOpen: true, onCancel: jest.fn(), onSave: jest.fn(), }; function setup(overridesProps?: any) { return mount( <Provider store={mockStore}> <DndProvider backend={HTML5Backend}> <FiltersConfigModal {...mockedProps} {...overridesProps} /> </DndProvider> </Provider>, ); } it('should be a valid react element', () => { expect(React.isValidElement(<FiltersConfigModal {...mockedProps} />)).toBe( true, ); }); it('the form validates required fields', async () => { const onSave = jest.fn(); const wrapper = setup({ save: onSave }); act(() => { wrapper .find('input') .first() .simulate('change', { target: { value: 'test name' } }); wrapper.find('.ant-modal-footer button').at(1).simulate('click'); }); await waitForComponentToPaint(wrapper); expect(onSave.mock.calls).toHaveLength(0); }); describe('when click cancel', () => { let onCancel: jest.Mock; let wrapper: ReactWrapper; beforeEach(() => { onCancel = jest.fn(); wrapper = setup({ onCancel, createNewOnOpen: false }); }); async function clickCancel() { act(() => { wrapper.find('.ant-modal-footer button').at(0).simulate('click'); }); await waitForComponentToPaint(wrapper); } async function addFilter() { act(() => { wrapper.find(AntdDropdown).at(0).simulate('mouseEnter'); }); await waitForComponentToPaint(wrapper, 300); act(() => { wrapper.find(Menu.Item).at(0).simulate('click'); }); } it('does not show alert when there is no unsaved filters', async () => { await clickCancel(); expect(onCancel.mock.calls).toHaveLength(1); }); it('shows correct alert message for unsaved filters', async () => { await addFilter(); await clickCancel(); expect(onCancel.mock.calls).toHaveLength(0); expect(wrapper.find(Alert).text()).toContain( 'There are unsaved changes.', ); }); }); });
7,334
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.test.tsx
/** * 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 React from 'react'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; import fetchMock from 'fetch-mock'; import * as utils from 'src/utils/getClientErrorObject'; import { Column, JsonObject } from '@superset-ui/core'; import userEvent from '@testing-library/user-event'; import { ColumnSelect } from './ColumnSelect'; fetchMock.get('glob:*/api/v1/dataset/123?*', { body: { result: { columns: [ { column_name: 'column_name_01', is_dttm: true }, { column_name: 'column_name_02', is_dttm: false }, { column_name: 'column_name_03', is_dttm: false }, ], }, }, }); fetchMock.get('glob:*/api/v1/dataset/456?*', { body: { result: { columns: [ { column_name: 'column_name_04', is_dttm: false }, { column_name: 'column_name_05', is_dttm: false }, { column_name: 'column_name_06', is_dttm: false }, ], }, }, }); fetchMock.get('glob:*/api/v1/dataset/789?*', { status: 404 }); const createProps = (extraProps: JsonObject = {}) => ({ filterId: 'filterId', form: { getFieldValue: jest.fn(), setFields: jest.fn() }, datasetId: 123, value: 'column_name_01', onChange: jest.fn(), ...extraProps, }); afterAll(() => { fetchMock.restore(); }); test('Should render', async () => { const props = createProps(); const { container } = render(<ColumnSelect {...(props as any)} />, { useRedux: true, }); expect(container.children).toHaveLength(1); userEvent.type(screen.getByRole('combobox'), 'column_name'); await waitFor(() => { expect(screen.getByTitle('column_name_01')).toBeInTheDocument(); }); await waitFor(() => { expect(screen.getByTitle('column_name_02')).toBeInTheDocument(); }); await waitFor(() => { expect(screen.getByTitle('column_name_03')).toBeInTheDocument(); }); }); test('Should call "setFields" when "datasetId" changes', () => { const props = createProps(); const { rerender } = render(<ColumnSelect {...(props as any)} />, { useRedux: true, }); expect(props.form.setFields).not.toBeCalled(); props.datasetId = 456; rerender(<ColumnSelect {...(props as any)} />); expect(props.form.setFields).toBeCalled(); }); test('Should call "getClientErrorObject" when api returns an error', async () => { const props = createProps(); props.datasetId = 789; const spy = jest.spyOn(utils, 'getClientErrorObject'); expect(spy).not.toBeCalled(); render(<ColumnSelect {...(props as any)} />, { useRedux: true, }); await waitFor(() => { expect(spy).toBeCalled(); }); }); test('Should filter results', async () => { const props = createProps({ filterValues: (column: Column) => column.is_dttm, }); const { container } = render(<ColumnSelect {...(props as any)} />, { useRedux: true, }); expect(container.children).toHaveLength(1); userEvent.type(screen.getByRole('combobox'), 'column_name'); await waitFor(() => { expect(screen.getByTitle('column_name_01')).toBeInTheDocument(); }); await waitFor(() => { expect(screen.queryByTitle('column_name_02')).not.toBeInTheDocument(); }); await waitFor(() => { expect(screen.queryByTitle('column_name_03')).not.toBeInTheDocument(); }); });
7,342
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.test.tsx
/** * 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 userEvent from '@testing-library/user-event'; import React from 'react'; import { Filter, NativeFilterType } from '@superset-ui/core'; import { render, screen } from 'spec/helpers/testing-library'; import { FormInstance } from 'src/components'; import getControlItemsMap, { ControlItemsProps } from './getControlItemsMap'; import { getControlItems, setNativeFilterFieldValues } from './utils'; jest.mock('./utils', () => ({ getControlItems: jest.fn(), setNativeFilterFieldValues: jest.fn(), })); const formMock: FormInstance = { __INTERNAL__: { itemRef: () => () => {} }, scrollToField: () => {}, getFieldInstance: () => {}, getFieldValue: () => {}, getFieldsValue: () => {}, getFieldError: () => [], getFieldsError: () => [], isFieldsTouched: () => false, isFieldTouched: () => false, isFieldValidating: () => false, isFieldsValidating: () => false, resetFields: () => {}, setFields: () => {}, setFieldsValue: () => {}, validateFields: () => Promise.resolve(), submit: () => {}, }; const filterMock: Filter = { cascadeParentIds: [], defaultDataMask: {}, id: 'mock', name: 'mock', scope: { rootPath: [], excluded: [], }, filterType: '', targets: [{}], controlValues: {}, type: NativeFilterType.NATIVE_FILTER, description: '', }; const createProps: () => ControlItemsProps = () => ({ datasetId: 1, disabled: false, forceUpdate: jest.fn(), form: formMock, filterId: 'filterId', filterToEdit: filterMock, filterType: 'filterType', }); const createControlItems = () => [ null, false, {}, { name: 'name_1', config: { renderTrigger: true, resetConfig: true } }, { name: 'groupby', config: { multiple: true, required: false } }, ]; beforeEach(() => { jest.clearAllMocks(); }); function renderControlItems( controlItemsMap: ReturnType<typeof getControlItemsMap>, ) { return render( // @ts-ignore <> {Object.values(controlItemsMap.controlItems).map(value => value.element)} </>, ); } test('Should render null when has no "formFilter"', () => { const props = createProps(); const controlItemsMap = getControlItemsMap(props); const { container } = renderControlItems(controlItemsMap); expect(container.children).toHaveLength(0); }); test('Should render null when has no "formFilter.filterType" is falsy value', () => { const props = createProps(); const controlItemsMap = getControlItemsMap({ ...props, filterType: 'filterType', }); const { container } = renderControlItems(controlItemsMap); expect(container.children).toHaveLength(0); }); test('Should render null empty when "getControlItems" return []', () => { const props = createProps(); (getControlItems as jest.Mock).mockReturnValue([]); const controlItemsMap = getControlItemsMap(props); const { container } = renderControlItems(controlItemsMap); expect(container.children).toHaveLength(0); }); test('Should render null empty when "getControlItems" return enableSingleValue', () => { const props = createProps(); (getControlItems as jest.Mock).mockReturnValue([ { name: 'enableSingleValue', config: { renderTrigger: true } }, ]); const controlItemsMap = getControlItemsMap(props); const { container } = renderControlItems(controlItemsMap); expect(container.children).toHaveLength(0); }); test('Should render null empty when "controlItems" are falsy', () => { const props = createProps(); const controlItems = [null, false, {}, { config: { renderTrigger: false } }]; (getControlItems as jest.Mock).mockReturnValue(controlItems); const controlItemsMap = getControlItemsMap(props); const { container } = renderControlItems(controlItemsMap); expect(container.children).toHaveLength(0); }); test('Should render ControlItems', () => { const props = createProps(); const controlItems = [ ...createControlItems(), { name: 'name_2', config: { renderTrigger: true } }, ]; (getControlItems as jest.Mock).mockReturnValue(controlItems); const controlItemsMap = getControlItemsMap(props); renderControlItems(controlItemsMap); expect(screen.getAllByRole('checkbox')).toHaveLength(2); }); test('Clicking on checkbox', () => { const props = createProps(); (getControlItems as jest.Mock).mockReturnValue(createControlItems()); const controlItemsMap = getControlItemsMap(props); renderControlItems(controlItemsMap); expect(props.forceUpdate).not.toBeCalled(); expect(setNativeFilterFieldValues).not.toBeCalled(); userEvent.click(screen.getByRole('checkbox')); expect(setNativeFilterFieldValues).toBeCalled(); expect(props.forceUpdate).toBeCalled(); }); test('Clicking on checkbox when resetConfig:flase', () => { const props = createProps(); (getControlItems as jest.Mock).mockReturnValue([ { name: 'name_1', config: { renderTrigger: true, resetConfig: false } }, ]); const controlItemsMap = getControlItemsMap(props); renderControlItems(controlItemsMap); expect(props.forceUpdate).not.toBeCalled(); expect(setNativeFilterFieldValues).not.toBeCalled(); userEvent.click(screen.getByRole('checkbox')); expect(props.forceUpdate).toBeCalled(); expect(setNativeFilterFieldValues).not.toBeCalled(); });
7,346
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/FilterScope.test.tsx
/** * 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 React from 'react'; import { Provider } from 'react-redux'; import { render, screen, fireEvent, waitFor, } from 'spec/helpers/testing-library'; import { mockStoreWithChartsInTabsAndRoot } from 'spec/fixtures/mockStore'; import { AntdForm, FormInstance } from 'src/components'; import { NativeFiltersForm } from 'src/dashboard/components/nativeFilters/FiltersConfigModal/types'; import FiltersConfigForm, { FilterPanels, } from 'src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm'; describe('FilterScope', () => { const save = jest.fn(); let form: FormInstance<NativeFiltersForm>; const mockedProps = { filterId: 'DefaultFilterId', dependencies: [], setErroredFilters: jest.fn(), restoreFilter: jest.fn(), getAvailableFilters: () => [], getDependencySuggestion: () => '', save, removedFilters: {}, handleActiveFilterPanelChange: jest.fn(), activeFilterPanelKeys: `DefaultFilterId-${FilterPanels.configuration.key}`, isActive: true, validateDependencies: jest.fn(), }; const MockModal = ({ scope }: { scope?: object }) => { const [newForm] = AntdForm.useForm<NativeFiltersForm>(); form = newForm; if (scope) { form.setFieldsValue({ filters: { [mockedProps.filterId]: { scope, }, }, }); } return ( <Provider store={mockStoreWithChartsInTabsAndRoot}> <AntdForm form={form}> <FiltersConfigForm form={form} {...mockedProps} /> </AntdForm> </Provider> ); }; const getTreeSwitcher = (order = 0) => document.querySelectorAll('.ant-tree-switcher')[order]; it('renders "apply to all" filter scope', () => { render(<MockModal />); expect(screen.queryByRole('tree')).not.toBeInTheDocument(); }); it('select tree values with 1 excluded', async () => { render(<MockModal />); fireEvent.click(screen.getByText('Scoping')); fireEvent.click(screen.getByLabelText('Apply to specific panels')); expect(screen.getByRole('tree')).not.toBe(null); fireEvent.click(getTreeSwitcher(2)); fireEvent.click(screen.getByText('CHART_ID2')); await waitFor(() => expect( form.getFieldValue('filters')?.[mockedProps.filterId].scope, ).toEqual({ excluded: [20], rootPath: ['ROOT_ID'], }), ); }); it('select 1 value only', async () => { render(<MockModal />); fireEvent.click(screen.getByText('Scoping')); fireEvent.click(screen.getByLabelText('Apply to specific panels')); expect(screen.getByRole('tree')).not.toBe(null); fireEvent.click(getTreeSwitcher(2)); fireEvent.click(screen.getByText('CHART_ID2')); fireEvent.click(screen.getByText('tab1')); await waitFor(() => expect( form.getFieldValue('filters')?.[mockedProps.filterId].scope, ).toEqual({ excluded: [18, 20], rootPath: ['ROOT_ID'], }), ); }); it('correct init tree with values', async () => { render( <MockModal scope={{ rootPath: ['TAB_ID'], excluded: [], }} />, ); fireEvent.click(screen.getByText('Scoping')); fireEvent.click(screen.getByLabelText('Apply to specific panels')); await waitFor(() => { expect(screen.getByRole('tree')).toBeInTheDocument(); expect( document.querySelectorAll('.ant-tree-checkbox-checked').length, ).toBe(4); }); }); });
7,351
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/utils.test.ts
/** * 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 { Layout } from 'src/dashboard/types'; import { buildTree } from './utils'; // The types defined for Layout and sub elements is not compatible with the data we get back fro a real dashboard layout // This test file is using data from a real example dashboard to test real world data sets. ts-ignore is set for this entire file // until we can reconcile adjusting types to match the actual data structures used describe('Ensure buildTree does not throw runtime errors when encountering an invalid node', () => { const node = { children: ['TABS-97PVJa11D_'], id: 'ROOT_ID', type: 'ROOT', parents: [], }; const treeItem = { children: [], key: 'ROOT_ID', type: 'ROOT', title: 'All panels', }; const layout: Layout = { 'CHART-1L7NIcXvVN': { children: [], id: 'CHART-1L7NIcXvVN', meta: { chartId: 95, height: 79, sliceName: 'Games per Genre over time', uuid: '0f8976aa-7bb4-40c7-860b-64445a51aaaf', width: 6, }, parents: ['ROOT_ID', 'TABS-97PVJa11D_', 'TAB-2_QXp8aNq', 'ROW-fjg6YQBkH'], type: 'CHART', }, 'CHART-7mKdnU7OUJ': { children: [], id: 'CHART-7mKdnU7OUJ', meta: { chartId: 131, height: 80, sliceName: 'Games per Genre', uuid: '0499bdec-0837-44f3-ae8a-8c670de81afd', width: 3, }, parents: ['ROOT_ID', 'TABS-97PVJa11D_', 'TAB-2_QXp8aNq', 'ROW-yP9SB89PZ'], type: 'CHART', }, 'CHART-8OG3UJX-Tn': { children: [], id: 'CHART-8OG3UJX-Tn', meta: { chartId: 125, height: 54, sliceName: '# of Games That Hit 100k in Sales By Release Year', sliceNameOverride: 'Top 10 Consoles, by # of Hit Games', uuid: '2b69887b-23e3-b46d-d38c-8ea11856c555', width: 6, }, parents: [ 'ROOT_ID', 'TABS-97PVJa11D_', 'TAB-lg-5ymUDgm', 'ROW-7kAf1blYU', ], type: 'CHART', }, 'CHART-W02beJK7ms': { children: [], id: 'CHART-W02beJK7ms', meta: { chartId: 78, height: 54, sliceName: 'Publishers With Most Titles', sliceNameOverride: 'Top 10 Games (by Global Sales)', uuid: 'd20b7324-3b80-24d4-37e2-3bd583b66713', width: 3, }, parents: [ 'ROOT_ID', 'TABS-97PVJa11D_', 'TAB-lg-5ymUDgm', 'ROW-7kAf1blYU', ], type: 'CHART', }, 'CHART-XFag0yZdLk': { children: [], id: 'CHART-XFag0yZdLk', meta: { chartId: 123, height: 54, sliceName: 'Most Dominant Platforms', sliceNameOverride: 'Publishers of Top 25 Games', uuid: '1810975a-f6d4-07c3-495c-c3b535d01f21', width: 3, }, parents: [ 'ROOT_ID', 'TABS-97PVJa11D_', 'TAB-lg-5ymUDgm', 'ROW-7kAf1blYU', ], type: 'CHART', }, 'CHART-XRvRfsMsaQ': { children: [], id: 'CHART-XRvRfsMsaQ', meta: { chartId: 113, height: 62, sliceName: 'Top 10 Games: Proportion of Sales in Markets', uuid: 'a40879d5-653a-42fe-9314-bbe88ad26e92', width: 6, }, parents: [ 'ROOT_ID', 'TABS-97PVJa11D_', 'TAB-lg-5ymUDgm', 'ROW-NuR8GFQTO', ], type: 'CHART', }, 'CHART-XVIYTeubZh': { children: [], id: 'CHART-XVIYTeubZh', meta: { chartId: 132, height: 80, sliceName: 'Games', uuid: '2a5e562b-ab37-1b9b-1de3-1be4335c8e83', width: 5, }, parents: ['ROOT_ID', 'TABS-97PVJa11D_', 'TAB-2_QXp8aNq', 'ROW-yP9SB89PZ'], type: 'CHART', }, 'CHART-_sx22yawJO': { children: [], id: 'CHART-_sx22yawJO', meta: { chartId: 93, height: 62, sliceName: 'Popular Genres Across Platforms', uuid: '326fc7e5-b7f1-448e-8a6f-80d0e7ce0b64', width: 6, }, parents: [ 'ROOT_ID', 'TABS-97PVJa11D_', 'TAB-lg-5ymUDgm', 'ROW-NuR8GFQTO', ], type: 'CHART', }, 'CHART-nYns6xr4Ft': { children: [], id: 'CHART-nYns6xr4Ft', meta: { chartId: 120, height: 79, sliceName: 'Total Sales per Market (Grouped by Genre)', uuid: 'd8bf948e-46fd-4380-9f9c-a950c34bcc92', width: 6, }, parents: ['ROOT_ID', 'TABS-97PVJa11D_', 'TAB-2_QXp8aNq', 'ROW-fjg6YQBkH'], type: 'CHART', }, 'CHART-uP9GF0z0rT': { children: [], id: 'CHART-uP9GF0z0rT', meta: { chartId: 127, height: 45, sliceName: 'Video Game Sales filter', uuid: 'fd9ce7ec-ae08-4f71-93e0-7c26b132b2e6', width: 4, }, parents: [ 'ROOT_ID', 'TABS-97PVJa11D_', 'TAB-2_QXp8aNq', 'ROW-yP9SB89PZ', 'COLUMN-F53B1OSMcz', ], type: 'CHART', }, 'CHART-wt6ZO8jRXZ': { children: [], id: 'CHART-wt6ZO8jRXZ', meta: { chartId: 103, height: 72, sliceName: 'Rise & Fall of Video Game Consoles', sliceNameOverride: 'Global Sales per Console', uuid: '83b0e2d0-d38b-d980-ed8e-e1c9846361b6', width: 12, }, parents: [ 'ROOT_ID', 'TABS-97PVJa11D_', 'TAB-lg-5ymUDgm', 'ROW-XT1DsNA_V', ], type: 'CHART', }, 'COLUMN-F53B1OSMcz': { children: ['MARKDOWN-7K5cBNy7qu', 'CHART-uP9GF0z0rT'], id: 'COLUMN-F53B1OSMcz', meta: { // @ts-expect-error background: 'BACKGROUND_TRANSPARENT', width: 4, }, parents: ['ROOT_ID', 'TABS-97PVJa11D_', 'TAB-2_QXp8aNq', 'ROW-yP9SB89PZ'], type: 'COLUMN', }, // @ts-expect-error DASHBOARD_VERSION_KEY: 'v2', // @ts-expect-error GRID_ID: { children: [], id: 'GRID_ID', parents: ['ROOT_ID'], type: 'GRID', }, HEADER_ID: { id: 'HEADER_ID', type: 'HEADER', // @ts-expect-error meta: { text: 'Video Game Sales', }, }, 'MARKDOWN-7K5cBNy7qu': { children: [], id: 'MARKDOWN-7K5cBNy7qu', meta: { // @ts-expect-error code: '# 🤿 Explore Trends\n\nDive into data on popular video games using the following dimensions:\n\n- Year\n- Platform\n- Publisher\n- Genre\n\nTo use the **Filter Games** box below, select values for each dimension you want to zoom in on and then click **Apply**. \n\nThe filter criteria you set in this Filter-box will apply to *all* charts in this tab.', height: 33, width: 4, }, parents: [ 'ROOT_ID', 'TABS-97PVJa11D_', 'TAB-2_QXp8aNq', 'ROW-yP9SB89PZ', 'COLUMN-F53B1OSMcz', ], type: 'MARKDOWN', }, 'MARKDOWN-JOZKOjVc3a': { children: [], id: 'MARKDOWN-JOZKOjVc3a', meta: { // @ts-expect-error code: '## 🎮Video Game Sales\n\nThis dashboard visualizes sales & platform data on video games that sold more than 100k copies. The data was last updated in early 2017.\n\n[Original dataset](https://www.kaggle.com/gregorut/videogamesales)', height: 18, width: 12, }, parents: [ 'ROOT_ID', 'TABS-97PVJa11D_', 'TAB-lg-5ymUDgm', 'ROW-0F99WDC-sz', ], type: 'MARKDOWN', }, // @ts-expect-error ROOT_ID: { children: ['TABS-97PVJa11D_'], id: 'ROOT_ID', type: 'ROOT', }, 'ROW-0F99WDC-sz': { children: ['MARKDOWN-JOZKOjVc3a'], id: 'ROW-0F99WDC-sz', meta: { // @ts-expect-error background: 'BACKGROUND_TRANSPARENT', }, parents: ['ROOT_ID', 'TABS-97PVJa11D_', 'TAB-lg-5ymUDgm'], type: 'ROW', }, 'ROW-7kAf1blYU': { children: ['CHART-W02beJK7ms', 'CHART-XFag0yZdLk', 'CHART-8OG3UJX-Tn'], id: 'ROW-7kAf1blYU', meta: { // @ts-expect-error '0': 'ROOT_ID', background: 'BACKGROUND_TRANSPARENT', }, parents: ['ROOT_ID', 'TABS-97PVJa11D_', 'TAB-lg-5ymUDgm'], type: 'ROW', }, 'ROW-NuR8GFQTO': { children: ['CHART-_sx22yawJO', 'CHART-XRvRfsMsaQ'], id: 'ROW-NuR8GFQTO', meta: { // @ts-expect-error '0': 'ROOT_ID', '1': 'TABS-97PVJa11D_', background: 'BACKGROUND_TRANSPARENT', }, parents: ['ROOT_ID', 'TABS-97PVJa11D_', 'TAB-lg-5ymUDgm'], type: 'ROW', }, 'ROW-XT1DsNA_V': { children: ['CHART-wt6ZO8jRXZ'], id: 'ROW-XT1DsNA_V', meta: { // @ts-expect-error background: 'BACKGROUND_TRANSPARENT', }, parents: ['ROOT_ID', 'TABS-97PVJa11D_', 'TAB-lg-5ymUDgm'], type: 'ROW', }, 'ROW-fjg6YQBkH': { children: ['CHART-1L7NIcXvVN', 'CHART-nYns6xr4Ft'], id: 'ROW-fjg6YQBkH', meta: { // @ts-expect-error background: 'BACKGROUND_TRANSPARENT', }, parents: ['ROOT_ID', 'TABS-97PVJa11D_', 'TAB-2_QXp8aNq'], type: 'ROW', }, 'ROW-yP9SB89PZ': { children: ['COLUMN-F53B1OSMcz', 'CHART-XVIYTeubZh', 'CHART-7mKdnU7OUJ'], id: 'ROW-yP9SB89PZ', meta: { // @ts-expect-error background: 'BACKGROUND_TRANSPARENT', }, parents: ['ROOT_ID', 'TABS-97PVJa11D_', 'TAB-2_QXp8aNq'], type: 'ROW', }, 'TAB-2_QXp8aNq': { children: ['ROW-yP9SB89PZ', 'ROW-fjg6YQBkH'], id: 'TAB-2_QXp8aNq', // @ts-expect-error meta: { text: '🤿 Explore Trends', }, parents: ['ROOT_ID', 'TABS-97PVJa11D_'], type: 'TAB', }, 'TAB-lg-5ymUDgm': { children: [ 'ROW-0F99WDC-sz', 'ROW-XT1DsNA_V', 'ROW-7kAf1blYU', 'ROW-NuR8GFQTO', ], id: 'TAB-lg-5ymUDgm', // @ts-expect-error meta: { text: 'Overview', }, parents: ['ROOT_ID', 'TABS-97PVJa11D_'], type: 'TAB', }, 'TABS-97PVJa11D_': { children: ['TAB-lg-5ymUDgm', 'TAB-2_QXp8aNq'], id: 'TABS-97PVJa11D_', // @ts-expect-error meta: {}, parents: ['ROOT_ID'], type: 'TABS', }, }; const charts = { '78': { id: 78, chartAlert: null, chartStatus: 'rendered', chartStackTrace: null, chartUpdateEndTime: 1673046999783, chartUpdateStartTime: 1673046994590, latestQueryFormData: { datasource: '20__table', viz_type: 'table', slice_id: 78, url_params: {}, granularity_sqla: 'year', time_grain_sqla: 'P1D', time_range: 'No filter', query_mode: 'raw', groupby: [], metrics: ['count'], all_columns: [ 'rank', 'name', 'global_sales', 'platform', 'genre', 'publisher', 'year', ], percent_metrics: [], adhoc_filters: [], order_by_cols: [], row_limit: 10, server_page_length: 10, order_desc: true, table_timestamp_format: 'smart_date', page_length: null, show_cell_bars: false, color_pn: false, queryFields: { groupby: 'groupby', metrics: 'metrics', }, label_colors: { '0': '#1FA8C9', '1': '#454E7C', '2600': '#666666', Europe: '#5AC189', Japan: '#FF7F44', 'North America': '#666666', Other: '#E04355', PS2: '#FCC700', X360: '#A868B7', PS3: '#3CCCCB', Wii: '#A38F79', DS: '#8FD3E4', PS: '#A1A6BD', GBA: '#ACE1C4', PSP: '#FEC0A1', PS4: '#B2B2B2', PC: '#EFA1AA', GB: '#FDE380', XB: '#D3B3DA', NES: '#9EE5E5', '3DS': '#D1C6BC', N64: '#1FA8C9', SNES: '#454E7C', GC: '#5AC189', XOne: '#FF7F44', WiiU: '#E04355', PSV: '#FCC700', SAT: '#A868B7', GEN: '#3CCCCB', DC: '#A38F79', SCD: '#8FD3E4', NG: '#A1A6BD', WS: '#ACE1C4', TG16: '#FEC0A1', '3DO': '#B2B2B2', GG: '#EFA1AA', PCFX: '#FDE380', Nintendo: '#D3B3DA', 'Take-Two Interactive': '#9EE5E5', 'Microsoft Game Studios': '#D1C6BC', Action: '#1FA8C9', Adventure: '#454E7C', Fighting: '#5AC189', Misc: '#FF7F44', Platform: '#666666', Puzzle: '#E04355', Racing: '#FCC700', 'Role-Playing': '#A868B7', Shooter: '#3CCCCB', Simulation: '#A38F79', Sports: '#8FD3E4', Strategy: '#A1A6BD', }, shared_label_colors: {}, color_scheme: 'supersetColors', extra_filters: [ { col: '__time_range', op: '==', val: 'No filter', }, ], extra_form_data: {}, dashboardId: 9, }, sliceFormData: null, queryController: {}, queriesResponse: [ { cache_key: '83862e7cb770044d4b5a4b2d8e665022', cached_dttm: null, cache_timeout: 86400, applied_template_filters: [], annotation_data: {}, error: null, is_cached: null, query: 'SELECT rank AS rank,\n name AS name,\n global_sales AS global_sales,\n platform AS platform,\n genre AS genre,\n publisher AS publisher,\n year AS year\nFROM main.video_game_sales\nLIMIT 10\nOFFSET 0;\n\n', status: 'success', stacktrace: null, rowcount: 10, from_dttm: null, to_dttm: null, label_map: { rank: ['rank'], name: ['name'], global_sales: ['global_sales'], platform: ['platform'], genre: ['genre'], publisher: ['publisher'], year: ['year'], }, colnames: [ 'rank', 'name', 'global_sales', 'platform', 'genre', 'publisher', 'year', ], indexnames: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], coltypes: [0, 1, 0, 1, 1, 1, 2], data: [ { rank: 1, name: 'Wii Sports', global_sales: 82.74, platform: 'Wii', genre: 'Sports', publisher: 'Nintendo', year: 1136073600000, }, { rank: 2, name: 'Super Mario Bros.', global_sales: 40.24, platform: 'NES', genre: 'Platform', publisher: 'Nintendo', year: 473385600000, }, { rank: 3, name: 'Mario Kart Wii', global_sales: 35.82, platform: 'Wii', genre: 'Racing', publisher: 'Nintendo', year: 1199145600000, }, { rank: 4, name: 'Wii Sports Resort', global_sales: 33, platform: 'Wii', genre: 'Sports', publisher: 'Nintendo', year: 1230768000000, }, { rank: 5, name: 'Pokemon Red/Pokemon Blue', global_sales: 31.37, platform: 'GB', genre: 'Role-Playing', publisher: 'Nintendo', year: 820454400000, }, { rank: 6, name: 'Tetris', global_sales: 30.26, platform: 'GB', genre: 'Puzzle', publisher: 'Nintendo', year: 599616000000, }, { rank: 7, name: 'New Super Mario Bros.', global_sales: 30.01, platform: 'DS', genre: 'Platform', publisher: 'Nintendo', year: 1136073600000, }, { rank: 8, name: 'Wii Play', global_sales: 29.02, platform: 'Wii', genre: 'Misc', publisher: 'Nintendo', year: 1136073600000, }, { rank: 9, name: 'New Super Mario Bros. Wii', global_sales: 28.62, platform: 'Wii', genre: 'Platform', publisher: 'Nintendo', year: 1230768000000, }, { rank: 10, name: 'Duck Hunt', global_sales: 28.31, platform: 'NES', genre: 'Shooter', publisher: 'Nintendo', year: 441763200000, }, ], result_format: 'json', applied_filters: [ { column: '__time_range', }, ], rejected_filters: [], }, ], triggerQuery: false, lastRendered: 0, form_data: { datasource: '20__table', viz_type: 'table', slice_id: 78, url_params: {}, granularity_sqla: 'year', time_grain_sqla: 'P1D', time_range: 'No filter', query_mode: 'raw', groupby: [], metrics: ['count'], all_columns: [ 'rank', 'name', 'global_sales', 'platform', 'genre', 'publisher', 'year', ], percent_metrics: [], adhoc_filters: [], order_by_cols: [], row_limit: 10, server_page_length: 10, order_desc: true, table_timestamp_format: 'smart_date', page_length: null, show_cell_bars: false, color_pn: false, queryFields: { groupby: 'groupby', metrics: 'metrics', }, }, }, '93': { id: 93, chartAlert: null, chartStatus: 'rendered', chartStackTrace: null, chartUpdateEndTime: 1673046999051, chartUpdateStartTime: 1673046994633, latestQueryFormData: { datasource: '20__table', viz_type: 'heatmap', slice_id: 93, url_params: {}, granularity_sqla: 'year', time_range: 'No filter', all_columns_x: 'platform', all_columns_y: 'genre', metric: 'count', adhoc_filters: [], row_limit: 10000, linear_color_scheme: 'blue_white_yellow', xscale_interval: null, yscale_interval: null, canvas_image_rendering: 'pixelated', normalize_across: 'heatmap', left_margin: 'auto', bottom_margin: 'auto', y_axis_bounds: [null, null], y_axis_format: 'SMART_NUMBER', sort_x_axis: 'alpha_asc', sort_y_axis: 'alpha_asc', show_legend: true, show_perc: true, show_values: true, queryFields: { metric: 'metrics', }, shared_label_colors: {}, color_scheme: 'supersetColors', extra_filters: [ { col: '__time_range', op: '==', val: 'No filter', }, ], extra_form_data: {}, dashboardId: 9, }, sliceFormData: null, queryController: {}, queriesResponse: [ { cache_key: '74366173c918f7430ab23aaa5567af49', cached_dttm: null, cache_timeout: 86400, errors: [], form_data: { datasource: '20__table', viz_type: 'heatmap', slice_id: 93, url_params: {}, granularity_sqla: 'year', time_range: 'No filter', all_columns_x: 'platform', all_columns_y: 'genre', metric: 'count', adhoc_filters: [], row_limit: 10000, linear_color_scheme: 'blue_white_yellow', xscale_interval: null, yscale_interval: null, canvas_image_rendering: 'pixelated', normalize_across: 'heatmap', left_margin: 'auto', bottom_margin: 'auto', y_axis_bounds: [null, null], y_axis_format: 'SMART_NUMBER', sort_x_axis: 'alpha_asc', sort_y_axis: 'alpha_asc', show_legend: true, show_perc: true, show_values: true, queryFields: { metric: 'metrics', }, shared_label_colors: {}, color_scheme: 'supersetColors', dashboardId: 9, applied_time_extras: {}, where: '', having: '', filters: [], }, is_cached: false, query: 'SELECT platform AS platform,\n genre AS genre,\n COUNT(*) AS count\nFROM main.video_game_sales\nGROUP BY platform,\n genre\nLIMIT 10000\nOFFSET 0', from_dttm: null, to_dttm: null, status: 'success', stacktrace: null, rowcount: 293, colnames: ['platform', 'genre', 'count'], coltypes: [1, 1, 0], data: { records: [ { x: '2600', y: 'Action', v: 61, perc: 0.15037593984962405, rank: 0.6962457337883959, }, { x: '2600', y: 'Adventure', v: 2, perc: 0.002506265664160401, rank: 0.09044368600682594, }, { x: '2600', y: 'Fighting', v: 2, perc: 0.002506265664160401, rank: 0.09044368600682594, }, { x: '2600', y: 'Misc', v: 5, perc: 0.010025062656641603, rank: 0.1962457337883959, }, { x: '2600', y: 'Platform', v: 9, perc: 0.020050125313283207, rank: 0.2832764505119454, }, { x: '2600', y: 'Puzzle', v: 11, perc: 0.02506265664160401, rank: 0.3242320819112628, }, { x: '2600', y: 'Racing', v: 6, perc: 0.012531328320802004, rank: 0.22184300341296928, }, { x: '2600', y: 'Shooter', v: 24, perc: 0.05764411027568922, rank: 0.49829351535836175, }, { x: '2600', y: 'Simulation', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: '2600', y: 'Sports', v: 12, perc: 0.02756892230576441, rank: 0.34982935153583616, }, { x: '3DO', y: 'Adventure', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: '3DO', y: 'Puzzle', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: '3DO', y: 'Simulation', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: '3DS', y: 'Action', v: 182, perc: 0.45363408521303256, rank: 0.9146757679180887, }, { x: '3DS', y: 'Adventure', v: 37, perc: 0.09022556390977443, rank: 0.6006825938566553, }, { x: '3DS', y: 'Fighting', v: 14, perc: 0.03258145363408521, rank: 0.378839590443686, }, { x: '3DS', y: 'Misc', v: 53, perc: 0.13032581453634084, rank: 0.6723549488054608, }, { x: '3DS', y: 'Platform', v: 28, perc: 0.06766917293233082, rank: 0.5426621160409556, }, { x: '3DS', y: 'Puzzle', v: 20, perc: 0.047619047619047616, rank: 0.4590443686006826, }, { x: '3DS', y: 'Racing', v: 11, perc: 0.02506265664160401, rank: 0.3242320819112628, }, { x: '3DS', y: 'Role-Playing', v: 86, perc: 0.21303258145363407, rank: 0.7832764505119454, }, { x: '3DS', y: 'Shooter', v: 7, perc: 0.015037593984962405, rank: 0.24573378839590443, }, { x: '3DS', y: 'Simulation', v: 30, perc: 0.07268170426065163, rank: 0.5580204778156996, }, { x: '3DS', y: 'Sports', v: 26, perc: 0.06265664160401002, rank: 0.5273037542662116, }, { x: '3DS', y: 'Strategy', v: 15, perc: 0.03508771929824561, rank: 0.39419795221843, }, { x: 'DC', y: 'Action', v: 3, perc: 0.005012531328320802, rank: 0.12798634812286688, }, { x: 'DC', y: 'Adventure', v: 11, perc: 0.02506265664160401, rank: 0.3242320819112628, }, { x: 'DC', y: 'Fighting', v: 12, perc: 0.02756892230576441, rank: 0.34982935153583616, }, { x: 'DC', y: 'Platform', v: 2, perc: 0.002506265664160401, rank: 0.09044368600682594, }, { x: 'DC', y: 'Racing', v: 6, perc: 0.012531328320802004, rank: 0.22184300341296928, }, { x: 'DC', y: 'Role-Playing', v: 4, perc: 0.007518796992481203, rank: 0.16552901023890784, }, { x: 'DC', y: 'Shooter', v: 3, perc: 0.005012531328320802, rank: 0.12798634812286688, }, { x: 'DC', y: 'Simulation', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'DC', y: 'Sports', v: 10, perc: 0.022556390977443608, rank: 0.3003412969283277, }, { x: 'DS', y: 'Action', v: 343, perc: 0.8571428571428571, rank: 0.9863481228668942, }, { x: 'DS', y: 'Adventure', v: 240, perc: 0.5989974937343359, rank: 0.9692832764505119, }, { x: 'DS', y: 'Fighting', v: 36, perc: 0.08771929824561403, rank: 0.5887372013651877, }, { x: 'DS', y: 'Misc', v: 393, perc: 0.9824561403508771, rank: 0.9965870307167235, }, { x: 'DS', y: 'Platform', v: 92, perc: 0.22807017543859648, rank: 0.8003412969283277, }, { x: 'DS', y: 'Puzzle', v: 238, perc: 0.5939849624060151, rank: 0.9641638225255973, }, { x: 'DS', y: 'Racing', v: 67, perc: 0.16541353383458646, rank: 0.726962457337884, }, { x: 'DS', y: 'Role-Playing', v: 200, perc: 0.49874686716791977, rank: 0.931740614334471, }, { x: 'DS', y: 'Shooter', v: 42, perc: 0.10275689223057644, rank: 0.6279863481228669, }, { x: 'DS', y: 'Simulation', v: 284, perc: 0.7092731829573935, rank: 0.9795221843003413, }, { x: 'DS', y: 'Sports', v: 148, perc: 0.3684210526315789, rank: 0.8822525597269625, }, { x: 'DS', y: 'Strategy', v: 79, perc: 0.19548872180451127, rank: 0.7679180887372014, }, { x: 'GB', y: 'Action', v: 6, perc: 0.012531328320802004, rank: 0.22184300341296928, }, { x: 'GB', y: 'Adventure', v: 5, perc: 0.010025062656641603, rank: 0.1962457337883959, }, { x: 'GB', y: 'Misc', v: 8, perc: 0.017543859649122806, rank: 0.26791808873720135, }, { x: 'GB', y: 'Platform', v: 19, perc: 0.045112781954887216, rank: 0.45051194539249145, }, { x: 'GB', y: 'Puzzle', v: 15, perc: 0.03508771929824561, rank: 0.39419795221843, }, { x: 'GB', y: 'Racing', v: 2, perc: 0.002506265664160401, rank: 0.09044368600682594, }, { x: 'GB', y: 'Role-Playing', v: 21, perc: 0.05012531328320802, rank: 0.46757679180887374, }, { x: 'GB', y: 'Shooter', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'GB', y: 'Simulation', v: 5, perc: 0.010025062656641603, rank: 0.1962457337883959, }, { x: 'GB', y: 'Sports', v: 9, perc: 0.020050125313283207, rank: 0.2832764505119454, }, { x: 'GB', y: 'Strategy', v: 7, perc: 0.015037593984962405, rank: 0.24573378839590443, }, { x: 'GBA', y: 'Action', v: 167, perc: 0.41604010025062654, rank: 0.9078498293515358, }, { x: 'GBA', y: 'Adventure', v: 38, perc: 0.09273182957393483, rank: 0.6092150170648464, }, { x: 'GBA', y: 'Fighting', v: 23, perc: 0.05513784461152882, rank: 0.4812286689419795, }, { x: 'GBA', y: 'Misc', v: 110, perc: 0.2731829573934837, rank: 0.8378839590443686, }, { x: 'GBA', y: 'Platform', v: 142, perc: 0.3533834586466165, rank: 0.8737201365187713, }, { x: 'GBA', y: 'Puzzle', v: 41, perc: 0.10025062656641603, rank: 0.621160409556314, }, { x: 'GBA', y: 'Racing', v: 64, perc: 0.15789473684210525, rank: 0.7081911262798635, }, { x: 'GBA', y: 'Role-Playing', v: 73, perc: 0.18045112781954886, rank: 0.7457337883959044, }, { x: 'GBA', y: 'Shooter', v: 40, perc: 0.09774436090225563, rank: 0.6160409556313993, }, { x: 'GBA', y: 'Simulation', v: 18, perc: 0.042606516290726815, rank: 0.43686006825938567, }, { x: 'GBA', y: 'Sports', v: 88, perc: 0.21804511278195488, rank: 0.7918088737201365, }, { x: 'GBA', y: 'Strategy', v: 18, perc: 0.042606516290726815, rank: 0.43686006825938567, }, { x: 'GC', y: 'Action', v: 101, perc: 0.2506265664160401, rank: 0.8156996587030717, }, { x: 'GC', y: 'Adventure', v: 20, perc: 0.047619047619047616, rank: 0.4590443686006826, }, { x: 'GC', y: 'Fighting', v: 42, perc: 0.10275689223057644, rank: 0.6279863481228669, }, { x: 'GC', y: 'Misc', v: 36, perc: 0.08771929824561403, rank: 0.5887372013651877, }, { x: 'GC', y: 'Platform', v: 73, perc: 0.18045112781954886, rank: 0.7457337883959044, }, { x: 'GC', y: 'Puzzle', v: 13, perc: 0.03007518796992481, rank: 0.36689419795221845, }, { x: 'GC', y: 'Racing', v: 63, perc: 0.15538847117794485, rank: 0.7013651877133106, }, { x: 'GC', y: 'Role-Playing', v: 27, perc: 0.06516290726817042, rank: 0.5358361774744027, }, { x: 'GC', y: 'Shooter', v: 48, perc: 0.11779448621553884, rank: 0.6535836177474402, }, { x: 'GC', y: 'Simulation', v: 12, perc: 0.02756892230576441, rank: 0.34982935153583616, }, { x: 'GC', y: 'Sports', v: 110, perc: 0.2731829573934837, rank: 0.8378839590443686, }, { x: 'GC', y: 'Strategy', v: 11, perc: 0.02506265664160401, rank: 0.3242320819112628, }, { x: 'GEN', y: 'Action', v: 3, perc: 0.005012531328320802, rank: 0.12798634812286688, }, { x: 'GEN', y: 'Adventure', v: 2, perc: 0.002506265664160401, rank: 0.09044368600682594, }, { x: 'GEN', y: 'Fighting', v: 5, perc: 0.010025062656641603, rank: 0.1962457337883959, }, { x: 'GEN', y: 'Misc', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'GEN', y: 'Platform', v: 7, perc: 0.015037593984962405, rank: 0.24573378839590443, }, { x: 'GEN', y: 'Racing', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'GEN', y: 'Role-Playing', v: 3, perc: 0.005012531328320802, rank: 0.12798634812286688, }, { x: 'GEN', y: 'Shooter', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'GEN', y: 'Sports', v: 3, perc: 0.005012531328320802, rank: 0.12798634812286688, }, { x: 'GEN', y: 'Strategy', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'GG', y: 'Platform', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'N64', y: 'Action', v: 38, perc: 0.09273182957393483, rank: 0.6092150170648464, }, { x: 'N64', y: 'Adventure', v: 4, perc: 0.007518796992481203, rank: 0.16552901023890784, }, { x: 'N64', y: 'Fighting', v: 29, perc: 0.07017543859649122, rank: 0.5511945392491467, }, { x: 'N64', y: 'Misc', v: 18, perc: 0.042606516290726815, rank: 0.43686006825938567, }, { x: 'N64', y: 'Platform', v: 30, perc: 0.07268170426065163, rank: 0.5580204778156996, }, { x: 'N64', y: 'Puzzle', v: 12, perc: 0.02756892230576441, rank: 0.34982935153583616, }, { x: 'N64', y: 'Racing', v: 57, perc: 0.14035087719298245, rank: 0.6791808873720137, }, { x: 'N64', y: 'Role-Playing', v: 8, perc: 0.017543859649122806, rank: 0.26791808873720135, }, { x: 'N64', y: 'Shooter', v: 24, perc: 0.05764411027568922, rank: 0.49829351535836175, }, { x: 'N64', y: 'Simulation', v: 10, perc: 0.022556390977443608, rank: 0.3003412969283277, }, { x: 'N64', y: 'Sports', v: 80, perc: 0.19799498746867167, rank: 0.7713310580204779, }, { x: 'N64', y: 'Strategy', v: 9, perc: 0.020050125313283207, rank: 0.2832764505119454, }, { x: 'NES', y: 'Action', v: 13, perc: 0.03007518796992481, rank: 0.36689419795221845, }, { x: 'NES', y: 'Adventure', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'NES', y: 'Fighting', v: 4, perc: 0.007518796992481203, rank: 0.16552901023890784, }, { x: 'NES', y: 'Misc', v: 2, perc: 0.002506265664160401, rank: 0.09044368600682594, }, { x: 'NES', y: 'Platform', v: 28, perc: 0.06766917293233082, rank: 0.5426621160409556, }, { x: 'NES', y: 'Puzzle', v: 14, perc: 0.03258145363408521, rank: 0.378839590443686, }, { x: 'NES', y: 'Racing', v: 4, perc: 0.007518796992481203, rank: 0.16552901023890784, }, { x: 'NES', y: 'Role-Playing', v: 11, perc: 0.02506265664160401, rank: 0.3242320819112628, }, { x: 'NES', y: 'Shooter', v: 7, perc: 0.015037593984962405, rank: 0.24573378839590443, }, { x: 'NES', y: 'Sports', v: 14, perc: 0.03258145363408521, rank: 0.378839590443686, }, { x: 'NG', y: 'Fighting', v: 11, perc: 0.02506265664160401, rank: 0.3242320819112628, }, { x: 'NG', y: 'Sports', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'PC', y: 'Action', v: 165, perc: 0.41102756892230574, rank: 0.9044368600682594, }, { x: 'PC', y: 'Adventure', v: 65, perc: 0.16040100250626566, rank: 0.7167235494880546, }, { x: 'PC', y: 'Fighting', v: 6, perc: 0.012531328320802004, rank: 0.22184300341296928, }, { x: 'PC', y: 'Misc', v: 24, perc: 0.05764411027568922, rank: 0.49829351535836175, }, { x: 'PC', y: 'Platform', v: 11, perc: 0.02506265664160401, rank: 0.3242320819112628, }, { x: 'PC', y: 'Puzzle', v: 25, perc: 0.06015037593984962, rank: 0.515358361774744, }, { x: 'PC', y: 'Racing', v: 60, perc: 0.14786967418546365, rank: 0.689419795221843, }, { x: 'PC', y: 'Role-Playing', v: 104, perc: 0.2581453634085213, rank: 0.8225255972696246, }, { x: 'PC', y: 'Shooter', v: 148, perc: 0.3684210526315789, rank: 0.8822525597269625, }, { x: 'PC', y: 'Simulation', v: 115, perc: 0.2857142857142857, rank: 0.8430034129692833, }, { x: 'PC', y: 'Sports', v: 49, perc: 0.12030075187969924, rank: 0.6621160409556314, }, { x: 'PC', y: 'Strategy', v: 188, perc: 0.46867167919799496, rank: 0.9215017064846417, }, { x: 'PCFX', y: 'Role-Playing', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'PS', y: 'Action', v: 157, perc: 0.39097744360902253, rank: 0.8976109215017065, }, { x: 'PS', y: 'Adventure', v: 69, perc: 0.17042606516290726, rank: 0.7337883959044369, }, { x: 'PS', y: 'Fighting', v: 108, perc: 0.2681704260651629, rank: 0.8327645051194539, }, { x: 'PS', y: 'Misc', v: 76, perc: 0.18796992481203006, rank: 0.7610921501706485, }, { x: 'PS', y: 'Platform', v: 64, perc: 0.15789473684210525, rank: 0.7081911262798635, }, { x: 'PS', y: 'Puzzle', v: 32, perc: 0.07769423558897243, rank: 0.5699658703071673, }, { x: 'PS', y: 'Racing', v: 145, perc: 0.3609022556390977, rank: 0.8771331058020477, }, { x: 'PS', y: 'Role-Playing', v: 97, perc: 0.24060150375939848, rank: 0.8122866894197952, }, { x: 'PS', y: 'Shooter', v: 96, perc: 0.23809523809523808, rank: 0.8088737201365188, }, { x: 'PS', y: 'Simulation', v: 60, perc: 0.14786967418546365, rank: 0.689419795221843, }, { x: 'PS', y: 'Sports', v: 222, perc: 0.5538847117794486, rank: 0.9556313993174061, }, { x: 'PS', y: 'Strategy', v: 70, perc: 0.17293233082706766, rank: 0.7372013651877133, }, { x: 'PS2', y: 'Action', v: 348, perc: 0.8696741854636592, rank: 0.9897610921501706, }, { x: 'PS2', y: 'Adventure', v: 196, perc: 0.48872180451127817, rank: 0.9283276450511946, }, { x: 'PS2', y: 'Fighting', v: 150, perc: 0.37343358395989973, rank: 0.8873720136518771, }, { x: 'PS2', y: 'Misc', v: 222, perc: 0.5538847117794486, rank: 0.9556313993174061, }, { x: 'PS2', y: 'Platform', v: 103, perc: 0.2556390977443609, rank: 0.8191126279863481, }, { x: 'PS2', y: 'Puzzle', v: 18, perc: 0.042606516290726815, rank: 0.43686006825938567, }, { x: 'PS2', y: 'Racing', v: 216, perc: 0.5388471177944862, rank: 0.9453924914675768, }, { x: 'PS2', y: 'Role-Playing', v: 187, perc: 0.46616541353383456, rank: 0.9180887372013652, }, { x: 'PS2', y: 'Shooter', v: 160, perc: 0.39849624060150374, rank: 0.9010238907849829, }, { x: 'PS2', y: 'Simulation', v: 90, perc: 0.22305764411027568, rank: 0.7952218430034129, }, { x: 'PS2', y: 'Sports', v: 400, perc: 1, rank: 1, }, { x: 'PS2', y: 'Strategy', v: 71, perc: 0.17543859649122806, rank: 0.7406143344709898, }, { x: 'PS3', y: 'Action', v: 380, perc: 0.949874686716792, rank: 0.9931740614334471, }, { x: 'PS3', y: 'Adventure', v: 74, perc: 0.18295739348370926, rank: 0.7525597269624573, }, { x: 'PS3', y: 'Fighting', v: 76, perc: 0.18796992481203006, rank: 0.7610921501706485, }, { x: 'PS3', y: 'Misc', v: 124, perc: 0.3082706766917293, rank: 0.856655290102389, }, { x: 'PS3', y: 'Platform', v: 37, perc: 0.09022556390977443, rank: 0.6006825938566553, }, { x: 'PS3', y: 'Puzzle', v: 3, perc: 0.005012531328320802, rank: 0.12798634812286688, }, { x: 'PS3', y: 'Racing', v: 92, perc: 0.22807017543859648, rank: 0.8003412969283277, }, { x: 'PS3', y: 'Role-Playing', v: 119, perc: 0.2957393483709273, rank: 0.8464163822525598, }, { x: 'PS3', y: 'Shooter', v: 156, perc: 0.38847117794486213, rank: 0.89419795221843, }, { x: 'PS3', y: 'Simulation', v: 31, perc: 0.07518796992481203, rank: 0.5648464163822525, }, { x: 'PS3', y: 'Sports', v: 213, perc: 0.531328320802005, rank: 0.9402730375426621, }, { x: 'PS3', y: 'Strategy', v: 24, perc: 0.05764411027568922, rank: 0.49829351535836175, }, { x: 'PS4', y: 'Action', v: 122, perc: 0.3032581453634085, rank: 0.8498293515358362, }, { x: 'PS4', y: 'Adventure', v: 19, perc: 0.045112781954887216, rank: 0.45051194539249145, }, { x: 'PS4', y: 'Fighting', v: 17, perc: 0.040100250626566414, rank: 0.42150170648464164, }, { x: 'PS4', y: 'Misc', v: 15, perc: 0.03508771929824561, rank: 0.39419795221843, }, { x: 'PS4', y: 'Platform', v: 11, perc: 0.02506265664160401, rank: 0.3242320819112628, }, { x: 'PS4', y: 'Puzzle', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'PS4', y: 'Racing', v: 17, perc: 0.040100250626566414, rank: 0.42150170648464164, }, { x: 'PS4', y: 'Role-Playing', v: 47, perc: 0.11528822055137844, rank: 0.6467576791808873, }, { x: 'PS4', y: 'Shooter', v: 34, perc: 0.08270676691729323, rank: 0.5767918088737202, }, { x: 'PS4', y: 'Simulation', v: 5, perc: 0.010025062656641603, rank: 0.1962457337883959, }, { x: 'PS4', y: 'Sports', v: 43, perc: 0.10526315789473684, rank: 0.6348122866894198, }, { x: 'PS4', y: 'Strategy', v: 5, perc: 0.010025062656641603, rank: 0.1962457337883959, }, { x: 'PSP', y: 'Action', v: 222, perc: 0.5538847117794486, rank: 0.9556313993174061, }, { x: 'PSP', y: 'Adventure', v: 213, perc: 0.531328320802005, rank: 0.9402730375426621, }, { x: 'PSP', y: 'Fighting', v: 74, perc: 0.18295739348370926, rank: 0.7525597269624573, }, { x: 'PSP', y: 'Misc', v: 106, perc: 0.2631578947368421, rank: 0.8293515358361775, }, { x: 'PSP', y: 'Platform', v: 36, perc: 0.08771929824561403, rank: 0.5887372013651877, }, { x: 'PSP', y: 'Puzzle', v: 44, perc: 0.10776942355889724, rank: 0.6382252559726962, }, { x: 'PSP', y: 'Racing', v: 65, perc: 0.16040100250626566, rank: 0.7167235494880546, }, { x: 'PSP', y: 'Role-Playing', v: 192, perc: 0.47869674185463656, rank: 0.9249146757679181, }, { x: 'PSP', y: 'Shooter', v: 37, perc: 0.09022556390977443, rank: 0.6006825938566553, }, { x: 'PSP', y: 'Simulation', v: 29, perc: 0.07017543859649122, rank: 0.5511945392491467, }, { x: 'PSP', y: 'Sports', v: 135, perc: 0.3358395989974937, rank: 0.8668941979522184, }, { x: 'PSP', y: 'Strategy', v: 60, perc: 0.14786967418546365, rank: 0.689419795221843, }, { x: 'PSV', y: 'Action', v: 141, perc: 0.3508771929824561, rank: 0.8703071672354948, }, { x: 'PSV', y: 'Adventure', v: 86, perc: 0.21303258145363407, rank: 0.7832764505119454, }, { x: 'PSV', y: 'Fighting', v: 16, perc: 0.03759398496240601, rank: 0.40955631399317405, }, { x: 'PSV', y: 'Misc', v: 24, perc: 0.05764411027568922, rank: 0.49829351535836175, }, { x: 'PSV', y: 'Platform', v: 10, perc: 0.022556390977443608, rank: 0.3003412969283277, }, { x: 'PSV', y: 'Puzzle', v: 3, perc: 0.005012531328320802, rank: 0.12798634812286688, }, { x: 'PSV', y: 'Racing', v: 11, perc: 0.02506265664160401, rank: 0.3242320819112628, }, { x: 'PSV', y: 'Role-Playing', v: 82, perc: 0.20300751879699247, rank: 0.7747440273037542, }, { x: 'PSV', y: 'Shooter', v: 5, perc: 0.010025062656641603, rank: 0.1962457337883959, }, { x: 'PSV', y: 'Simulation', v: 3, perc: 0.005012531328320802, rank: 0.12798634812286688, }, { x: 'PSV', y: 'Sports', v: 23, perc: 0.05513784461152882, rank: 0.4812286689419795, }, { x: 'PSV', y: 'Strategy', v: 7, perc: 0.015037593984962405, rank: 0.24573378839590443, }, { x: 'SAT', y: 'Action', v: 3, perc: 0.005012531328320802, rank: 0.12798634812286688, }, { x: 'SAT', y: 'Adventure', v: 26, perc: 0.06265664160401002, rank: 0.5273037542662116, }, { x: 'SAT', y: 'Fighting', v: 31, perc: 0.07518796992481203, rank: 0.5648464163822525, }, { x: 'SAT', y: 'Misc', v: 15, perc: 0.03508771929824561, rank: 0.39419795221843, }, { x: 'SAT', y: 'Platform', v: 5, perc: 0.010025062656641603, rank: 0.1962457337883959, }, { x: 'SAT', y: 'Puzzle', v: 5, perc: 0.010025062656641603, rank: 0.1962457337883959, }, { x: 'SAT', y: 'Racing', v: 8, perc: 0.017543859649122806, rank: 0.26791808873720135, }, { x: 'SAT', y: 'Role-Playing', v: 17, perc: 0.040100250626566414, rank: 0.42150170648464164, }, { x: 'SAT', y: 'Shooter', v: 22, perc: 0.05263157894736842, rank: 0.47440273037542663, }, { x: 'SAT', y: 'Simulation', v: 7, perc: 0.015037593984962405, rank: 0.24573378839590443, }, { x: 'SAT', y: 'Sports', v: 16, perc: 0.03759398496240601, rank: 0.40955631399317405, }, { x: 'SAT', y: 'Strategy', v: 18, perc: 0.042606516290726815, rank: 0.43686006825938567, }, { x: 'SCD', y: 'Misc', v: 2, perc: 0.002506265664160401, rank: 0.09044368600682594, }, { x: 'SCD', y: 'Platform', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'SCD', y: 'Racing', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'SCD', y: 'Role-Playing', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'SCD', y: 'Strategy', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'SNES', y: 'Action', v: 12, perc: 0.02756892230576441, rank: 0.34982935153583616, }, { x: 'SNES', y: 'Adventure', v: 4, perc: 0.007518796992481203, rank: 0.16552901023890784, }, { x: 'SNES', y: 'Fighting', v: 25, perc: 0.06015037593984962, rank: 0.515358361774744, }, { x: 'SNES', y: 'Misc', v: 17, perc: 0.040100250626566414, rank: 0.42150170648464164, }, { x: 'SNES', y: 'Platform', v: 26, perc: 0.06265664160401002, rank: 0.5273037542662116, }, { x: 'SNES', y: 'Puzzle', v: 13, perc: 0.03007518796992481, rank: 0.36689419795221845, }, { x: 'SNES', y: 'Racing', v: 9, perc: 0.020050125313283207, rank: 0.2832764505119454, }, { x: 'SNES', y: 'Role-Playing', v: 50, perc: 0.12280701754385964, rank: 0.6689419795221843, }, { x: 'SNES', y: 'Shooter', v: 10, perc: 0.022556390977443608, rank: 0.3003412969283277, }, { x: 'SNES', y: 'Simulation', v: 9, perc: 0.020050125313283207, rank: 0.2832764505119454, }, { x: 'SNES', y: 'Sports', v: 49, perc: 0.12030075187969924, rank: 0.6621160409556314, }, { x: 'SNES', y: 'Strategy', v: 15, perc: 0.03508771929824561, rank: 0.39419795221843, }, { x: 'TG16', y: 'Adventure', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'TG16', y: 'Shooter', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'WS', y: 'Role-Playing', v: 4, perc: 0.007518796992481203, rank: 0.16552901023890784, }, { x: 'WS', y: 'Strategy', v: 2, perc: 0.002506265664160401, rank: 0.09044368600682594, }, { x: 'Wii', y: 'Action', v: 238, perc: 0.5939849624060151, rank: 0.9641638225255973, }, { x: 'Wii', y: 'Adventure', v: 84, perc: 0.20802005012531327, rank: 0.7781569965870307, }, { x: 'Wii', y: 'Fighting', v: 42, perc: 0.10275689223057644, rank: 0.6279863481228669, }, { x: 'Wii', y: 'Misc', v: 280, perc: 0.6992481203007519, rank: 0.9761092150170648, }, { x: 'Wii', y: 'Platform', v: 58, perc: 0.14285714285714285, rank: 0.6825938566552902, }, { x: 'Wii', y: 'Puzzle', v: 55, perc: 0.13533834586466165, rank: 0.6757679180887372, }, { x: 'Wii', y: 'Racing', v: 94, perc: 0.23308270676691728, rank: 0.8054607508532423, }, { x: 'Wii', y: 'Role-Playing', v: 35, perc: 0.08521303258145363, rank: 0.5802047781569966, }, { x: 'Wii', y: 'Shooter', v: 66, perc: 0.16290726817042606, rank: 0.7235494880546075, }, { x: 'Wii', y: 'Simulation', v: 87, perc: 0.21553884711779447, rank: 0.78839590443686, }, { x: 'Wii', y: 'Sports', v: 261, perc: 0.6516290726817042, rank: 0.9726962457337884, }, { x: 'Wii', y: 'Strategy', v: 25, perc: 0.06015037593984962, rank: 0.515358361774744, }, { x: 'WiiU', y: 'Action', v: 63, perc: 0.15538847117794485, rank: 0.7013651877133106, }, { x: 'WiiU', y: 'Adventure', v: 3, perc: 0.005012531328320802, rank: 0.12798634812286688, }, { x: 'WiiU', y: 'Fighting', v: 5, perc: 0.010025062656641603, rank: 0.1962457337883959, }, { x: 'WiiU', y: 'Misc', v: 21, perc: 0.05012531328320802, rank: 0.46757679180887374, }, { x: 'WiiU', y: 'Platform', v: 16, perc: 0.03759398496240601, rank: 0.40955631399317405, }, { x: 'WiiU', y: 'Puzzle', v: 4, perc: 0.007518796992481203, rank: 0.16552901023890784, }, { x: 'WiiU', y: 'Racing', v: 3, perc: 0.005012531328320802, rank: 0.12798634812286688, }, { x: 'WiiU', y: 'Role-Playing', v: 6, perc: 0.012531328320802004, rank: 0.22184300341296928, }, { x: 'WiiU', y: 'Shooter', v: 10, perc: 0.022556390977443608, rank: 0.3003412969283277, }, { x: 'WiiU', y: 'Simulation', v: 1, perc: 0, rank: 0.03924914675767918, }, { x: 'WiiU', y: 'Sports', v: 8, perc: 0.017543859649122806, rank: 0.26791808873720135, }, { x: 'WiiU', y: 'Strategy', v: 3, perc: 0.005012531328320802, rank: 0.12798634812286688, }, { x: 'X360', y: 'Action', v: 324, perc: 0.8095238095238095, rank: 0.9829351535836177, }, { x: 'X360', y: 'Adventure', v: 47, perc: 0.11528822055137844, rank: 0.6467576791808873, }, { x: 'X360', y: 'Fighting', v: 65, perc: 0.16040100250626566, rank: 0.7167235494880546, }, { x: 'X360', y: 'Misc', v: 126, perc: 0.3132832080200501, rank: 0.8600682593856656, }, { x: 'X360', y: 'Platform', v: 24, perc: 0.05764411027568922, rank: 0.49829351535836175, }, { x: 'X360', y: 'Puzzle', v: 7, perc: 0.015037593984962405, rank: 0.24573378839590443, }, { x: 'X360', y: 'Racing', v: 105, perc: 0.2606516290726817, rank: 0.825938566552901, }, { x: 'X360', y: 'Role-Playing', v: 76, perc: 0.18796992481203006, rank: 0.7610921501706485, }, { x: 'X360', y: 'Shooter', v: 203, perc: 0.506265664160401, rank: 0.9351535836177475, }, { x: 'X360', y: 'Simulation', v: 40, perc: 0.09774436090225563, rank: 0.6160409556313993, }, { x: 'X360', y: 'Sports', v: 220, perc: 0.5488721804511278, rank: 0.9488054607508533, }, { x: 'X360', y: 'Strategy', v: 28, perc: 0.06766917293233082, rank: 0.5426621160409556, }, { x: 'XB', y: 'Action', v: 155, perc: 0.38596491228070173, rank: 0.8907849829351536, }, { x: 'XB', y: 'Adventure', v: 26, perc: 0.06265664160401002, rank: 0.5273037542662116, }, { x: 'XB', y: 'Fighting', v: 48, perc: 0.11779448621553884, rank: 0.6535836177474402, }, { x: 'XB', y: 'Misc', v: 46, perc: 0.11278195488721804, rank: 0.6416382252559727, }, { x: 'XB', y: 'Platform', v: 49, perc: 0.12030075187969924, rank: 0.6621160409556314, }, { x: 'XB', y: 'Puzzle', v: 7, perc: 0.015037593984962405, rank: 0.24573378839590443, }, { x: 'XB', y: 'Racing', v: 123, perc: 0.3057644110275689, rank: 0.8532423208191127, }, { x: 'XB', y: 'Role-Playing', v: 23, perc: 0.05513784461152882, rank: 0.4812286689419795, }, { x: 'XB', y: 'Shooter', v: 132, perc: 0.3283208020050125, rank: 0.863481228668942, }, { x: 'XB', y: 'Simulation', v: 24, perc: 0.05764411027568922, rank: 0.49829351535836175, }, { x: 'XB', y: 'Sports', v: 170, perc: 0.42355889724310775, rank: 0.9112627986348123, }, { x: 'XB', y: 'Strategy', v: 21, perc: 0.05012531328320802, rank: 0.46757679180887374, }, { x: 'XOne', y: 'Action', v: 68, perc: 0.16791979949874686, rank: 0.7303754266211604, }, { x: 'XOne', y: 'Adventure', v: 12, perc: 0.02756892230576441, rank: 0.34982935153583616, }, { x: 'XOne', y: 'Fighting', v: 7, perc: 0.015037593984962405, rank: 0.24573378839590443, }, { x: 'XOne', y: 'Misc', v: 15, perc: 0.03508771929824561, rank: 0.39419795221843, }, { x: 'XOne', y: 'Platform', v: 4, perc: 0.007518796992481203, rank: 0.16552901023890784, }, { x: 'XOne', y: 'Racing', v: 19, perc: 0.045112781954887216, rank: 0.45051194539249145, }, { x: 'XOne', y: 'Role-Playing', v: 13, perc: 0.03007518796992481, rank: 0.36689419795221845, }, { x: 'XOne', y: 'Shooter', v: 33, perc: 0.08020050125313283, rank: 0.5733788395904437, }, { x: 'XOne', y: 'Simulation', v: 3, perc: 0.005012531328320802, rank: 0.12798634812286688, }, { x: 'XOne', y: 'Sports', v: 36, perc: 0.08771929824561403, rank: 0.5887372013651877, }, { x: 'XOne', y: 'Strategy', v: 3, perc: 0.005012531328320802, rank: 0.12798634812286688, }, ], extents: [1, 400], }, applied_filters: [], rejected_filters: [], }, ], triggerQuery: false, lastRendered: 0, form_data: { datasource: '20__table', viz_type: 'heatmap', slice_id: 93, url_params: {}, granularity_sqla: 'year', time_range: 'No filter', all_columns_x: 'platform', all_columns_y: 'genre', metric: 'count', adhoc_filters: [], row_limit: 10000, linear_color_scheme: 'blue_white_yellow', xscale_interval: null, yscale_interval: null, canvas_image_rendering: 'pixelated', normalize_across: 'heatmap', left_margin: 'auto', bottom_margin: 'auto', y_axis_bounds: [null, null], y_axis_format: 'SMART_NUMBER', sort_x_axis: 'alpha_asc', sort_y_axis: 'alpha_asc', show_legend: true, show_perc: true, show_values: true, queryFields: { metric: 'metrics', }, }, }, '95': { id: 95, chartAlert: null, chartStatus: 'loading', chartStackTrace: null, chartUpdateEndTime: null, chartUpdateStartTime: 0, latestQueryFormData: {}, sliceFormData: null, queryController: null, queriesResponse: null, triggerQuery: true, lastRendered: 0, form_data: { datasource: '20__table', viz_type: 'line', slice_id: 95, url_params: { preselect_filters: '{"1389": {"platform": ["PS", "PS2", "PS3", "PS4"], "genre": null, "__time_range": "No filter"}}', }, granularity_sqla: 'year', time_grain_sqla: null, time_range: 'No filter', metrics: ['count'], adhoc_filters: [], groupby: ['genre'], order_desc: true, contribution: false, row_limit: null, color_scheme: 'supersetColors', show_brush: 'auto', show_legend: true, rich_tooltip: true, show_markers: false, line_interpolation: 'linear', x_axis_label: 'Year Published', bottom_margin: 'auto', x_ticks_layout: 'auto', x_axis_format: 'smart_date', x_axis_showminmax: true, y_axis_label: '# of Games Published', left_margin: 'auto', y_axis_showminmax: true, y_axis_format: 'SMART_NUMBER', y_axis_bounds: [null, null], rolling_type: 'None', comparison_type: 'values', annotation_layers: [], label_colors: { '0': '#1FA8C9', '1': '#454E7C', '2600': '#666666', '3DO': '#B2B2B2', '3DS': '#D1C6BC', Action: '#1FA8C9', Adventure: '#454E7C', DC: '#A38F79', DS: '#8FD3E4', Europe: '#5AC189', Fighting: '#5AC189', GB: '#FDE380', GBA: '#ACE1C4', GC: '#5AC189', GEN: '#3CCCCB', GG: '#EFA1AA', Japan: '#FF7F44', 'Microsoft Game Studios': '#D1C6BC', Misc: '#FF7F44', N64: '#1FA8C9', NES: '#9EE5E5', NG: '#A1A6BD', Nintendo: '#D3B3DA', 'North America': '#666666', Other: '#E04355', PC: '#EFA1AA', PCFX: '#FDE380', PS: '#A1A6BD', PS2: '#FCC700', PS3: '#3CCCCB', PS4: '#B2B2B2', PSP: '#FEC0A1', PSV: '#FCC700', Platform: '#666666', Puzzle: '#E04355', Racing: '#FCC700', 'Role-Playing': '#A868B7', SAT: '#A868B7', SCD: '#8FD3E4', SNES: '#454E7C', Shooter: '#3CCCCB', Simulation: '#A38F79', Sports: '#8FD3E4', Strategy: '#A1A6BD', TG16: '#FEC0A1', 'Take-Two Interactive': '#9EE5E5', WS: '#ACE1C4', Wii: '#A38F79', WiiU: '#E04355', X360: '#A868B7', XB: '#D3B3DA', XOne: '#FF7F44', }, queryFields: { groupby: 'groupby', metrics: 'metrics', }, }, }, '103': { id: 103, chartAlert: null, chartStatus: 'rendered', chartStackTrace: null, chartUpdateEndTime: 1673047001527, chartUpdateStartTime: 1673046994566, latestQueryFormData: { datasource: '20__table', viz_type: 'area', slice_id: 103, url_params: { preselect_filters: '{"1389": {"platform": ["PS", "PS2", "PS3", "PS4"], "genre": null, "__time_range": "No filter"}}', }, granularity_sqla: 'year', time_grain_sqla: null, time_range: 'No filter', metrics: [ { aggregate: 'SUM', column: { column_name: 'global_sales', description: null, expression: null, filterable: true, groupby: true, id: 887, is_dttm: false, optionName: '_col_Global_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: false, isNew: false, label: 'SUM(Global_Sales)', optionName: 'metric_ufl75addr8c_oqqhdumirpn', sqlExpression: null, }, ], adhoc_filters: [], groupby: ['platform'], order_desc: true, contribution: false, row_limit: null, show_brush: 'auto', show_legend: false, line_interpolation: 'linear', stacked_style: 'stream', color_scheme: 'supersetColors', rich_tooltip: true, x_axis_label: 'Year Published', bottom_margin: 'auto', x_ticks_layout: 'auto', x_axis_format: 'smart_date', x_axis_showminmax: true, y_axis_format: 'SMART_NUMBER', y_axis_bounds: [null, null], rolling_type: 'None', comparison_type: 'values', annotation_layers: [], queryFields: { groupby: 'groupby', metrics: 'metrics', }, shared_label_colors: {}, extra_filters: [ { col: '__time_range', op: '==', val: 'No filter', }, ], extra_form_data: {}, dashboardId: 9, }, sliceFormData: null, queryController: {}, queriesResponse: [ { cache_key: '20775ba73440f8cab2208ae3f422402f', cached_dttm: null, cache_timeout: 86400, errors: [], form_data: { datasource: '20__table', viz_type: 'area', slice_id: 103, url_params: { preselect_filters: '{"1389": {"platform": ["PS", "PS2", "PS3", "PS4"], "genre": null, "__time_range": "No filter"}}', }, granularity_sqla: 'year', time_grain_sqla: null, time_range: 'No filter', metrics: [ { aggregate: 'SUM', column: { column_name: 'global_sales', description: null, expression: null, filterable: true, groupby: true, id: 887, is_dttm: false, optionName: '_col_Global_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: false, isNew: false, label: 'SUM(Global_Sales)', optionName: 'metric_ufl75addr8c_oqqhdumirpn', sqlExpression: null, }, ], adhoc_filters: [], groupby: ['platform'], order_desc: true, contribution: false, row_limit: null, show_brush: 'auto', show_legend: false, line_interpolation: 'linear', stacked_style: 'stream', color_scheme: 'supersetColors', rich_tooltip: true, x_axis_label: 'Year Published', bottom_margin: 'auto', x_ticks_layout: 'auto', x_axis_format: 'smart_date', x_axis_showminmax: true, y_axis_format: 'SMART_NUMBER', y_axis_bounds: [null, null], rolling_type: 'None', comparison_type: 'values', annotation_layers: [], queryFields: { groupby: 'groupby', metrics: 'metrics', }, shared_label_colors: {}, dashboardId: 9, applied_time_extras: {}, where: '', having: '', filters: [], }, is_cached: false, query: 'SELECT year AS __timestamp,\n platform AS platform,\n sum(global_sales) AS "SUM(Global_Sales)"\nFROM main.video_game_sales\nGROUP BY platform,\n year\nORDER BY "SUM(Global_Sales)" DESC\nLIMIT 50000\nOFFSET 0', from_dttm: null, to_dttm: null, status: 'success', stacktrace: null, rowcount: 255, colnames: ['__timestamp', 'platform', 'SUM(Global_Sales)'], coltypes: [2, 1, 0], data: [ { key: ['PS2'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 0, display: { y: 0, y0: 323.9812778912993, }, series: 0, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 0, display: { y: 0, y0: 336.1762778912994, }, series: 0, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 0, display: { y: 0, y0: 332.72127789129934, }, series: 0, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 0, display: { y: 0, y0: 336.1057418579461, }, series: 0, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 0, display: { y: 0, y0: 355.76073292228295, }, series: 0, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 0, display: { y: 0, y0: 357.452200293436, }, series: 0, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 0, display: { y: 0, y0: 348.78746735575066, }, series: 0, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 0, display: { y: 0, y0: 339.76436707976166, }, series: 0, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 0, display: { y: 0, y0: 352.9550172280039, }, series: 0, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 0, display: { y: 0, y0: 345.7760219931503, }, series: 0, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 0, display: { y: 0, y0: 365.16480818468705, }, series: 0, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 0, display: { y: 0, y0: 355.9463874586553, }, series: 0, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 0, display: { y: 0, y0: 375.71003766873946, }, series: 0, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 0, display: { y: 0, y0: 377.41055311023564, }, series: 0, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 0, display: { y: 0, y0: 383.37655475227183, }, series: 0, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 0, display: { y: 0, y0: 381.6416336309462, }, series: 0, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 0, display: { y: 0, y0: 436.22008078133535, }, series: 0, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 0, display: { y: 0, y0: 421.48302062609594, }, series: 0, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 0, display: { y: 0, y0: 457.6032684133616, }, series: 0, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 0, display: { y: 0, y0: 464.9110839106354, }, series: 0, }, { x: 946684800000, y: 39.11000000000001, index: 20, seriesIndex: 0, display: { y: 39.11000000000001, y0: 422.2363863019829, }, series: 0, }, { x: 978307200000, y: 166.43000000000006, index: 21, seriesIndex: 0, display: { y: 166.43000000000006, y0: 375.71659853838435, }, series: 0, }, { x: 1009843200000, y: 205.40000000000006, index: 22, seriesIndex: 0, display: { y: 205.40000000000006, y0: 366.939571207276, }, series: 0, }, { x: 1041379200000, y: 184.28999999999996, index: 23, seriesIndex: 0, display: { y: 184.28999999999996, y0: 366.3006269568918, }, series: 0, }, { x: 1072915200000, y: 211.77999999999992, index: 24, seriesIndex: 0, display: { y: 211.77999999999992, y0: 358.5965490670251, }, series: 0, }, { x: 1104537600000, y: 160.65000000000012, index: 25, seriesIndex: 0, display: { y: 160.65000000000012, y0: 367.8171603424089, }, series: 0, }, { x: 1136073600000, y: 103.41999999999999, index: 26, seriesIndex: 0, display: { y: 103.41999999999999, y0: 332.2283968117778, }, series: 0, }, { x: 1167609600000, y: 76, index: 27, seriesIndex: 0, display: { y: 76, y0: 334.2380715127416, }, series: 0, }, { x: 1199145600000, y: 53.830000000000034, index: 28, seriesIndex: 0, display: { y: 53.830000000000034, y0: 331.2200000000006, }, series: 0, }, { x: 1230768000000, y: 26.45, index: 29, seriesIndex: 0, display: { y: 26.45, y0: 323.57657904990293, }, series: 0, }, { x: 1262304000000, y: 5.629999999999995, index: 30, seriesIndex: 0, display: { y: 5.629999999999995, y0: 353.63872327506743, }, series: 0, }, { x: 1293840000000, y: 0.47, index: 31, seriesIndex: 0, display: { y: 0.47, y0: 346.7617397094945, }, series: 0, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 0, display: { y: 0, y0: 355.2033114760125, }, series: 0, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 0, display: { y: 0, y0: 347.01434975261475, }, series: 0, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 0, display: { y: 0, y0: 356.1414727314012, }, series: 0, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 0, display: { y: 0, y0: 352.9817622110564, }, series: 0, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 0, display: { y: 0, y0: 323.31515851727374, }, series: 0, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 0, display: { y: 0, y0: 293.5851585172737, }, series: 0, }, ], }, { key: ['X360'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 1, display: { y: 0, y0: 312.60127789129933, }, series: 1, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 1, display: { y: 0, y0: 300.40627789129934, }, series: 1, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 1, display: { y: 0, y0: 303.8612778912993, }, series: 1, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 1, display: { y: 0, y0: 319.31574185794614, }, series: 1, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 1, display: { y: 0, y0: 305.40073292228294, }, series: 1, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 1, display: { y: 0, y0: 303.54220029343605, }, series: 1, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 1, display: { y: 0, y0: 311.7174673557506, }, series: 1, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 1, display: { y: 0, y0: 318.02436707976165, }, series: 1, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 1, display: { y: 0, y0: 305.7650172280039, }, series: 1, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 1, display: { y: 0, y0: 272.3260219931503, }, series: 1, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 1, display: { y: 0, y0: 315.774808184687, }, series: 1, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 1, display: { y: 0, y0: 323.71638745865533, }, series: 1, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 1, display: { y: 0, y0: 302.57003766873936, }, series: 1, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 1, display: { y: 0, y0: 331.4305531102357, }, series: 1, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 1, display: { y: 0, y0: 317.05655475227184, }, series: 1, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 1, display: { y: 0, y0: 297.7616336309462, }, series: 1, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 1, display: { y: 0, y0: 247.66008078133538, }, series: 1, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 1, display: { y: 0, y0: 231.76302062609608, }, series: 1, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 1, display: { y: 0, y0: 204.41326841336158, }, series: 1, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 1, display: { y: 0, y0: 218.39108391063536, }, series: 1, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 1, display: { y: 0, y0: 264.466386301983, }, series: 1, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 1, display: { y: 0, y0: 216.18659853838435, }, series: 1, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 1, display: { y: 0, y0: 185.4195712072759, }, series: 1, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 1, display: { y: 0, y0: 201.70062695689174, }, series: 1, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 1, display: { y: 0, y0: 161.52654906702506, }, series: 1, }, { x: 1104537600000, y: 8.319999999999999, index: 25, seriesIndex: 1, display: { y: 8.319999999999999, y0: 72.99716034240856, }, series: 1, }, { x: 1136073600000, y: 51.879999999999995, index: 26, seriesIndex: 1, display: { y: 51.879999999999995, y0: 76.55839681177778, }, series: 1, }, { x: 1167609600000, y: 95.83999999999993, index: 27, seriesIndex: 1, display: { y: 95.83999999999993, y0: 37.28807151274146, }, series: 1, }, { x: 1199145600000, y: 135.76000000000002, index: 28, seriesIndex: 1, display: { y: 135.76000000000002, y0: 12.669999999999975, }, series: 1, }, { x: 1230768000000, y: 120.85000000000001, index: 29, seriesIndex: 1, display: { y: 120.85000000000001, y0: 42.666579049902865, }, series: 1, }, { x: 1262304000000, y: 171.05000000000004, index: 30, seriesIndex: 1, display: { y: 171.05000000000004, y0: 59.49872327506736, }, series: 1, }, { x: 1293840000000, y: 145.1200000000002, index: 31, seriesIndex: 1, display: { y: 145.1200000000002, y0: 155.9517397094943, }, series: 1, }, { x: 1325376000000, y: 100.87999999999992, index: 32, seriesIndex: 1, display: { y: 100.87999999999992, y0: 234.96331147601265, }, series: 1, }, { x: 1356998400000, y: 89.61000000000001, index: 33, seriesIndex: 1, display: { y: 89.61000000000001, y0: 252.25434975261473, }, series: 1, }, { x: 1388534400000, y: 36.41999999999998, index: 34, seriesIndex: 1, display: { y: 36.41999999999998, y0: 319.4614727314013, }, series: 1, }, { x: 1420070400000, y: 13.049999999999999, index: 35, seriesIndex: 1, display: { y: 13.049999999999999, y0: 339.81176221105636, }, series: 1, }, { x: 1451606400000, y: 0.8300000000000001, index: 36, seriesIndex: 1, display: { y: 0.8300000000000001, y0: 322.48515851727376, }, series: 1, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 1, display: { y: 0, y0: 293.5851585172737, }, series: 1, }, ], }, { key: ['PS3'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 2, display: { y: 0, y0: 323.9812778912993, }, series: 2, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 2, display: { y: 0, y0: 336.1762778912994, }, series: 2, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 2, display: { y: 0, y0: 332.72127789129934, }, series: 2, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 2, display: { y: 0, y0: 336.1057418579461, }, series: 2, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 2, display: { y: 0, y0: 355.76073292228295, }, series: 2, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 2, display: { y: 0, y0: 357.452200293436, }, series: 2, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 2, display: { y: 0, y0: 348.78746735575066, }, series: 2, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 2, display: { y: 0, y0: 339.76436707976166, }, series: 2, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 2, display: { y: 0, y0: 352.9550172280039, }, series: 2, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 2, display: { y: 0, y0: 345.7760219931503, }, series: 2, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 2, display: { y: 0, y0: 365.16480818468705, }, series: 2, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 2, display: { y: 0, y0: 355.9463874586553, }, series: 2, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 2, display: { y: 0, y0: 375.71003766873946, }, series: 2, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 2, display: { y: 0, y0: 377.41055311023564, }, series: 2, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 2, display: { y: 0, y0: 383.37655475227183, }, series: 2, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 2, display: { y: 0, y0: 381.6416336309462, }, series: 2, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 2, display: { y: 0, y0: 436.22008078133535, }, series: 2, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 2, display: { y: 0, y0: 421.48302062609594, }, series: 2, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 2, display: { y: 0, y0: 457.6032684133616, }, series: 2, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 2, display: { y: 0, y0: 464.9110839106354, }, series: 2, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 2, display: { y: 0, y0: 461.34638630198293, }, series: 2, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 2, display: { y: 0, y0: 542.1465985383844, }, series: 2, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 2, display: { y: 0, y0: 572.3395712072761, }, series: 2, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 2, display: { y: 0, y0: 550.5906269568918, }, series: 2, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 2, display: { y: 0, y0: 570.376549067025, }, series: 2, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 2, display: { y: 0, y0: 528.467160342409, }, series: 2, }, { x: 1136073600000, y: 21.070000000000004, index: 26, seriesIndex: 2, display: { y: 21.070000000000004, y0: 573.5583968117778, }, series: 2, }, { x: 1167609600000, y: 73.81000000000006, index: 27, seriesIndex: 2, display: { y: 73.81000000000006, y0: 565.2080715127415, }, series: 2, }, { x: 1199145600000, y: 119.69000000000001, index: 28, seriesIndex: 2, display: { y: 119.69000000000001, y0: 559.2100000000006, }, series: 2, }, { x: 1230768000000, y: 132.33999999999997, index: 29, seriesIndex: 2, display: { y: 132.33999999999997, y0: 560.4665790499031, }, series: 2, }, { x: 1262304000000, y: 144.42000000000007, index: 30, seriesIndex: 2, display: { y: 144.42000000000007, y0: 491.06872327506755, }, series: 2, }, { x: 1293840000000, y: 159.3700000000001, index: 31, seriesIndex: 2, display: { y: 159.3700000000001, y0: 409.6417397094946, }, series: 2, }, { x: 1325376000000, y: 109.49000000000002, index: 32, seriesIndex: 2, display: { y: 109.49000000000002, y0: 377.9733114760125, }, series: 2, }, { x: 1356998400000, y: 117.38999999999994, index: 33, seriesIndex: 2, display: { y: 117.38999999999994, y0: 356.37434975261476, }, series: 2, }, { x: 1388534400000, y: 50.96000000000002, index: 34, seriesIndex: 2, display: { y: 50.96000000000002, y0: 360.5814727314012, }, series: 2, }, { x: 1420070400000, y: 18.220000000000002, index: 35, seriesIndex: 2, display: { y: 18.220000000000002, y0: 354.5317622110564, }, series: 2, }, { x: 1451606400000, y: 2.59, index: 36, seriesIndex: 2, display: { y: 2.59, y0: 323.31515851727374, }, series: 2, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 2, display: { y: 0, y0: 293.5851585172737, }, series: 2, }, ], }, { key: ['Wii'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 3, display: { y: 0, y0: 323.9812778912993, }, series: 3, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 3, display: { y: 0, y0: 336.1762778912994, }, series: 3, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 3, display: { y: 0, y0: 332.72127789129934, }, series: 3, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 3, display: { y: 0, y0: 336.1057418579461, }, series: 3, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 3, display: { y: 0, y0: 355.76073292228295, }, series: 3, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 3, display: { y: 0, y0: 357.452200293436, }, series: 3, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 3, display: { y: 0, y0: 348.78746735575066, }, series: 3, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 3, display: { y: 0, y0: 339.76436707976166, }, series: 3, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 3, display: { y: 0, y0: 352.9550172280039, }, series: 3, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 3, display: { y: 0, y0: 345.7760219931503, }, series: 3, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 3, display: { y: 0, y0: 365.16480818468705, }, series: 3, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 3, display: { y: 0, y0: 355.9463874586553, }, series: 3, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 3, display: { y: 0, y0: 375.71003766873946, }, series: 3, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 3, display: { y: 0, y0: 377.41055311023564, }, series: 3, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 3, display: { y: 0, y0: 383.37655475227183, }, series: 3, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 3, display: { y: 0, y0: 381.6416336309462, }, series: 3, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 3, display: { y: 0, y0: 436.22008078133535, }, series: 3, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 3, display: { y: 0, y0: 421.48302062609594, }, series: 3, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 3, display: { y: 0, y0: 457.6032684133616, }, series: 3, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 3, display: { y: 0, y0: 464.9110839106354, }, series: 3, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 3, display: { y: 0, y0: 461.34638630198293, }, series: 3, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 3, display: { y: 0, y0: 542.1465985383844, }, series: 3, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 3, display: { y: 0, y0: 572.3395712072761, }, series: 3, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 3, display: { y: 0, y0: 550.5906269568918, }, series: 3, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 3, display: { y: 0, y0: 570.376549067025, }, series: 3, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 3, display: { y: 0, y0: 528.467160342409, }, series: 3, }, { x: 1136073600000, y: 137.91000000000003, index: 26, seriesIndex: 3, display: { y: 137.91000000000003, y0: 435.64839681177784, }, series: 3, }, { x: 1167609600000, y: 154.96999999999997, index: 27, seriesIndex: 3, display: { y: 154.96999999999997, y0: 410.2380715127416, }, series: 3, }, { x: 1199145600000, y: 174.16, index: 28, seriesIndex: 3, display: { y: 174.16, y0: 385.05000000000064, }, series: 3, }, { x: 1230768000000, y: 210.4400000000002, index: 29, seriesIndex: 3, display: { y: 210.4400000000002, y0: 350.0265790499029, }, series: 3, }, { x: 1262304000000, y: 131.8000000000001, index: 30, seriesIndex: 3, display: { y: 131.8000000000001, y0: 359.26872327506743, }, series: 3, }, { x: 1293840000000, y: 62.41000000000001, index: 31, seriesIndex: 3, display: { y: 62.41000000000001, y0: 347.23173970949455, }, series: 3, }, { x: 1325376000000, y: 22.770000000000003, index: 32, seriesIndex: 3, display: { y: 22.770000000000003, y0: 355.2033114760125, }, series: 3, }, { x: 1356998400000, y: 9.359999999999998, index: 33, seriesIndex: 3, display: { y: 9.359999999999998, y0: 347.01434975261475, }, series: 3, }, { x: 1388534400000, y: 4.439999999999999, index: 34, seriesIndex: 3, display: { y: 4.439999999999999, y0: 356.1414727314012, }, series: 3, }, { x: 1420070400000, y: 1.55, index: 35, seriesIndex: 3, display: { y: 1.55, y0: 352.9817622110564, }, series: 3, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 3, display: { y: 0, y0: 323.31515851727374, }, series: 3, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 3, display: { y: 0, y0: 293.5851585172737, }, series: 3, }, ], }, { key: ['DS'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 4, display: { y: 0, y0: 312.60127789129933, }, series: 4, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 4, display: { y: 0, y0: 300.40627789129934, }, series: 4, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 4, display: { y: 0, y0: 303.8612778912993, }, series: 4, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 4, display: { y: 0, y0: 319.31574185794614, }, series: 4, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 4, display: { y: 0, y0: 305.40073292228294, }, series: 4, }, { x: 473385600000, y: 0.02, index: 5, seriesIndex: 4, display: { y: 0.02, y0: 303.54220029343605, }, series: 4, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 4, display: { y: 0, y0: 311.7174673557506, }, series: 4, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 4, display: { y: 0, y0: 318.02436707976165, }, series: 4, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 4, display: { y: 0, y0: 305.7650172280039, }, series: 4, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 4, display: { y: 0, y0: 272.3260219931503, }, series: 4, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 4, display: { y: 0, y0: 315.774808184687, }, series: 4, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 4, display: { y: 0, y0: 323.71638745865533, }, series: 4, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 4, display: { y: 0, y0: 302.57003766873936, }, series: 4, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 4, display: { y: 0, y0: 331.4305531102357, }, series: 4, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 4, display: { y: 0, y0: 317.05655475227184, }, series: 4, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 4, display: { y: 0, y0: 297.7616336309462, }, series: 4, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 4, display: { y: 0, y0: 247.66008078133538, }, series: 4, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 4, display: { y: 0, y0: 231.76302062609608, }, series: 4, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 4, display: { y: 0, y0: 204.41326841336158, }, series: 4, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 4, display: { y: 0, y0: 218.39108391063536, }, series: 4, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 4, display: { y: 0, y0: 264.466386301983, }, series: 4, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 4, display: { y: 0, y0: 216.18659853838435, }, series: 4, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 4, display: { y: 0, y0: 185.4195712072759, }, series: 4, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 4, display: { y: 0, y0: 201.70062695689174, }, series: 4, }, { x: 1072915200000, y: 17.459999999999994, index: 24, seriesIndex: 4, display: { y: 17.459999999999994, y0: 161.52654906702506, }, series: 4, }, { x: 1104537600000, y: 131.4000000000002, index: 25, seriesIndex: 4, display: { y: 131.4000000000002, y0: 81.31716034240856, }, series: 4, }, { x: 1136073600000, y: 121.14999999999998, index: 26, seriesIndex: 4, display: { y: 121.14999999999998, y0: 128.43839681177778, }, series: 4, }, { x: 1167609600000, y: 149.3600000000002, index: 27, seriesIndex: 4, display: { y: 149.3600000000002, y0: 133.1280715127414, }, series: 4, }, { x: 1199145600000, y: 147.89000000000047, index: 28, seriesIndex: 4, display: { y: 147.89000000000047, y0: 148.43, }, series: 4, }, { x: 1230768000000, y: 121.99000000000001, index: 29, seriesIndex: 4, display: { y: 121.99000000000001, y0: 163.51657904990287, }, series: 4, }, { x: 1262304000000, y: 87.97999999999995, index: 30, seriesIndex: 4, display: { y: 87.97999999999995, y0: 230.5487232750674, }, series: 4, }, { x: 1293840000000, y: 27.799999999999994, index: 31, seriesIndex: 4, display: { y: 27.799999999999994, y0: 301.0717397094945, }, series: 4, }, { x: 1325376000000, y: 11.639999999999993, index: 32, seriesIndex: 4, display: { y: 11.639999999999993, y0: 335.84331147601256, }, series: 4, }, { x: 1356998400000, y: 1.96, index: 33, seriesIndex: 4, display: { y: 1.96, y0: 341.86434975261477, }, series: 4, }, { x: 1388534400000, y: 0.02, index: 34, seriesIndex: 4, display: { y: 0.02, y0: 355.88147273140123, }, series: 4, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 4, display: { y: 0, y0: 352.8617622110564, }, series: 4, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 4, display: { y: 0, y0: 323.31515851727374, }, series: 4, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 4, display: { y: 0, y0: 293.5851585172737, }, series: 4, }, ], }, { key: ['PS'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 5, display: { y: 0, y0: 312.60127789129933, }, series: 5, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 5, display: { y: 0, y0: 300.40627789129934, }, series: 5, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 5, display: { y: 0, y0: 303.8612778912993, }, series: 5, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 5, display: { y: 0, y0: 319.31574185794614, }, series: 5, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 5, display: { y: 0, y0: 305.40073292228294, }, series: 5, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 5, display: { y: 0, y0: 303.56220029343604, }, series: 5, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 5, display: { y: 0, y0: 311.7174673557506, }, series: 5, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 5, display: { y: 0, y0: 318.02436707976165, }, series: 5, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 5, display: { y: 0, y0: 305.7650172280039, }, series: 5, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 5, display: { y: 0, y0: 272.3260219931503, }, series: 5, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 5, display: { y: 0, y0: 315.774808184687, }, series: 5, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 5, display: { y: 0, y0: 323.71638745865533, }, series: 5, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 5, display: { y: 0, y0: 302.57003766873936, }, series: 5, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 5, display: { y: 0, y0: 331.4305531102357, }, series: 5, }, { x: 757382400000, y: 6.020000000000001, index: 14, seriesIndex: 5, display: { y: 6.020000000000001, y0: 317.05655475227184, }, series: 5, }, { x: 788918400000, y: 35.92000000000002, index: 15, seriesIndex: 5, display: { y: 35.92000000000002, y0: 297.7616336309462, }, series: 5, }, { x: 820454400000, y: 94.67999999999999, index: 16, seriesIndex: 5, display: { y: 94.67999999999999, y0: 247.66008078133538, }, series: 5, }, { x: 852076800000, y: 136.0799999999999, index: 17, seriesIndex: 5, display: { y: 136.0799999999999, y0: 231.76302062609608, }, series: 5, }, { x: 883612800000, y: 169.58, index: 18, seriesIndex: 5, display: { y: 169.58, y0: 204.41326841336158, }, series: 5, }, { x: 915148800000, y: 144.5700000000001, index: 19, seriesIndex: 5, display: { y: 144.5700000000001, y0: 218.39108391063536, }, series: 5, }, { x: 946684800000, y: 96.27999999999993, index: 20, seriesIndex: 5, display: { y: 96.27999999999993, y0: 265.516386301983, }, series: 5, }, { x: 978307200000, y: 35.520000000000024, index: 21, seriesIndex: 5, display: { y: 35.520000000000024, y0: 300.04659853838433, }, series: 5, }, { x: 1009843200000, y: 6.689999999999998, index: 22, seriesIndex: 5, display: { y: 6.689999999999998, y0: 307.949571207276, }, series: 5, }, { x: 1041379200000, y: 2.05, index: 23, seriesIndex: 5, display: { y: 2.05, y0: 313.59062695689175, }, series: 5, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 5, display: { y: 0, y0: 329.7065490670251, }, series: 5, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 5, display: { y: 0, y0: 340.01716034240894, }, series: 5, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 5, display: { y: 0, y0: 320.9383968117778, }, series: 5, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 5, display: { y: 0, y0: 333.94807151274165, }, series: 5, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 5, display: { y: 0, y0: 331.1800000000006, }, series: 5, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 5, display: { y: 0, y0: 323.57657904990293, }, series: 5, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 5, display: { y: 0, y0: 353.63872327506743, }, series: 5, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 5, display: { y: 0, y0: 346.7617397094945, }, series: 5, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 5, display: { y: 0, y0: 355.2033114760125, }, series: 5, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 5, display: { y: 0, y0: 347.01434975261475, }, series: 5, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 5, display: { y: 0, y0: 356.1414727314012, }, series: 5, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 5, display: { y: 0, y0: 352.9817622110564, }, series: 5, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 5, display: { y: 0, y0: 323.31515851727374, }, series: 5, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 5, display: { y: 0, y0: 293.5851585172737, }, series: 5, }, ], }, { key: ['GBA'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 6, display: { y: 0, y0: 312.60127789129933, }, series: 6, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 6, display: { y: 0, y0: 300.40627789129934, }, series: 6, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 6, display: { y: 0, y0: 303.8612778912993, }, series: 6, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 6, display: { y: 0, y0: 319.31574185794614, }, series: 6, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 6, display: { y: 0, y0: 305.40073292228294, }, series: 6, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 6, display: { y: 0, y0: 303.56220029343604, }, series: 6, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 6, display: { y: 0, y0: 311.7174673557506, }, series: 6, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 6, display: { y: 0, y0: 318.02436707976165, }, series: 6, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 6, display: { y: 0, y0: 305.7650172280039, }, series: 6, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 6, display: { y: 0, y0: 272.3260219931503, }, series: 6, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 6, display: { y: 0, y0: 315.774808184687, }, series: 6, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 6, display: { y: 0, y0: 323.71638745865533, }, series: 6, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 6, display: { y: 0, y0: 302.57003766873936, }, series: 6, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 6, display: { y: 0, y0: 331.4305531102357, }, series: 6, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 6, display: { y: 0, y0: 317.05655475227184, }, series: 6, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 6, display: { y: 0, y0: 297.7616336309462, }, series: 6, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 6, display: { y: 0, y0: 247.66008078133538, }, series: 6, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 6, display: { y: 0, y0: 231.76302062609608, }, series: 6, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 6, display: { y: 0, y0: 204.41326841336158, }, series: 6, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 6, display: { y: 0, y0: 218.39108391063536, }, series: 6, }, { x: 946684800000, y: 0.06, index: 20, seriesIndex: 6, display: { y: 0.06, y0: 265.456386301983, }, series: 6, }, { x: 978307200000, y: 61.62000000000001, index: 21, seriesIndex: 6, display: { y: 61.62000000000001, y0: 238.42659853838433, }, series: 6, }, { x: 1009843200000, y: 74.38, index: 22, seriesIndex: 6, display: { y: 74.38, y0: 233.56957120727597, }, series: 6, }, { x: 1041379200000, y: 56.72999999999996, index: 23, seriesIndex: 6, display: { y: 56.72999999999996, y0: 256.8606269568918, }, series: 6, }, { x: 1072915200000, y: 78.09, index: 24, seriesIndex: 6, display: { y: 78.09, y0: 251.61654906702506, }, series: 6, }, { x: 1104537600000, y: 33.90000000000001, index: 25, seriesIndex: 6, display: { y: 33.90000000000001, y0: 306.1171603424089, }, series: 6, }, { x: 1136073600000, y: 5.35, index: 26, seriesIndex: 6, display: { y: 5.35, y0: 315.5883968117778, }, series: 6, }, { x: 1167609600000, y: 3.4299999999999997, index: 27, seriesIndex: 6, display: { y: 3.4299999999999997, y0: 330.51807151274164, }, series: 6, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 6, display: { y: 0, y0: 331.1800000000006, }, series: 6, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 6, display: { y: 0, y0: 323.57657904990293, }, series: 6, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 6, display: { y: 0, y0: 353.63872327506743, }, series: 6, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 6, display: { y: 0, y0: 346.7617397094945, }, series: 6, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 6, display: { y: 0, y0: 355.2033114760125, }, series: 6, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 6, display: { y: 0, y0: 347.01434975261475, }, series: 6, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 6, display: { y: 0, y0: 356.1414727314012, }, series: 6, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 6, display: { y: 0, y0: 352.9817622110564, }, series: 6, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 6, display: { y: 0, y0: 323.31515851727374, }, series: 6, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 6, display: { y: 0, y0: 293.5851585172737, }, series: 6, }, ], }, { key: ['PSP'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 7, display: { y: 0, y0: 312.60127789129933, }, series: 7, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 7, display: { y: 0, y0: 300.40627789129934, }, series: 7, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 7, display: { y: 0, y0: 303.8612778912993, }, series: 7, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 7, display: { y: 0, y0: 319.31574185794614, }, series: 7, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 7, display: { y: 0, y0: 305.40073292228294, }, series: 7, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 7, display: { y: 0, y0: 303.56220029343604, }, series: 7, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 7, display: { y: 0, y0: 311.7174673557506, }, series: 7, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 7, display: { y: 0, y0: 318.02436707976165, }, series: 7, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 7, display: { y: 0, y0: 305.7650172280039, }, series: 7, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 7, display: { y: 0, y0: 272.3260219931503, }, series: 7, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 7, display: { y: 0, y0: 315.774808184687, }, series: 7, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 7, display: { y: 0, y0: 323.71638745865533, }, series: 7, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 7, display: { y: 0, y0: 302.57003766873936, }, series: 7, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 7, display: { y: 0, y0: 331.4305531102357, }, series: 7, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 7, display: { y: 0, y0: 317.05655475227184, }, series: 7, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 7, display: { y: 0, y0: 297.7616336309462, }, series: 7, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 7, display: { y: 0, y0: 247.66008078133538, }, series: 7, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 7, display: { y: 0, y0: 231.76302062609608, }, series: 7, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 7, display: { y: 0, y0: 204.41326841336158, }, series: 7, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 7, display: { y: 0, y0: 218.39108391063536, }, series: 7, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 7, display: { y: 0, y0: 264.466386301983, }, series: 7, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 7, display: { y: 0, y0: 216.18659853838435, }, series: 7, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 7, display: { y: 0, y0: 185.4195712072759, }, series: 7, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 7, display: { y: 0, y0: 201.70062695689174, }, series: 7, }, { x: 1072915200000, y: 7.13, index: 24, seriesIndex: 7, display: { y: 7.13, y0: 178.98654906702507, }, series: 7, }, { x: 1104537600000, y: 44.23000000000001, index: 25, seriesIndex: 7, display: { y: 44.23000000000001, y0: 212.71716034240876, }, series: 7, }, { x: 1136073600000, y: 55.850000000000044, index: 26, seriesIndex: 7, display: { y: 55.850000000000044, y0: 249.58839681177776, }, series: 7, }, { x: 1167609600000, y: 47.48000000000004, index: 27, seriesIndex: 7, display: { y: 47.48000000000004, y0: 282.4880715127416, }, series: 7, }, { x: 1199145600000, y: 34.680000000000035, index: 28, seriesIndex: 7, display: { y: 34.680000000000035, y0: 296.3200000000005, }, series: 7, }, { x: 1230768000000, y: 38.070000000000036, index: 29, seriesIndex: 7, display: { y: 38.070000000000036, y0: 285.5065790499029, }, series: 7, }, { x: 1262304000000, y: 35.11000000000007, index: 30, seriesIndex: 7, display: { y: 35.11000000000007, y0: 318.52872327506736, }, series: 7, }, { x: 1293840000000, y: 17.89000000000001, index: 31, seriesIndex: 7, display: { y: 17.89000000000001, y0: 328.87173970949453, }, series: 7, }, { x: 1325376000000, y: 7.71999999999999, index: 32, seriesIndex: 7, display: { y: 7.71999999999999, y0: 347.48331147601255, }, series: 7, }, { x: 1356998400000, y: 3.189999999999996, index: 33, seriesIndex: 7, display: { y: 3.189999999999996, y0: 343.82434975261475, }, series: 7, }, { x: 1388534400000, y: 0.24000000000000005, index: 34, seriesIndex: 7, display: { y: 0.24000000000000005, y0: 355.9014727314012, }, series: 7, }, { x: 1420070400000, y: 0.12000000000000001, index: 35, seriesIndex: 7, display: { y: 0.12000000000000001, y0: 352.8617622110564, }, series: 7, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 7, display: { y: 0, y0: 323.31515851727374, }, series: 7, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 7, display: { y: 0, y0: 293.5851585172737, }, series: 7, }, ], }, { key: ['PS4'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 8, display: { y: 0, y0: 312.60127789129933, }, series: 8, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 8, display: { y: 0, y0: 300.40627789129934, }, series: 8, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 8, display: { y: 0, y0: 303.8612778912993, }, series: 8, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 8, display: { y: 0, y0: 319.31574185794614, }, series: 8, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 8, display: { y: 0, y0: 305.40073292228294, }, series: 8, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 8, display: { y: 0, y0: 303.5122002934361, }, series: 8, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 8, display: { y: 0, y0: 311.7174673557506, }, series: 8, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 8, display: { y: 0, y0: 318.02436707976165, }, series: 8, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 8, display: { y: 0, y0: 305.7350172280039, }, series: 8, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 8, display: { y: 0, y0: 272.3260219931503, }, series: 8, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 8, display: { y: 0, y0: 315.774808184687, }, series: 8, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 8, display: { y: 0, y0: 323.71638745865533, }, series: 8, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 8, display: { y: 0, y0: 299.5500376687394, }, series: 8, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 8, display: { y: 0, y0: 331.4305531102357, }, series: 8, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 8, display: { y: 0, y0: 304.2065547522718, }, series: 8, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 8, display: { y: 0, y0: 293.5316336309462, }, series: 8, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 8, display: { y: 0, y0: 237.07008078133538, }, series: 8, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 8, display: { y: 0, y0: 220.5030206260961, }, series: 8, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 8, display: { y: 0, y0: 201.13326841336158, }, series: 8, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 8, display: { y: 0, y0: 213.64108391063536, }, series: 8, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 8, display: { y: 0, y0: 259.786386301983, }, series: 8, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 8, display: { y: 0, y0: 210.67659853838435, }, series: 8, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 8, display: { y: 0, y0: 176.8195712072759, }, series: 8, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 8, display: { y: 0, y0: 192.74062695689176, }, series: 8, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 8, display: { y: 0, y0: 151.06654906702508, }, series: 8, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 8, display: { y: 0, y0: 68.52716034240856, }, series: 8, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 8, display: { y: 0, y0: 73.58839681177778, }, series: 8, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 8, display: { y: 0, y0: 27.888071512741476, }, series: 8, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 8, display: { y: 0, y0: 0, }, series: 8, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 8, display: { y: 0, y0: 25.506579049902825, }, series: 8, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 8, display: { y: 0, y0: 35.038723275067355, }, series: 8, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 8, display: { y: 0, y0: 115.55173970949426, }, series: 8, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 8, display: { y: 0, y0: 175.06331147601264, }, series: 8, }, { x: 1356998400000, y: 24.760000000000005, index: 33, seriesIndex: 8, display: { y: 24.760000000000005, y0: 180.13434975261472, }, series: 8, }, { x: 1388534400000, y: 98.76000000000003, index: 34, seriesIndex: 8, display: { y: 98.76000000000003, y0: 170.06147273140124, }, series: 8, }, { x: 1420070400000, y: 115.29999999999997, index: 35, seriesIndex: 8, display: { y: 115.29999999999997, y0: 192.96176221105642, }, series: 8, }, { x: 1451606400000, y: 39.25000000000002, index: 36, seriesIndex: 8, display: { y: 39.25000000000002, y0: 273.94515851727374, }, series: 8, }, { x: 1483228800000, y: 0.03, index: 37, seriesIndex: 8, display: { y: 0.03, y0: 293.55515851727375, }, series: 8, }, ], }, { key: ['PC'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 9, display: { y: 0, y0: 312.60127789129933, }, series: 9, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 9, display: { y: 0, y0: 300.40627789129934, }, series: 9, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 9, display: { y: 0, y0: 303.8612778912993, }, series: 9, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 9, display: { y: 0, y0: 319.31574185794614, }, series: 9, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 9, display: { y: 0, y0: 305.40073292228294, }, series: 9, }, { x: 473385600000, y: 0.03, index: 5, seriesIndex: 9, display: { y: 0.03, y0: 303.5122002934361, }, series: 9, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 9, display: { y: 0, y0: 311.7174673557506, }, series: 9, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 9, display: { y: 0, y0: 318.02436707976165, }, series: 9, }, { x: 567993600000, y: 0.03, index: 8, seriesIndex: 9, display: { y: 0.03, y0: 305.7350172280039, }, series: 9, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 9, display: { y: 0, y0: 272.3260219931503, }, series: 9, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 9, display: { y: 0, y0: 315.774808184687, }, series: 9, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 9, display: { y: 0, y0: 323.71638745865533, }, series: 9, }, { x: 694224000000, y: 3.0199999999999996, index: 12, seriesIndex: 9, display: { y: 3.0199999999999996, y0: 299.5500376687394, }, series: 9, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 9, display: { y: 0, y0: 331.4305531102357, }, series: 9, }, { x: 757382400000, y: 12.85, index: 14, seriesIndex: 9, display: { y: 12.85, y0: 304.2065547522718, }, series: 9, }, { x: 788918400000, y: 4.2299999999999995, index: 15, seriesIndex: 9, display: { y: 4.2299999999999995, y0: 293.5316336309462, }, series: 9, }, { x: 820454400000, y: 10.59, index: 16, seriesIndex: 9, display: { y: 10.59, y0: 237.07008078133538, }, series: 9, }, { x: 852076800000, y: 11.260000000000002, index: 17, seriesIndex: 9, display: { y: 11.260000000000002, y0: 220.5030206260961, }, series: 9, }, { x: 883612800000, y: 3.2800000000000002, index: 18, seriesIndex: 9, display: { y: 3.2800000000000002, y0: 201.13326841336158, }, series: 9, }, { x: 915148800000, y: 4.749999999999999, index: 19, seriesIndex: 9, display: { y: 4.749999999999999, y0: 213.64108391063536, }, series: 9, }, { x: 946684800000, y: 4.679999999999999, index: 20, seriesIndex: 9, display: { y: 4.679999999999999, y0: 259.786386301983, }, series: 9, }, { x: 978307200000, y: 5.51, index: 21, seriesIndex: 9, display: { y: 5.51, y0: 210.67659853838435, }, series: 9, }, { x: 1009843200000, y: 8.599999999999996, index: 22, seriesIndex: 9, display: { y: 8.599999999999996, y0: 176.8195712072759, }, series: 9, }, { x: 1041379200000, y: 8.959999999999988, index: 23, seriesIndex: 9, display: { y: 8.959999999999988, y0: 192.74062695689176, }, series: 9, }, { x: 1072915200000, y: 10.459999999999992, index: 24, seriesIndex: 9, display: { y: 10.459999999999992, y0: 151.06654906702508, }, series: 9, }, { x: 1104537600000, y: 4.469999999999995, index: 25, seriesIndex: 9, display: { y: 4.469999999999995, y0: 68.52716034240856, }, series: 9, }, { x: 1136073600000, y: 2.969999999999998, index: 26, seriesIndex: 9, display: { y: 2.969999999999998, y0: 73.58839681177778, }, series: 9, }, { x: 1167609600000, y: 9.399999999999984, index: 27, seriesIndex: 9, display: { y: 9.399999999999984, y0: 27.888071512741476, }, series: 9, }, { x: 1199145600000, y: 12.669999999999975, index: 28, seriesIndex: 9, display: { y: 12.669999999999975, y0: 0, }, series: 9, }, { x: 1230768000000, y: 17.160000000000043, index: 29, seriesIndex: 9, display: { y: 17.160000000000043, y0: 25.506579049902825, }, series: 9, }, { x: 1262304000000, y: 24.460000000000004, index: 30, seriesIndex: 9, display: { y: 24.460000000000004, y0: 35.038723275067355, }, series: 9, }, { x: 1293840000000, y: 35.250000000000036, index: 31, seriesIndex: 9, display: { y: 35.250000000000036, y0: 120.70173970949426, }, series: 9, }, { x: 1325376000000, y: 23.53, index: 32, seriesIndex: 9, display: { y: 23.53, y0: 211.43331147601265, }, series: 9, }, { x: 1356998400000, y: 12.829999999999995, index: 33, seriesIndex: 9, display: { y: 12.829999999999995, y0: 239.42434975261475, }, series: 9, }, { x: 1388534400000, y: 13.389999999999993, index: 34, seriesIndex: 9, display: { y: 13.389999999999993, y0: 306.0714727314013, }, series: 9, }, { x: 1420070400000, y: 8.069999999999997, index: 35, seriesIndex: 9, display: { y: 8.069999999999997, y0: 331.74176221105637, }, series: 9, }, { x: 1451606400000, y: 2.5999999999999974, index: 36, seriesIndex: 9, display: { y: 2.5999999999999974, y0: 319.88515851727374, }, series: 9, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 9, display: { y: 0, y0: 293.5851585172737, }, series: 9, }, ], }, { key: ['GB'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 10, display: { y: 0, y0: 312.60127789129933, }, series: 10, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 10, display: { y: 0, y0: 300.40627789129934, }, series: 10, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 10, display: { y: 0, y0: 303.8612778912993, }, series: 10, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 10, display: { y: 0, y0: 319.31574185794614, }, series: 10, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 10, display: { y: 0, y0: 305.40073292228294, }, series: 10, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 10, display: { y: 0, y0: 303.56220029343604, }, series: 10, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 10, display: { y: 0, y0: 311.7174673557506, }, series: 10, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 10, display: { y: 0, y0: 318.02436707976165, }, series: 10, }, { x: 567993600000, y: 1.43, index: 8, seriesIndex: 10, display: { y: 1.43, y0: 305.7650172280039, }, series: 10, }, { x: 599616000000, y: 64.98, index: 9, seriesIndex: 10, display: { y: 64.98, y0: 272.3260219931503, }, series: 10, }, { x: 631152000000, y: 4.890000000000001, index: 10, seriesIndex: 10, display: { y: 4.890000000000001, y0: 315.774808184687, }, series: 10, }, { x: 662688000000, y: 5.57, index: 11, seriesIndex: 10, display: { y: 5.57, y0: 323.71638745865533, }, series: 10, }, { x: 694224000000, y: 25.48, index: 12, seriesIndex: 10, display: { y: 25.48, y0: 302.57003766873936, }, series: 10, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 10, display: { y: 0, y0: 333.14055311023566, }, series: 10, }, { x: 757382400000, y: 12.170000000000002, index: 14, seriesIndex: 10, display: { y: 12.170000000000002, y0: 327.9065547522718, }, series: 10, }, { x: 788918400000, y: 3.5999999999999996, index: 15, seriesIndex: 10, display: { y: 3.5999999999999996, y0: 345.8316336309462, }, series: 10, }, { x: 820454400000, y: 36.02, index: 16, seriesIndex: 10, display: { y: 36.02, y0: 350.16008078133535, }, series: 10, }, { x: 852076800000, y: 6.37, index: 17, seriesIndex: 10, display: { y: 6.37, y0: 374.61302062609593, }, series: 10, }, { x: 883612800000, y: 26.9, index: 18, seriesIndex: 10, display: { y: 26.9, y0: 377.8132684133616, }, series: 10, }, { x: 915148800000, y: 38.010000000000005, index: 19, seriesIndex: 10, display: { y: 38.010000000000005, y0: 363.05108391063544, }, series: 10, }, { x: 946684800000, y: 19.759999999999998, index: 20, seriesIndex: 10, display: { y: 19.759999999999998, y0: 361.7963863019829, }, series: 10, }, { x: 978307200000, y: 9.24, index: 21, seriesIndex: 10, display: { y: 9.24, y0: 335.56659853838437, }, series: 10, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 10, display: { y: 0, y0: 314.639571207276, }, series: 10, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 10, display: { y: 0, y0: 315.64062695689177, }, series: 10, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 10, display: { y: 0, y0: 329.7065490670251, }, series: 10, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 10, display: { y: 0, y0: 340.01716034240894, }, series: 10, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 10, display: { y: 0, y0: 320.9383968117778, }, series: 10, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 10, display: { y: 0, y0: 333.94807151274165, }, series: 10, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 10, display: { y: 0, y0: 331.1800000000006, }, series: 10, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 10, display: { y: 0, y0: 323.57657904990293, }, series: 10, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 10, display: { y: 0, y0: 353.63872327506743, }, series: 10, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 10, display: { y: 0, y0: 346.7617397094945, }, series: 10, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 10, display: { y: 0, y0: 355.2033114760125, }, series: 10, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 10, display: { y: 0, y0: 347.01434975261475, }, series: 10, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 10, display: { y: 0, y0: 356.1414727314012, }, series: 10, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 10, display: { y: 0, y0: 352.9817622110564, }, series: 10, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 10, display: { y: 0, y0: 323.31515851727374, }, series: 10, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 10, display: { y: 0, y0: 293.5851585172737, }, series: 10, }, ], }, { key: ['XB'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 11, display: { y: 0, y0: 312.60127789129933, }, series: 11, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 11, display: { y: 0, y0: 300.40627789129934, }, series: 11, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 11, display: { y: 0, y0: 303.8612778912993, }, series: 11, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 11, display: { y: 0, y0: 319.31574185794614, }, series: 11, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 11, display: { y: 0, y0: 305.40073292228294, }, series: 11, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 11, display: { y: 0, y0: 303.56220029343604, }, series: 11, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 11, display: { y: 0, y0: 311.7174673557506, }, series: 11, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 11, display: { y: 0, y0: 318.02436707976165, }, series: 11, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 11, display: { y: 0, y0: 305.7650172280039, }, series: 11, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 11, display: { y: 0, y0: 272.3260219931503, }, series: 11, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 11, display: { y: 0, y0: 315.774808184687, }, series: 11, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 11, display: { y: 0, y0: 323.71638745865533, }, series: 11, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 11, display: { y: 0, y0: 302.57003766873936, }, series: 11, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 11, display: { y: 0, y0: 331.4305531102357, }, series: 11, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 11, display: { y: 0, y0: 317.05655475227184, }, series: 11, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 11, display: { y: 0, y0: 297.7616336309462, }, series: 11, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 11, display: { y: 0, y0: 247.66008078133538, }, series: 11, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 11, display: { y: 0, y0: 231.76302062609608, }, series: 11, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 11, display: { y: 0, y0: 204.41326841336158, }, series: 11, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 11, display: { y: 0, y0: 218.39108391063536, }, series: 11, }, { x: 946684800000, y: 0.99, index: 20, seriesIndex: 11, display: { y: 0.99, y0: 264.466386301983, }, series: 11, }, { x: 978307200000, y: 22.23999999999999, index: 21, seriesIndex: 11, display: { y: 22.23999999999999, y0: 216.18659853838435, }, series: 11, }, { x: 1009843200000, y: 48.15000000000006, index: 22, seriesIndex: 11, display: { y: 48.15000000000006, y0: 185.4195712072759, }, series: 11, }, { x: 1041379200000, y: 55.16000000000003, index: 23, seriesIndex: 11, display: { y: 55.16000000000003, y0: 201.70062695689174, }, series: 11, }, { x: 1072915200000, y: 65.50000000000001, index: 24, seriesIndex: 11, display: { y: 65.50000000000001, y0: 186.11654906702506, }, series: 11, }, { x: 1104537600000, y: 49.17000000000011, index: 25, seriesIndex: 11, display: { y: 49.17000000000011, y0: 256.9471603424088, }, series: 11, }, { x: 1136073600000, y: 10.149999999999991, index: 26, seriesIndex: 11, display: { y: 10.149999999999991, y0: 305.4383968117778, }, series: 11, }, { x: 1167609600000, y: 0.5499999999999999, index: 27, seriesIndex: 11, display: { y: 0.5499999999999999, y0: 329.96807151274163, }, series: 11, }, { x: 1199145600000, y: 0.18, index: 28, seriesIndex: 11, display: { y: 0.18, y0: 331.00000000000057, }, series: 11, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 11, display: { y: 0, y0: 323.57657904990293, }, series: 11, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 11, display: { y: 0, y0: 353.63872327506743, }, series: 11, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 11, display: { y: 0, y0: 346.7617397094945, }, series: 11, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 11, display: { y: 0, y0: 355.2033114760125, }, series: 11, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 11, display: { y: 0, y0: 347.01434975261475, }, series: 11, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 11, display: { y: 0, y0: 356.1414727314012, }, series: 11, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 11, display: { y: 0, y0: 352.9817622110564, }, series: 11, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 11, display: { y: 0, y0: 323.31515851727374, }, series: 11, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 11, display: { y: 0, y0: 293.5851585172737, }, series: 11, }, ], }, { key: ['NES'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 12, display: { y: 0, y0: 323.9812778912993, }, series: 12, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 12, display: { y: 0, y0: 336.1762778912994, }, series: 12, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 12, display: { y: 0, y0: 332.72127789129934, }, series: 12, }, { x: 410227200000, y: 10.959999999999999, index: 3, seriesIndex: 12, display: { y: 10.959999999999999, y0: 325.1457418579461, }, series: 12, }, { x: 441763200000, y: 50.09000000000001, index: 4, seriesIndex: 12, display: { y: 50.09000000000001, y0: 305.6707329222829, }, series: 12, }, { x: 473385600000, y: 53.44, index: 5, seriesIndex: 12, display: { y: 53.44, y0: 304.012200293436, }, series: 12, }, { x: 504921600000, y: 36.410000000000004, index: 6, seriesIndex: 12, display: { y: 36.410000000000004, y0: 312.37746735575064, }, series: 12, }, { x: 536457600000, y: 19.759999999999998, index: 7, seriesIndex: 12, display: { y: 19.759999999999998, y0: 320.00436707976166, }, series: 12, }, { x: 567993600000, y: 45.01, index: 8, seriesIndex: 12, display: { y: 45.01, y0: 307.9450172280039, }, series: 12, }, { x: 599616000000, y: 7.849999999999999, index: 9, seriesIndex: 12, display: { y: 7.849999999999999, y0: 337.9260219931503, }, series: 12, }, { x: 631152000000, y: 15.74, index: 10, seriesIndex: 12, display: { y: 15.74, y0: 320.664808184687, }, series: 12, }, { x: 662688000000, y: 6.11, index: 11, seriesIndex: 12, display: { y: 6.11, y0: 329.2863874586553, }, series: 12, }, { x: 694224000000, y: 1.9800000000000002, index: 12, seriesIndex: 12, display: { y: 1.9800000000000002, y0: 328.0500376687394, }, series: 12, }, { x: 725846400000, y: 3.61, index: 13, seriesIndex: 12, display: { y: 3.61, y0: 333.14055311023566, }, series: 12, }, { x: 757382400000, y: 0.11, index: 14, seriesIndex: 12, display: { y: 0.11, y0: 340.0765547522718, }, series: 12, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 12, display: { y: 0, y0: 349.43163363094624, }, series: 12, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 12, display: { y: 0, y0: 386.18008078133533, }, series: 12, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 12, display: { y: 0, y0: 380.98302062609594, }, series: 12, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 12, display: { y: 0, y0: 404.71326841336156, }, series: 12, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 12, display: { y: 0, y0: 401.06108391063543, }, series: 12, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 12, display: { y: 0, y0: 381.5563863019829, }, series: 12, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 12, display: { y: 0, y0: 344.8065985383844, }, series: 12, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 12, display: { y: 0, y0: 314.639571207276, }, series: 12, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 12, display: { y: 0, y0: 315.64062695689177, }, series: 12, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 12, display: { y: 0, y0: 329.7065490670251, }, series: 12, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 12, display: { y: 0, y0: 340.01716034240894, }, series: 12, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 12, display: { y: 0, y0: 320.9383968117778, }, series: 12, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 12, display: { y: 0, y0: 333.94807151274165, }, series: 12, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 12, display: { y: 0, y0: 331.1800000000006, }, series: 12, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 12, display: { y: 0, y0: 323.57657904990293, }, series: 12, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 12, display: { y: 0, y0: 353.63872327506743, }, series: 12, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 12, display: { y: 0, y0: 346.7617397094945, }, series: 12, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 12, display: { y: 0, y0: 355.2033114760125, }, series: 12, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 12, display: { y: 0, y0: 347.01434975261475, }, series: 12, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 12, display: { y: 0, y0: 356.1414727314012, }, series: 12, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 12, display: { y: 0, y0: 352.9817622110564, }, series: 12, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 12, display: { y: 0, y0: 323.31515851727374, }, series: 12, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 12, display: { y: 0, y0: 293.5851585172737, }, series: 12, }, ], }, { key: ['3DS'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 13, display: { y: 0, y0: 323.9812778912993, }, series: 13, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 13, display: { y: 0, y0: 336.1762778912994, }, series: 13, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 13, display: { y: 0, y0: 332.72127789129934, }, series: 13, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 13, display: { y: 0, y0: 336.1057418579461, }, series: 13, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 13, display: { y: 0, y0: 355.76073292228295, }, series: 13, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 13, display: { y: 0, y0: 357.452200293436, }, series: 13, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 13, display: { y: 0, y0: 348.78746735575066, }, series: 13, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 13, display: { y: 0, y0: 339.76436707976166, }, series: 13, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 13, display: { y: 0, y0: 352.9550172280039, }, series: 13, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 13, display: { y: 0, y0: 345.7760219931503, }, series: 13, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 13, display: { y: 0, y0: 365.16480818468705, }, series: 13, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 13, display: { y: 0, y0: 355.9463874586553, }, series: 13, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 13, display: { y: 0, y0: 375.71003766873946, }, series: 13, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 13, display: { y: 0, y0: 377.41055311023564, }, series: 13, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 13, display: { y: 0, y0: 383.37655475227183, }, series: 13, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 13, display: { y: 0, y0: 381.6416336309462, }, series: 13, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 13, display: { y: 0, y0: 436.22008078133535, }, series: 13, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 13, display: { y: 0, y0: 421.48302062609594, }, series: 13, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 13, display: { y: 0, y0: 457.6032684133616, }, series: 13, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 13, display: { y: 0, y0: 464.9110839106354, }, series: 13, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 13, display: { y: 0, y0: 461.34638630198293, }, series: 13, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 13, display: { y: 0, y0: 542.1465985383844, }, series: 13, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 13, display: { y: 0, y0: 572.3395712072761, }, series: 13, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 13, display: { y: 0, y0: 550.5906269568918, }, series: 13, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 13, display: { y: 0, y0: 570.376549067025, }, series: 13, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 13, display: { y: 0, y0: 528.467160342409, }, series: 13, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 13, display: { y: 0, y0: 594.6283968117779, }, series: 13, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 13, display: { y: 0, y0: 639.0180715127416, }, series: 13, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 13, display: { y: 0, y0: 678.9000000000007, }, series: 13, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 13, display: { y: 0, y0: 692.8065790499031, }, series: 13, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 13, display: { y: 0, y0: 635.4887232750676, }, series: 13, }, { x: 1293840000000, y: 62.53, index: 31, seriesIndex: 13, display: { y: 62.53, y0: 569.0117397094947, }, series: 13, }, { x: 1325376000000, y: 51.14000000000004, index: 32, seriesIndex: 13, display: { y: 51.14000000000004, y0: 487.4633114760125, }, series: 13, }, { x: 1356998400000, y: 55.88000000000002, index: 33, seriesIndex: 13, display: { y: 55.88000000000002, y0: 473.7643497526147, }, series: 13, }, { x: 1388534400000, y: 43.140000000000036, index: 34, seriesIndex: 13, display: { y: 43.140000000000036, y0: 411.54147273140126, }, series: 13, }, { x: 1420070400000, y: 26.99, index: 35, seriesIndex: 13, display: { y: 26.99, y0: 372.7517622110564, }, series: 13, }, { x: 1451606400000, y: 6.599999999999999, index: 36, seriesIndex: 13, display: { y: 6.599999999999999, y0: 325.9051585172737, }, series: 13, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 13, display: { y: 0, y0: 293.5851585172737, }, series: 13, }, ], }, { key: ['N64'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 14, display: { y: 0, y0: 323.9812778912993, }, series: 14, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 14, display: { y: 0, y0: 336.1762778912994, }, series: 14, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 14, display: { y: 0, y0: 332.72127789129934, }, series: 14, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 14, display: { y: 0, y0: 336.1057418579461, }, series: 14, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 14, display: { y: 0, y0: 355.76073292228295, }, series: 14, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 14, display: { y: 0, y0: 357.452200293436, }, series: 14, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 14, display: { y: 0, y0: 348.78746735575066, }, series: 14, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 14, display: { y: 0, y0: 339.76436707976166, }, series: 14, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 14, display: { y: 0, y0: 352.9550172280039, }, series: 14, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 14, display: { y: 0, y0: 345.7760219931503, }, series: 14, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 14, display: { y: 0, y0: 365.16480818468705, }, series: 14, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 14, display: { y: 0, y0: 355.9463874586553, }, series: 14, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 14, display: { y: 0, y0: 375.71003766873946, }, series: 14, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 14, display: { y: 0, y0: 377.41055311023564, }, series: 14, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 14, display: { y: 0, y0: 383.37655475227183, }, series: 14, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 14, display: { y: 0, y0: 381.6416336309462, }, series: 14, }, { x: 820454400000, y: 34.10999999999999, index: 16, seriesIndex: 14, display: { y: 34.10999999999999, y0: 402.11008078133534, }, series: 14, }, { x: 852076800000, y: 39.509999999999984, index: 17, seriesIndex: 14, display: { y: 39.509999999999984, y0: 381.97302062609594, }, series: 14, }, { x: 883612800000, y: 49.28000000000002, index: 18, seriesIndex: 14, display: { y: 49.28000000000002, y0: 404.9332684133616, }, series: 14, }, { x: 915148800000, y: 57.95999999999997, index: 19, seriesIndex: 14, display: { y: 57.95999999999997, y0: 401.3210839106354, }, series: 14, }, { x: 946684800000, y: 34.00999999999999, index: 20, seriesIndex: 14, display: { y: 34.00999999999999, y0: 381.5563863019829, }, series: 14, }, { x: 978307200000, y: 3.2600000000000002, index: 21, seriesIndex: 14, display: { y: 3.2600000000000002, y0: 344.8065985383844, }, series: 14, }, { x: 1009843200000, y: 0.08, index: 22, seriesIndex: 14, display: { y: 0.08, y0: 314.639571207276, }, series: 14, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 14, display: { y: 0, y0: 315.64062695689177, }, series: 14, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 14, display: { y: 0, y0: 329.7065490670251, }, series: 14, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 14, display: { y: 0, y0: 340.01716034240894, }, series: 14, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 14, display: { y: 0, y0: 320.9383968117778, }, series: 14, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 14, display: { y: 0, y0: 333.94807151274165, }, series: 14, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 14, display: { y: 0, y0: 331.1800000000006, }, series: 14, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 14, display: { y: 0, y0: 323.57657904990293, }, series: 14, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 14, display: { y: 0, y0: 353.63872327506743, }, series: 14, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 14, display: { y: 0, y0: 346.7617397094945, }, series: 14, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 14, display: { y: 0, y0: 355.2033114760125, }, series: 14, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 14, display: { y: 0, y0: 347.01434975261475, }, series: 14, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 14, display: { y: 0, y0: 356.1414727314012, }, series: 14, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 14, display: { y: 0, y0: 352.9817622110564, }, series: 14, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 14, display: { y: 0, y0: 323.31515851727374, }, series: 14, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 14, display: { y: 0, y0: 293.5851585172737, }, series: 14, }, ], }, { key: ['SNES'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 15, display: { y: 0, y0: 323.9812778912993, }, series: 15, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 15, display: { y: 0, y0: 336.1762778912994, }, series: 15, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 15, display: { y: 0, y0: 332.72127789129934, }, series: 15, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 15, display: { y: 0, y0: 336.1057418579461, }, series: 15, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 15, display: { y: 0, y0: 355.76073292228295, }, series: 15, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 15, display: { y: 0, y0: 357.452200293436, }, series: 15, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 15, display: { y: 0, y0: 348.78746735575066, }, series: 15, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 15, display: { y: 0, y0: 339.76436707976166, }, series: 15, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 15, display: { y: 0, y0: 352.9550172280039, }, series: 15, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 15, display: { y: 0, y0: 345.7760219931503, }, series: 15, }, { x: 631152000000, y: 26.16, index: 10, seriesIndex: 15, display: { y: 26.16, y0: 339.004808184687, }, series: 15, }, { x: 662688000000, y: 16.21, index: 11, seriesIndex: 15, display: { y: 16.21, y0: 339.7363874586553, }, series: 15, }, { x: 694224000000, y: 32.97999999999999, index: 12, seriesIndex: 15, display: { y: 32.97999999999999, y0: 342.73003766873944, }, series: 15, }, { x: 725846400000, y: 40.010000000000005, index: 13, seriesIndex: 15, display: { y: 40.010000000000005, y0: 337.40055311023565, }, series: 15, }, { x: 757382400000, y: 35.08, index: 14, seriesIndex: 15, display: { y: 35.08, y0: 348.29655475227185, }, series: 15, }, { x: 788918400000, y: 32.21000000000001, index: 15, seriesIndex: 15, display: { y: 32.21000000000001, y0: 349.43163363094624, }, series: 15, }, { x: 820454400000, y: 15.929999999999996, index: 16, seriesIndex: 15, display: { y: 15.929999999999996, y0: 386.18008078133533, }, series: 15, }, { x: 852076800000, y: 0.99, index: 17, seriesIndex: 15, display: { y: 0.99, y0: 380.98302062609594, }, series: 15, }, { x: 883612800000, y: 0.22000000000000003, index: 18, seriesIndex: 15, display: { y: 0.22000000000000003, y0: 404.71326841336156, }, series: 15, }, { x: 915148800000, y: 0.26, index: 19, seriesIndex: 15, display: { y: 0.26, y0: 401.06108391063543, }, series: 15, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 15, display: { y: 0, y0: 381.5563863019829, }, series: 15, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 15, display: { y: 0, y0: 344.8065985383844, }, series: 15, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 15, display: { y: 0, y0: 314.639571207276, }, series: 15, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 15, display: { y: 0, y0: 315.64062695689177, }, series: 15, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 15, display: { y: 0, y0: 329.7065490670251, }, series: 15, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 15, display: { y: 0, y0: 340.01716034240894, }, series: 15, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 15, display: { y: 0, y0: 320.9383968117778, }, series: 15, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 15, display: { y: 0, y0: 333.94807151274165, }, series: 15, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 15, display: { y: 0, y0: 331.1800000000006, }, series: 15, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 15, display: { y: 0, y0: 323.57657904990293, }, series: 15, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 15, display: { y: 0, y0: 353.63872327506743, }, series: 15, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 15, display: { y: 0, y0: 346.7617397094945, }, series: 15, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 15, display: { y: 0, y0: 355.2033114760125, }, series: 15, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 15, display: { y: 0, y0: 347.01434975261475, }, series: 15, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 15, display: { y: 0, y0: 356.1414727314012, }, series: 15, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 15, display: { y: 0, y0: 352.9817622110564, }, series: 15, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 15, display: { y: 0, y0: 323.31515851727374, }, series: 15, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 15, display: { y: 0, y0: 293.5851585172737, }, series: 15, }, ], }, { key: ['GC'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 16, display: { y: 0, y0: 323.9812778912993, }, series: 16, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 16, display: { y: 0, y0: 336.1762778912994, }, series: 16, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 16, display: { y: 0, y0: 332.72127789129934, }, series: 16, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 16, display: { y: 0, y0: 336.1057418579461, }, series: 16, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 16, display: { y: 0, y0: 355.76073292228295, }, series: 16, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 16, display: { y: 0, y0: 357.452200293436, }, series: 16, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 16, display: { y: 0, y0: 348.78746735575066, }, series: 16, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 16, display: { y: 0, y0: 339.76436707976166, }, series: 16, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 16, display: { y: 0, y0: 352.9550172280039, }, series: 16, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 16, display: { y: 0, y0: 345.7760219931503, }, series: 16, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 16, display: { y: 0, y0: 365.16480818468705, }, series: 16, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 16, display: { y: 0, y0: 355.9463874586553, }, series: 16, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 16, display: { y: 0, y0: 375.71003766873946, }, series: 16, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 16, display: { y: 0, y0: 377.41055311023564, }, series: 16, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 16, display: { y: 0, y0: 383.37655475227183, }, series: 16, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 16, display: { y: 0, y0: 381.6416336309462, }, series: 16, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 16, display: { y: 0, y0: 436.22008078133535, }, series: 16, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 16, display: { y: 0, y0: 421.48302062609594, }, series: 16, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 16, display: { y: 0, y0: 457.6032684133616, }, series: 16, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 16, display: { y: 0, y0: 464.9110839106354, }, series: 16, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 16, display: { y: 0, y0: 422.2363863019829, }, series: 16, }, { x: 978307200000, y: 26.299999999999997, index: 21, seriesIndex: 16, display: { y: 26.299999999999997, y0: 349.41659853838433, }, series: 16, }, { x: 1009843200000, y: 51.93, index: 22, seriesIndex: 16, display: { y: 51.93, y0: 315.009571207276, }, series: 16, }, { x: 1041379200000, y: 50.660000000000004, index: 23, seriesIndex: 16, display: { y: 50.660000000000004, y0: 315.64062695689177, }, series: 16, }, { x: 1072915200000, y: 28.889999999999983, index: 24, seriesIndex: 16, display: { y: 28.889999999999983, y0: 329.7065490670251, }, series: 16, }, { x: 1104537600000, y: 27.799999999999976, index: 25, seriesIndex: 16, display: { y: 27.799999999999976, y0: 340.01716034240894, }, series: 16, }, { x: 1136073600000, y: 11.29, index: 26, seriesIndex: 16, display: { y: 11.29, y0: 320.9383968117778, }, series: 16, }, { x: 1167609600000, y: 0.27, index: 27, seriesIndex: 16, display: { y: 0.27, y0: 333.96807151274163, }, series: 16, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 16, display: { y: 0, y0: 331.2200000000006, }, series: 16, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 16, display: { y: 0, y0: 323.57657904990293, }, series: 16, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 16, display: { y: 0, y0: 353.63872327506743, }, series: 16, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 16, display: { y: 0, y0: 346.7617397094945, }, series: 16, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 16, display: { y: 0, y0: 355.2033114760125, }, series: 16, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 16, display: { y: 0, y0: 347.01434975261475, }, series: 16, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 16, display: { y: 0, y0: 356.1414727314012, }, series: 16, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 16, display: { y: 0, y0: 352.9817622110564, }, series: 16, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 16, display: { y: 0, y0: 323.31515851727374, }, series: 16, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 16, display: { y: 0, y0: 293.5851585172737, }, series: 16, }, ], }, { key: ['XOne'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 17, display: { y: 0, y0: 323.9812778912993, }, series: 17, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 17, display: { y: 0, y0: 336.1762778912994, }, series: 17, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 17, display: { y: 0, y0: 332.72127789129934, }, series: 17, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 17, display: { y: 0, y0: 336.1057418579461, }, series: 17, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 17, display: { y: 0, y0: 355.76073292228295, }, series: 17, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 17, display: { y: 0, y0: 357.452200293436, }, series: 17, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 17, display: { y: 0, y0: 348.78746735575066, }, series: 17, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 17, display: { y: 0, y0: 339.76436707976166, }, series: 17, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 17, display: { y: 0, y0: 352.9550172280039, }, series: 17, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 17, display: { y: 0, y0: 345.7760219931503, }, series: 17, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 17, display: { y: 0, y0: 365.16480818468705, }, series: 17, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 17, display: { y: 0, y0: 355.9463874586553, }, series: 17, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 17, display: { y: 0, y0: 375.71003766873946, }, series: 17, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 17, display: { y: 0, y0: 377.41055311023564, }, series: 17, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 17, display: { y: 0, y0: 383.37655475227183, }, series: 17, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 17, display: { y: 0, y0: 381.6416336309462, }, series: 17, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 17, display: { y: 0, y0: 436.22008078133535, }, series: 17, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 17, display: { y: 0, y0: 421.48302062609594, }, series: 17, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 17, display: { y: 0, y0: 457.6032684133616, }, series: 17, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 17, display: { y: 0, y0: 464.9110839106354, }, series: 17, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 17, display: { y: 0, y0: 461.34638630198293, }, series: 17, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 17, display: { y: 0, y0: 542.1465985383844, }, series: 17, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 17, display: { y: 0, y0: 572.3395712072761, }, series: 17, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 17, display: { y: 0, y0: 550.5906269568918, }, series: 17, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 17, display: { y: 0, y0: 570.376549067025, }, series: 17, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 17, display: { y: 0, y0: 528.467160342409, }, series: 17, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 17, display: { y: 0, y0: 594.6283968117779, }, series: 17, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 17, display: { y: 0, y0: 639.0180715127416, }, series: 17, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 17, display: { y: 0, y0: 678.9000000000007, }, series: 17, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 17, display: { y: 0, y0: 692.8065790499031, }, series: 17, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 17, display: { y: 0, y0: 635.4887232750676, }, series: 17, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 17, display: { y: 0, y0: 631.5417397094947, }, series: 17, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 17, display: { y: 0, y0: 538.6033114760125, }, series: 17, }, { x: 1356998400000, y: 18.599999999999998, index: 33, seriesIndex: 17, display: { y: 18.599999999999998, y0: 529.6443497526147, }, series: 17, }, { x: 1388534400000, y: 52.43, index: 34, seriesIndex: 17, display: { y: 52.43, y0: 454.6814727314013, }, series: 17, }, { x: 1420070400000, y: 57.660000000000025, index: 35, seriesIndex: 17, display: { y: 57.660000000000025, y0: 399.7417622110564, }, series: 17, }, { x: 1451606400000, y: 12.369999999999987, index: 36, seriesIndex: 17, display: { y: 12.369999999999987, y0: 332.50515851727374, }, series: 17, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 17, display: { y: 0, y0: 293.5851585172737, }, series: 17, }, ], }, { key: ['2600'], values: [ { x: 315532800000, y: 11.379999999999999, index: 0, seriesIndex: 18, display: { y: 11.379999999999999, y0: 312.60127789129933, }, series: 18, }, { x: 347155200000, y: 35.77000000000001, index: 1, seriesIndex: 18, display: { y: 35.77000000000001, y0: 300.40627789129934, }, series: 18, }, { x: 378691200000, y: 28.859999999999996, index: 2, seriesIndex: 18, display: { y: 28.859999999999996, y0: 303.8612778912993, }, series: 18, }, { x: 410227200000, y: 5.83, index: 3, seriesIndex: 18, display: { y: 5.83, y0: 319.31574185794614, }, series: 18, }, { x: 441763200000, y: 0.27, index: 4, seriesIndex: 18, display: { y: 0.27, y0: 305.40073292228294, }, series: 18, }, { x: 473385600000, y: 0.45, index: 5, seriesIndex: 18, display: { y: 0.45, y0: 303.56220029343604, }, series: 18, }, { x: 504921600000, y: 0.6599999999999999, index: 6, seriesIndex: 18, display: { y: 0.6599999999999999, y0: 311.7174673557506, }, series: 18, }, { x: 536457600000, y: 1.9800000000000002, index: 7, seriesIndex: 18, display: { y: 1.9800000000000002, y0: 318.02436707976165, }, series: 18, }, { x: 567993600000, y: 0.75, index: 8, seriesIndex: 18, display: { y: 0.75, y0: 307.1950172280039, }, series: 18, }, { x: 599616000000, y: 0.62, index: 9, seriesIndex: 18, display: { y: 0.62, y0: 337.3060219931503, }, series: 18, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 18, display: { y: 0, y0: 320.664808184687, }, series: 18, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 18, display: { y: 0, y0: 329.2863874586553, }, series: 18, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 18, display: { y: 0, y0: 328.0500376687394, }, series: 18, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 18, display: { y: 0, y0: 333.14055311023566, }, series: 18, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 18, display: { y: 0, y0: 340.0765547522718, }, series: 18, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 18, display: { y: 0, y0: 349.43163363094624, }, series: 18, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 18, display: { y: 0, y0: 386.18008078133533, }, series: 18, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 18, display: { y: 0, y0: 380.98302062609594, }, series: 18, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 18, display: { y: 0, y0: 404.71326841336156, }, series: 18, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 18, display: { y: 0, y0: 401.06108391063543, }, series: 18, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 18, display: { y: 0, y0: 381.5563863019829, }, series: 18, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 18, display: { y: 0, y0: 344.8065985383844, }, series: 18, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 18, display: { y: 0, y0: 314.639571207276, }, series: 18, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 18, display: { y: 0, y0: 315.64062695689177, }, series: 18, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 18, display: { y: 0, y0: 329.7065490670251, }, series: 18, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 18, display: { y: 0, y0: 340.01716034240894, }, series: 18, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 18, display: { y: 0, y0: 320.9383968117778, }, series: 18, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 18, display: { y: 0, y0: 333.94807151274165, }, series: 18, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 18, display: { y: 0, y0: 331.1800000000006, }, series: 18, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 18, display: { y: 0, y0: 323.57657904990293, }, series: 18, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 18, display: { y: 0, y0: 353.63872327506743, }, series: 18, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 18, display: { y: 0, y0: 346.7617397094945, }, series: 18, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 18, display: { y: 0, y0: 355.2033114760125, }, series: 18, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 18, display: { y: 0, y0: 347.01434975261475, }, series: 18, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 18, display: { y: 0, y0: 356.1414727314012, }, series: 18, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 18, display: { y: 0, y0: 352.9817622110564, }, series: 18, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 18, display: { y: 0, y0: 323.31515851727374, }, series: 18, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 18, display: { y: 0, y0: 293.5851585172737, }, series: 18, }, ], }, { key: ['WiiU'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 19, display: { y: 0, y0: 312.60127789129933, }, series: 19, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 19, display: { y: 0, y0: 300.40627789129934, }, series: 19, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 19, display: { y: 0, y0: 303.8612778912993, }, series: 19, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 19, display: { y: 0, y0: 319.31574185794614, }, series: 19, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 19, display: { y: 0, y0: 305.40073292228294, }, series: 19, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 19, display: { y: 0, y0: 303.5122002934361, }, series: 19, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 19, display: { y: 0, y0: 311.7174673557506, }, series: 19, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 19, display: { y: 0, y0: 318.02436707976165, }, series: 19, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 19, display: { y: 0, y0: 305.7350172280039, }, series: 19, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 19, display: { y: 0, y0: 272.3260219931503, }, series: 19, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 19, display: { y: 0, y0: 315.774808184687, }, series: 19, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 19, display: { y: 0, y0: 323.71638745865533, }, series: 19, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 19, display: { y: 0, y0: 299.5500376687394, }, series: 19, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 19, display: { y: 0, y0: 331.4305531102357, }, series: 19, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 19, display: { y: 0, y0: 304.2065547522718, }, series: 19, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 19, display: { y: 0, y0: 293.5316336309462, }, series: 19, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 19, display: { y: 0, y0: 237.07008078133538, }, series: 19, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 19, display: { y: 0, y0: 220.5030206260961, }, series: 19, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 19, display: { y: 0, y0: 201.13326841336158, }, series: 19, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 19, display: { y: 0, y0: 213.64108391063536, }, series: 19, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 19, display: { y: 0, y0: 259.786386301983, }, series: 19, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 19, display: { y: 0, y0: 210.67659853838435, }, series: 19, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 19, display: { y: 0, y0: 176.8195712072759, }, series: 19, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 19, display: { y: 0, y0: 192.74062695689176, }, series: 19, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 19, display: { y: 0, y0: 151.06654906702508, }, series: 19, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 19, display: { y: 0, y0: 68.52716034240856, }, series: 19, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 19, display: { y: 0, y0: 73.58839681177778, }, series: 19, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 19, display: { y: 0, y0: 27.888071512741476, }, series: 19, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 19, display: { y: 0, y0: 0, }, series: 19, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 19, display: { y: 0, y0: 25.506579049902825, }, series: 19, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 19, display: { y: 0, y0: 35.038723275067355, }, series: 19, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 19, display: { y: 0, y0: 115.55173970949426, }, series: 19, }, { x: 1325376000000, y: 17.840000000000003, index: 32, seriesIndex: 19, display: { y: 17.840000000000003, y0: 175.06331147601264, }, series: 19, }, { x: 1356998400000, y: 21.84, index: 33, seriesIndex: 19, display: { y: 21.84, y0: 204.89434975261474, }, series: 19, }, { x: 1388534400000, y: 22.509999999999994, index: 34, seriesIndex: 19, display: { y: 22.509999999999994, y0: 268.8214727314013, }, series: 19, }, { x: 1420070400000, y: 16.380000000000003, index: 35, seriesIndex: 19, display: { y: 16.380000000000003, y0: 308.2617622110564, }, series: 19, }, { x: 1451606400000, y: 3.2899999999999996, index: 36, seriesIndex: 19, display: { y: 3.2899999999999996, y0: 313.19515851727374, }, series: 19, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 19, display: { y: 0, y0: 293.5851585172737, }, series: 19, }, ], }, { key: ['PSV'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 20, display: { y: 0, y0: 312.60127789129933, }, series: 20, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 20, display: { y: 0, y0: 300.40627789129934, }, series: 20, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 20, display: { y: 0, y0: 303.8612778912993, }, series: 20, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 20, display: { y: 0, y0: 319.31574185794614, }, series: 20, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 20, display: { y: 0, y0: 305.40073292228294, }, series: 20, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 20, display: { y: 0, y0: 303.5122002934361, }, series: 20, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 20, display: { y: 0, y0: 311.7174673557506, }, series: 20, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 20, display: { y: 0, y0: 318.02436707976165, }, series: 20, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 20, display: { y: 0, y0: 305.7350172280039, }, series: 20, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 20, display: { y: 0, y0: 272.3260219931503, }, series: 20, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 20, display: { y: 0, y0: 315.774808184687, }, series: 20, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 20, display: { y: 0, y0: 323.71638745865533, }, series: 20, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 20, display: { y: 0, y0: 299.5500376687394, }, series: 20, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 20, display: { y: 0, y0: 331.4305531102357, }, series: 20, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 20, display: { y: 0, y0: 304.2065547522718, }, series: 20, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 20, display: { y: 0, y0: 293.5316336309462, }, series: 20, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 20, display: { y: 0, y0: 237.07008078133538, }, series: 20, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 20, display: { y: 0, y0: 220.5030206260961, }, series: 20, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 20, display: { y: 0, y0: 201.13326841336158, }, series: 20, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 20, display: { y: 0, y0: 213.64108391063536, }, series: 20, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 20, display: { y: 0, y0: 259.786386301983, }, series: 20, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 20, display: { y: 0, y0: 210.67659853838435, }, series: 20, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 20, display: { y: 0, y0: 176.8195712072759, }, series: 20, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 20, display: { y: 0, y0: 192.74062695689176, }, series: 20, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 20, display: { y: 0, y0: 151.06654906702508, }, series: 20, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 20, display: { y: 0, y0: 68.52716034240856, }, series: 20, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 20, display: { y: 0, y0: 73.58839681177778, }, series: 20, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 20, display: { y: 0, y0: 27.888071512741476, }, series: 20, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 20, display: { y: 0, y0: 0, }, series: 20, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 20, display: { y: 0, y0: 25.506579049902825, }, series: 20, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 20, display: { y: 0, y0: 35.038723275067355, }, series: 20, }, { x: 1293840000000, y: 5.1499999999999995, index: 31, seriesIndex: 20, display: { y: 5.1499999999999995, y0: 115.55173970949426, }, series: 20, }, { x: 1325376000000, y: 18.530000000000005, index: 32, seriesIndex: 20, display: { y: 18.530000000000005, y0: 192.90331147601265, }, series: 20, }, { x: 1356998400000, y: 12.690000000000001, index: 33, seriesIndex: 20, display: { y: 12.690000000000001, y0: 226.73434975261475, }, series: 20, }, { x: 1388534400000, y: 14.73999999999999, index: 34, seriesIndex: 20, display: { y: 14.73999999999999, y0: 291.3314727314013, }, series: 20, }, { x: 1420070400000, y: 7.09999999999999, index: 35, seriesIndex: 20, display: { y: 7.09999999999999, y0: 324.6417622110564, }, series: 20, }, { x: 1451606400000, y: 3.399999999999996, index: 36, seriesIndex: 20, display: { y: 3.399999999999996, y0: 316.48515851727376, }, series: 20, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 20, display: { y: 0, y0: 293.5851585172737, }, series: 20, }, ], }, { key: ['SAT'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 21, display: { y: 0, y0: 312.60127789129933, }, series: 21, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 21, display: { y: 0, y0: 300.40627789129934, }, series: 21, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 21, display: { y: 0, y0: 303.8612778912993, }, series: 21, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 21, display: { y: 0, y0: 319.31574185794614, }, series: 21, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 21, display: { y: 0, y0: 305.40073292228294, }, series: 21, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 21, display: { y: 0, y0: 303.56220029343604, }, series: 21, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 21, display: { y: 0, y0: 311.7174673557506, }, series: 21, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 21, display: { y: 0, y0: 318.02436707976165, }, series: 21, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 21, display: { y: 0, y0: 305.7650172280039, }, series: 21, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 21, display: { y: 0, y0: 272.3260219931503, }, series: 21, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 21, display: { y: 0, y0: 315.774808184687, }, series: 21, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 21, display: { y: 0, y0: 323.71638745865533, }, series: 21, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 21, display: { y: 0, y0: 302.57003766873936, }, series: 21, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 21, display: { y: 0, y0: 331.4305531102357, }, series: 21, }, { x: 757382400000, y: 3.6400000000000006, index: 14, seriesIndex: 21, display: { y: 3.6400000000000006, y0: 323.0965547522718, }, series: 21, }, { x: 788918400000, y: 11.579999999999998, index: 15, seriesIndex: 21, display: { y: 11.579999999999998, y0: 333.92163363094625, }, series: 21, }, { x: 820454400000, y: 7.69, index: 16, seriesIndex: 21, display: { y: 7.69, y0: 342.37008078133533, }, series: 21, }, { x: 852076800000, y: 6.7700000000000005, index: 17, seriesIndex: 21, display: { y: 6.7700000000000005, y0: 367.84302062609595, }, series: 21, }, { x: 883612800000, y: 3.819999999999999, index: 18, seriesIndex: 21, display: { y: 3.819999999999999, y0: 373.9932684133616, }, series: 21, }, { x: 915148800000, y: 0.09, index: 19, seriesIndex: 21, display: { y: 0.09, y0: 362.96108391063547, }, series: 21, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 21, display: { y: 0, y0: 361.7963863019829, }, series: 21, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 21, display: { y: 0, y0: 335.56659853838437, }, series: 21, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 21, display: { y: 0, y0: 314.639571207276, }, series: 21, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 21, display: { y: 0, y0: 315.64062695689177, }, series: 21, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 21, display: { y: 0, y0: 329.7065490670251, }, series: 21, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 21, display: { y: 0, y0: 340.01716034240894, }, series: 21, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 21, display: { y: 0, y0: 320.9383968117778, }, series: 21, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 21, display: { y: 0, y0: 333.94807151274165, }, series: 21, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 21, display: { y: 0, y0: 331.1800000000006, }, series: 21, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 21, display: { y: 0, y0: 323.57657904990293, }, series: 21, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 21, display: { y: 0, y0: 353.63872327506743, }, series: 21, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 21, display: { y: 0, y0: 346.7617397094945, }, series: 21, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 21, display: { y: 0, y0: 355.2033114760125, }, series: 21, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 21, display: { y: 0, y0: 347.01434975261475, }, series: 21, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 21, display: { y: 0, y0: 356.1414727314012, }, series: 21, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 21, display: { y: 0, y0: 352.9817622110564, }, series: 21, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 21, display: { y: 0, y0: 323.31515851727374, }, series: 21, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 21, display: { y: 0, y0: 293.5851585172737, }, series: 21, }, ], }, { key: ['GEN'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 22, display: { y: 0, y0: 323.9812778912993, }, series: 22, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 22, display: { y: 0, y0: 336.1762778912994, }, series: 22, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 22, display: { y: 0, y0: 332.72127789129934, }, series: 22, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 22, display: { y: 0, y0: 336.1057418579461, }, series: 22, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 22, display: { y: 0, y0: 355.76073292228295, }, series: 22, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 22, display: { y: 0, y0: 357.452200293436, }, series: 22, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 22, display: { y: 0, y0: 348.78746735575066, }, series: 22, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 22, display: { y: 0, y0: 339.76436707976166, }, series: 22, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 22, display: { y: 0, y0: 352.9550172280039, }, series: 22, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 22, display: { y: 0, y0: 345.7760219931503, }, series: 22, }, { x: 631152000000, y: 2.6, index: 10, seriesIndex: 22, display: { y: 2.6, y0: 336.404808184687, }, series: 22, }, { x: 662688000000, y: 4.34, index: 11, seriesIndex: 22, display: { y: 4.34, y0: 335.39638745865534, }, series: 22, }, { x: 694224000000, y: 12.66, index: 12, seriesIndex: 22, display: { y: 12.66, y0: 330.0300376687394, }, series: 22, }, { x: 725846400000, y: 0.6500000000000001, index: 13, seriesIndex: 22, display: { y: 0.6500000000000001, y0: 336.75055311023567, }, series: 22, }, { x: 757382400000, y: 8.109999999999998, index: 14, seriesIndex: 22, display: { y: 8.109999999999998, y0: 340.18655475227183, }, series: 22, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 22, display: { y: 0, y0: 349.43163363094624, }, series: 22, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 22, display: { y: 0, y0: 386.18008078133533, }, series: 22, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 22, display: { y: 0, y0: 380.98302062609594, }, series: 22, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 22, display: { y: 0, y0: 404.71326841336156, }, series: 22, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 22, display: { y: 0, y0: 401.06108391063543, }, series: 22, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 22, display: { y: 0, y0: 381.5563863019829, }, series: 22, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 22, display: { y: 0, y0: 344.8065985383844, }, series: 22, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 22, display: { y: 0, y0: 314.639571207276, }, series: 22, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 22, display: { y: 0, y0: 315.64062695689177, }, series: 22, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 22, display: { y: 0, y0: 329.7065490670251, }, series: 22, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 22, display: { y: 0, y0: 340.01716034240894, }, series: 22, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 22, display: { y: 0, y0: 320.9383968117778, }, series: 22, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 22, display: { y: 0, y0: 333.94807151274165, }, series: 22, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 22, display: { y: 0, y0: 331.1800000000006, }, series: 22, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 22, display: { y: 0, y0: 323.57657904990293, }, series: 22, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 22, display: { y: 0, y0: 353.63872327506743, }, series: 22, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 22, display: { y: 0, y0: 346.7617397094945, }, series: 22, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 22, display: { y: 0, y0: 355.2033114760125, }, series: 22, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 22, display: { y: 0, y0: 347.01434975261475, }, series: 22, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 22, display: { y: 0, y0: 356.1414727314012, }, series: 22, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 22, display: { y: 0, y0: 352.9817622110564, }, series: 22, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 22, display: { y: 0, y0: 323.31515851727374, }, series: 22, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 22, display: { y: 0, y0: 293.5851585172737, }, series: 22, }, ], }, { key: ['DC'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 23, display: { y: 0, y0: 323.9812778912993, }, series: 23, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 23, display: { y: 0, y0: 336.1762778912994, }, series: 23, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 23, display: { y: 0, y0: 332.72127789129934, }, series: 23, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 23, display: { y: 0, y0: 336.1057418579461, }, series: 23, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 23, display: { y: 0, y0: 355.76073292228295, }, series: 23, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 23, display: { y: 0, y0: 357.452200293436, }, series: 23, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 23, display: { y: 0, y0: 348.78746735575066, }, series: 23, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 23, display: { y: 0, y0: 339.76436707976166, }, series: 23, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 23, display: { y: 0, y0: 352.9550172280039, }, series: 23, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 23, display: { y: 0, y0: 345.7760219931503, }, series: 23, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 23, display: { y: 0, y0: 365.16480818468705, }, series: 23, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 23, display: { y: 0, y0: 355.9463874586553, }, series: 23, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 23, display: { y: 0, y0: 375.71003766873946, }, series: 23, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 23, display: { y: 0, y0: 377.41055311023564, }, series: 23, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 23, display: { y: 0, y0: 383.37655475227183, }, series: 23, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 23, display: { y: 0, y0: 381.6416336309462, }, series: 23, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 23, display: { y: 0, y0: 436.22008078133535, }, series: 23, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 23, display: { y: 0, y0: 421.48302062609594, }, series: 23, }, { x: 883612800000, y: 3.39, index: 18, seriesIndex: 23, display: { y: 3.39, y0: 454.2132684133616, }, series: 23, }, { x: 915148800000, y: 5.169999999999999, index: 19, seriesIndex: 23, display: { y: 5.169999999999999, y0: 459.2810839106354, }, series: 23, }, { x: 946684800000, y: 5.989999999999998, index: 20, seriesIndex: 23, display: { y: 5.989999999999998, y0: 415.5663863019829, }, series: 23, }, { x: 978307200000, y: 1.07, index: 21, seriesIndex: 23, display: { y: 1.07, y0: 348.06659853838437, }, series: 23, }, { x: 1009843200000, y: 0.29, index: 22, seriesIndex: 23, display: { y: 0.29, y0: 314.719571207276, }, series: 23, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 23, display: { y: 0, y0: 315.64062695689177, }, series: 23, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 23, display: { y: 0, y0: 329.7065490670251, }, series: 23, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 23, display: { y: 0, y0: 340.01716034240894, }, series: 23, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 23, display: { y: 0, y0: 320.9383968117778, }, series: 23, }, { x: 1167609600000, y: 0.02, index: 27, seriesIndex: 23, display: { y: 0.02, y0: 333.94807151274165, }, series: 23, }, { x: 1199145600000, y: 0.04, index: 28, seriesIndex: 23, display: { y: 0.04, y0: 331.1800000000006, }, series: 23, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 23, display: { y: 0, y0: 323.57657904990293, }, series: 23, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 23, display: { y: 0, y0: 353.63872327506743, }, series: 23, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 23, display: { y: 0, y0: 346.7617397094945, }, series: 23, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 23, display: { y: 0, y0: 355.2033114760125, }, series: 23, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 23, display: { y: 0, y0: 347.01434975261475, }, series: 23, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 23, display: { y: 0, y0: 356.1414727314012, }, series: 23, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 23, display: { y: 0, y0: 352.9817622110564, }, series: 23, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 23, display: { y: 0, y0: 323.31515851727374, }, series: 23, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 23, display: { y: 0, y0: 293.5851585172737, }, series: 23, }, ], }, { key: ['SCD'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 24, display: { y: 0, y0: 312.60127789129933, }, series: 24, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 24, display: { y: 0, y0: 300.40627789129934, }, series: 24, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 24, display: { y: 0, y0: 303.8612778912993, }, series: 24, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 24, display: { y: 0, y0: 319.31574185794614, }, series: 24, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 24, display: { y: 0, y0: 305.40073292228294, }, series: 24, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 24, display: { y: 0, y0: 303.56220029343604, }, series: 24, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 24, display: { y: 0, y0: 311.7174673557506, }, series: 24, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 24, display: { y: 0, y0: 318.02436707976165, }, series: 24, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 24, display: { y: 0, y0: 305.7650172280039, }, series: 24, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 24, display: { y: 0, y0: 272.3260219931503, }, series: 24, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 24, display: { y: 0, y0: 315.774808184687, }, series: 24, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 24, display: { y: 0, y0: 323.71638745865533, }, series: 24, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 24, display: { y: 0, y0: 302.57003766873936, }, series: 24, }, { x: 725846400000, y: 1.5, index: 13, seriesIndex: 24, display: { y: 1.5, y0: 331.64055311023566, }, series: 24, }, { x: 757382400000, y: 0.37, index: 14, seriesIndex: 24, display: { y: 0.37, y0: 327.5365547522718, }, series: 24, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 24, display: { y: 0, y0: 345.8316336309462, }, series: 24, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 24, display: { y: 0, y0: 350.16008078133535, }, series: 24, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 24, display: { y: 0, y0: 374.61302062609593, }, series: 24, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 24, display: { y: 0, y0: 377.8132684133616, }, series: 24, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 24, display: { y: 0, y0: 363.05108391063544, }, series: 24, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 24, display: { y: 0, y0: 361.7963863019829, }, series: 24, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 24, display: { y: 0, y0: 335.56659853838437, }, series: 24, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 24, display: { y: 0, y0: 314.639571207276, }, series: 24, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 24, display: { y: 0, y0: 315.64062695689177, }, series: 24, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 24, display: { y: 0, y0: 329.7065490670251, }, series: 24, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 24, display: { y: 0, y0: 340.01716034240894, }, series: 24, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 24, display: { y: 0, y0: 320.9383968117778, }, series: 24, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 24, display: { y: 0, y0: 333.94807151274165, }, series: 24, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 24, display: { y: 0, y0: 331.1800000000006, }, series: 24, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 24, display: { y: 0, y0: 323.57657904990293, }, series: 24, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 24, display: { y: 0, y0: 353.63872327506743, }, series: 24, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 24, display: { y: 0, y0: 346.7617397094945, }, series: 24, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 24, display: { y: 0, y0: 355.2033114760125, }, series: 24, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 24, display: { y: 0, y0: 347.01434975261475, }, series: 24, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 24, display: { y: 0, y0: 356.1414727314012, }, series: 24, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 24, display: { y: 0, y0: 352.9817622110564, }, series: 24, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 24, display: { y: 0, y0: 323.31515851727374, }, series: 24, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 24, display: { y: 0, y0: 293.5851585172737, }, series: 24, }, ], }, { key: ['NG'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 25, display: { y: 0, y0: 312.60127789129933, }, series: 25, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 25, display: { y: 0, y0: 300.40627789129934, }, series: 25, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 25, display: { y: 0, y0: 303.8612778912993, }, series: 25, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 25, display: { y: 0, y0: 319.31574185794614, }, series: 25, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 25, display: { y: 0, y0: 305.40073292228294, }, series: 25, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 25, display: { y: 0, y0: 303.56220029343604, }, series: 25, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 25, display: { y: 0, y0: 311.7174673557506, }, series: 25, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 25, display: { y: 0, y0: 318.02436707976165, }, series: 25, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 25, display: { y: 0, y0: 305.7650172280039, }, series: 25, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 25, display: { y: 0, y0: 272.3260219931503, }, series: 25, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 25, display: { y: 0, y0: 315.774808184687, }, series: 25, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 25, display: { y: 0, y0: 323.71638745865533, }, series: 25, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 25, display: { y: 0, y0: 302.57003766873936, }, series: 25, }, { x: 725846400000, y: 0.21000000000000002, index: 13, seriesIndex: 25, display: { y: 0.21000000000000002, y0: 331.4305531102357, }, series: 25, }, { x: 757382400000, y: 0.7999999999999999, index: 14, seriesIndex: 25, display: { y: 0.7999999999999999, y0: 326.7365547522718, }, series: 25, }, { x: 788918400000, y: 0.33000000000000007, index: 15, seriesIndex: 25, display: { y: 0.33000000000000007, y0: 345.50163363094623, }, series: 25, }, { x: 820454400000, y: 0.1, index: 16, seriesIndex: 25, display: { y: 0.1, y0: 350.06008078133533, }, series: 25, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 25, display: { y: 0, y0: 374.61302062609593, }, series: 25, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 25, display: { y: 0, y0: 377.8132684133616, }, series: 25, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 25, display: { y: 0, y0: 363.05108391063544, }, series: 25, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 25, display: { y: 0, y0: 361.7963863019829, }, series: 25, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 25, display: { y: 0, y0: 335.56659853838437, }, series: 25, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 25, display: { y: 0, y0: 314.639571207276, }, series: 25, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 25, display: { y: 0, y0: 315.64062695689177, }, series: 25, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 25, display: { y: 0, y0: 329.7065490670251, }, series: 25, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 25, display: { y: 0, y0: 340.01716034240894, }, series: 25, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 25, display: { y: 0, y0: 320.9383968117778, }, series: 25, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 25, display: { y: 0, y0: 333.94807151274165, }, series: 25, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 25, display: { y: 0, y0: 331.1800000000006, }, series: 25, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 25, display: { y: 0, y0: 323.57657904990293, }, series: 25, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 25, display: { y: 0, y0: 353.63872327506743, }, series: 25, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 25, display: { y: 0, y0: 346.7617397094945, }, series: 25, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 25, display: { y: 0, y0: 355.2033114760125, }, series: 25, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 25, display: { y: 0, y0: 347.01434975261475, }, series: 25, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 25, display: { y: 0, y0: 356.1414727314012, }, series: 25, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 25, display: { y: 0, y0: 352.9817622110564, }, series: 25, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 25, display: { y: 0, y0: 323.31515851727374, }, series: 25, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 25, display: { y: 0, y0: 293.5851585172737, }, series: 25, }, ], }, { key: ['WS'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 26, display: { y: 0, y0: 323.9812778912993, }, series: 26, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 26, display: { y: 0, y0: 336.1762778912994, }, series: 26, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 26, display: { y: 0, y0: 332.72127789129934, }, series: 26, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 26, display: { y: 0, y0: 336.1057418579461, }, series: 26, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 26, display: { y: 0, y0: 355.76073292228295, }, series: 26, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 26, display: { y: 0, y0: 357.452200293436, }, series: 26, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 26, display: { y: 0, y0: 348.78746735575066, }, series: 26, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 26, display: { y: 0, y0: 339.76436707976166, }, series: 26, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 26, display: { y: 0, y0: 352.9550172280039, }, series: 26, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 26, display: { y: 0, y0: 345.7760219931503, }, series: 26, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 26, display: { y: 0, y0: 365.16480818468705, }, series: 26, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 26, display: { y: 0, y0: 355.9463874586553, }, series: 26, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 26, display: { y: 0, y0: 375.71003766873946, }, series: 26, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 26, display: { y: 0, y0: 377.41055311023564, }, series: 26, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 26, display: { y: 0, y0: 383.37655475227183, }, series: 26, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 26, display: { y: 0, y0: 381.6416336309462, }, series: 26, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 26, display: { y: 0, y0: 436.22008078133535, }, series: 26, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 26, display: { y: 0, y0: 421.48302062609594, }, series: 26, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 26, display: { y: 0, y0: 457.6032684133616, }, series: 26, }, { x: 915148800000, y: 0.46, index: 19, seriesIndex: 26, display: { y: 0.46, y0: 464.4510839106354, }, series: 26, }, { x: 946684800000, y: 0.68, index: 20, seriesIndex: 26, display: { y: 0.68, y0: 421.5563863019829, }, series: 26, }, { x: 978307200000, y: 0.28, index: 21, seriesIndex: 26, display: { y: 0.28, y0: 349.13659853838436, }, series: 26, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 26, display: { y: 0, y0: 315.009571207276, }, series: 26, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 26, display: { y: 0, y0: 315.64062695689177, }, series: 26, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 26, display: { y: 0, y0: 329.7065490670251, }, series: 26, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 26, display: { y: 0, y0: 340.01716034240894, }, series: 26, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 26, display: { y: 0, y0: 320.9383968117778, }, series: 26, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 26, display: { y: 0, y0: 333.96807151274163, }, series: 26, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 26, display: { y: 0, y0: 331.2200000000006, }, series: 26, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 26, display: { y: 0, y0: 323.57657904990293, }, series: 26, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 26, display: { y: 0, y0: 353.63872327506743, }, series: 26, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 26, display: { y: 0, y0: 346.7617397094945, }, series: 26, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 26, display: { y: 0, y0: 355.2033114760125, }, series: 26, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 26, display: { y: 0, y0: 347.01434975261475, }, series: 26, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 26, display: { y: 0, y0: 356.1414727314012, }, series: 26, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 26, display: { y: 0, y0: 352.9817622110564, }, series: 26, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 26, display: { y: 0, y0: 323.31515851727374, }, series: 26, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 26, display: { y: 0, y0: 293.5851585172737, }, series: 26, }, ], }, { key: ['TG16'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 27, display: { y: 0, y0: 312.60127789129933, }, series: 27, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 27, display: { y: 0, y0: 300.40627789129934, }, series: 27, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 27, display: { y: 0, y0: 303.8612778912993, }, series: 27, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 27, display: { y: 0, y0: 319.31574185794614, }, series: 27, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 27, display: { y: 0, y0: 305.40073292228294, }, series: 27, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 27, display: { y: 0, y0: 303.56220029343604, }, series: 27, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 27, display: { y: 0, y0: 311.7174673557506, }, series: 27, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 27, display: { y: 0, y0: 318.02436707976165, }, series: 27, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 27, display: { y: 0, y0: 305.7650172280039, }, series: 27, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 27, display: { y: 0, y0: 272.3260219931503, }, series: 27, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 27, display: { y: 0, y0: 315.774808184687, }, series: 27, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 27, display: { y: 0, y0: 323.71638745865533, }, series: 27, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 27, display: { y: 0, y0: 302.57003766873936, }, series: 27, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 27, display: { y: 0, y0: 331.4305531102357, }, series: 27, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 27, display: { y: 0, y0: 323.0965547522718, }, series: 27, }, { x: 788918400000, y: 0.16, index: 15, seriesIndex: 27, display: { y: 0.16, y0: 333.7616336309462, }, series: 27, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 27, display: { y: 0, y0: 342.37008078133533, }, series: 27, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 27, display: { y: 0, y0: 367.84302062609595, }, series: 27, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 27, display: { y: 0, y0: 373.9932684133616, }, series: 27, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 27, display: { y: 0, y0: 362.96108391063547, }, series: 27, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 27, display: { y: 0, y0: 361.7963863019829, }, series: 27, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 27, display: { y: 0, y0: 335.56659853838437, }, series: 27, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 27, display: { y: 0, y0: 314.639571207276, }, series: 27, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 27, display: { y: 0, y0: 315.64062695689177, }, series: 27, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 27, display: { y: 0, y0: 329.7065490670251, }, series: 27, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 27, display: { y: 0, y0: 340.01716034240894, }, series: 27, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 27, display: { y: 0, y0: 320.9383968117778, }, series: 27, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 27, display: { y: 0, y0: 333.94807151274165, }, series: 27, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 27, display: { y: 0, y0: 331.1800000000006, }, series: 27, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 27, display: { y: 0, y0: 323.57657904990293, }, series: 27, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 27, display: { y: 0, y0: 353.63872327506743, }, series: 27, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 27, display: { y: 0, y0: 346.7617397094945, }, series: 27, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 27, display: { y: 0, y0: 355.2033114760125, }, series: 27, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 27, display: { y: 0, y0: 347.01434975261475, }, series: 27, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 27, display: { y: 0, y0: 356.1414727314012, }, series: 27, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 27, display: { y: 0, y0: 352.9817622110564, }, series: 27, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 27, display: { y: 0, y0: 323.31515851727374, }, series: 27, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 27, display: { y: 0, y0: 293.5851585172737, }, series: 27, }, ], }, { key: ['3DO'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 28, display: { y: 0, y0: 312.60127789129933, }, series: 28, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 28, display: { y: 0, y0: 300.40627789129934, }, series: 28, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 28, display: { y: 0, y0: 303.8612778912993, }, series: 28, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 28, display: { y: 0, y0: 319.31574185794614, }, series: 28, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 28, display: { y: 0, y0: 305.40073292228294, }, series: 28, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 28, display: { y: 0, y0: 303.56220029343604, }, series: 28, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 28, display: { y: 0, y0: 311.7174673557506, }, series: 28, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 28, display: { y: 0, y0: 318.02436707976165, }, series: 28, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 28, display: { y: 0, y0: 305.7650172280039, }, series: 28, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 28, display: { y: 0, y0: 272.3260219931503, }, series: 28, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 28, display: { y: 0, y0: 315.774808184687, }, series: 28, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 28, display: { y: 0, y0: 323.71638745865533, }, series: 28, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 28, display: { y: 0, y0: 302.57003766873936, }, series: 28, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 28, display: { y: 0, y0: 331.4305531102357, }, series: 28, }, { x: 757382400000, y: 0.02, index: 14, seriesIndex: 28, display: { y: 0.02, y0: 323.0765547522718, }, series: 28, }, { x: 788918400000, y: 0.08, index: 15, seriesIndex: 28, display: { y: 0.08, y0: 333.68163363094624, }, series: 28, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 28, display: { y: 0, y0: 342.37008078133533, }, series: 28, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 28, display: { y: 0, y0: 367.84302062609595, }, series: 28, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 28, display: { y: 0, y0: 373.9932684133616, }, series: 28, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 28, display: { y: 0, y0: 362.96108391063547, }, series: 28, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 28, display: { y: 0, y0: 361.7963863019829, }, series: 28, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 28, display: { y: 0, y0: 335.56659853838437, }, series: 28, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 28, display: { y: 0, y0: 314.639571207276, }, series: 28, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 28, display: { y: 0, y0: 315.64062695689177, }, series: 28, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 28, display: { y: 0, y0: 329.7065490670251, }, series: 28, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 28, display: { y: 0, y0: 340.01716034240894, }, series: 28, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 28, display: { y: 0, y0: 320.9383968117778, }, series: 28, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 28, display: { y: 0, y0: 333.94807151274165, }, series: 28, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 28, display: { y: 0, y0: 331.1800000000006, }, series: 28, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 28, display: { y: 0, y0: 323.57657904990293, }, series: 28, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 28, display: { y: 0, y0: 353.63872327506743, }, series: 28, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 28, display: { y: 0, y0: 346.7617397094945, }, series: 28, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 28, display: { y: 0, y0: 355.2033114760125, }, series: 28, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 28, display: { y: 0, y0: 347.01434975261475, }, series: 28, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 28, display: { y: 0, y0: 356.1414727314012, }, series: 28, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 28, display: { y: 0, y0: 352.9817622110564, }, series: 28, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 28, display: { y: 0, y0: 323.31515851727374, }, series: 28, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 28, display: { y: 0, y0: 293.5851585172737, }, series: 28, }, ], }, { key: ['GG'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 29, display: { y: 0, y0: 323.9812778912993, }, series: 29, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 29, display: { y: 0, y0: 336.1762778912994, }, series: 29, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 29, display: { y: 0, y0: 332.72127789129934, }, series: 29, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 29, display: { y: 0, y0: 336.1057418579461, }, series: 29, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 29, display: { y: 0, y0: 355.76073292228295, }, series: 29, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 29, display: { y: 0, y0: 357.452200293436, }, series: 29, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 29, display: { y: 0, y0: 348.78746735575066, }, series: 29, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 29, display: { y: 0, y0: 339.76436707976166, }, series: 29, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 29, display: { y: 0, y0: 352.9550172280039, }, series: 29, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 29, display: { y: 0, y0: 345.7760219931503, }, series: 29, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 29, display: { y: 0, y0: 339.004808184687, }, series: 29, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 29, display: { y: 0, y0: 339.7363874586553, }, series: 29, }, { x: 694224000000, y: 0.04, index: 12, seriesIndex: 29, display: { y: 0.04, y0: 342.6900376687394, }, series: 29, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 29, display: { y: 0, y0: 337.40055311023565, }, series: 29, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 29, display: { y: 0, y0: 348.29655475227185, }, series: 29, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 29, display: { y: 0, y0: 349.43163363094624, }, series: 29, }, { x: 820454400000, y: 0, index: 16, seriesIndex: 29, display: { y: 0, y0: 386.18008078133533, }, series: 29, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 29, display: { y: 0, y0: 380.98302062609594, }, series: 29, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 29, display: { y: 0, y0: 404.71326841336156, }, series: 29, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 29, display: { y: 0, y0: 401.06108391063543, }, series: 29, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 29, display: { y: 0, y0: 381.5563863019829, }, series: 29, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 29, display: { y: 0, y0: 344.8065985383844, }, series: 29, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 29, display: { y: 0, y0: 314.639571207276, }, series: 29, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 29, display: { y: 0, y0: 315.64062695689177, }, series: 29, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 29, display: { y: 0, y0: 329.7065490670251, }, series: 29, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 29, display: { y: 0, y0: 340.01716034240894, }, series: 29, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 29, display: { y: 0, y0: 320.9383968117778, }, series: 29, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 29, display: { y: 0, y0: 333.94807151274165, }, series: 29, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 29, display: { y: 0, y0: 331.1800000000006, }, series: 29, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 29, display: { y: 0, y0: 323.57657904990293, }, series: 29, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 29, display: { y: 0, y0: 353.63872327506743, }, series: 29, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 29, display: { y: 0, y0: 346.7617397094945, }, series: 29, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 29, display: { y: 0, y0: 355.2033114760125, }, series: 29, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 29, display: { y: 0, y0: 347.01434975261475, }, series: 29, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 29, display: { y: 0, y0: 356.1414727314012, }, series: 29, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 29, display: { y: 0, y0: 352.9817622110564, }, series: 29, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 29, display: { y: 0, y0: 323.31515851727374, }, series: 29, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 29, display: { y: 0, y0: 293.5851585172737, }, series: 29, }, ], }, { key: ['PCFX'], values: [ { x: 315532800000, y: 0, index: 0, seriesIndex: 30, display: { y: 0, y0: 312.60127789129933, }, series: 30, }, { x: 347155200000, y: 0, index: 1, seriesIndex: 30, display: { y: 0, y0: 300.40627789129934, }, series: 30, }, { x: 378691200000, y: 0, index: 2, seriesIndex: 30, display: { y: 0, y0: 303.8612778912993, }, series: 30, }, { x: 410227200000, y: 0, index: 3, seriesIndex: 30, display: { y: 0, y0: 319.31574185794614, }, series: 30, }, { x: 441763200000, y: 0, index: 4, seriesIndex: 30, display: { y: 0, y0: 305.40073292228294, }, series: 30, }, { x: 473385600000, y: 0, index: 5, seriesIndex: 30, display: { y: 0, y0: 303.56220029343604, }, series: 30, }, { x: 504921600000, y: 0, index: 6, seriesIndex: 30, display: { y: 0, y0: 311.7174673557506, }, series: 30, }, { x: 536457600000, y: 0, index: 7, seriesIndex: 30, display: { y: 0, y0: 318.02436707976165, }, series: 30, }, { x: 567993600000, y: 0, index: 8, seriesIndex: 30, display: { y: 0, y0: 305.7650172280039, }, series: 30, }, { x: 599616000000, y: 0, index: 9, seriesIndex: 30, display: { y: 0, y0: 272.3260219931503, }, series: 30, }, { x: 631152000000, y: 0, index: 10, seriesIndex: 30, display: { y: 0, y0: 315.774808184687, }, series: 30, }, { x: 662688000000, y: 0, index: 11, seriesIndex: 30, display: { y: 0, y0: 323.71638745865533, }, series: 30, }, { x: 694224000000, y: 0, index: 12, seriesIndex: 30, display: { y: 0, y0: 302.57003766873936, }, series: 30, }, { x: 725846400000, y: 0, index: 13, seriesIndex: 30, display: { y: 0, y0: 331.4305531102357, }, series: 30, }, { x: 757382400000, y: 0, index: 14, seriesIndex: 30, display: { y: 0, y0: 323.0765547522718, }, series: 30, }, { x: 788918400000, y: 0, index: 15, seriesIndex: 30, display: { y: 0, y0: 333.68163363094624, }, series: 30, }, { x: 820454400000, y: 0.03, index: 16, seriesIndex: 30, display: { y: 0.03, y0: 342.34008078133536, }, series: 30, }, { x: 852076800000, y: 0, index: 17, seriesIndex: 30, display: { y: 0, y0: 367.84302062609595, }, series: 30, }, { x: 883612800000, y: 0, index: 18, seriesIndex: 30, display: { y: 0, y0: 373.9932684133616, }, series: 30, }, { x: 915148800000, y: 0, index: 19, seriesIndex: 30, display: { y: 0, y0: 362.96108391063547, }, series: 30, }, { x: 946684800000, y: 0, index: 20, seriesIndex: 30, display: { y: 0, y0: 361.7963863019829, }, series: 30, }, { x: 978307200000, y: 0, index: 21, seriesIndex: 30, display: { y: 0, y0: 335.56659853838437, }, series: 30, }, { x: 1009843200000, y: 0, index: 22, seriesIndex: 30, display: { y: 0, y0: 314.639571207276, }, series: 30, }, { x: 1041379200000, y: 0, index: 23, seriesIndex: 30, display: { y: 0, y0: 315.64062695689177, }, series: 30, }, { x: 1072915200000, y: 0, index: 24, seriesIndex: 30, display: { y: 0, y0: 329.7065490670251, }, series: 30, }, { x: 1104537600000, y: 0, index: 25, seriesIndex: 30, display: { y: 0, y0: 340.01716034240894, }, series: 30, }, { x: 1136073600000, y: 0, index: 26, seriesIndex: 30, display: { y: 0, y0: 320.9383968117778, }, series: 30, }, { x: 1167609600000, y: 0, index: 27, seriesIndex: 30, display: { y: 0, y0: 333.94807151274165, }, series: 30, }, { x: 1199145600000, y: 0, index: 28, seriesIndex: 30, display: { y: 0, y0: 331.1800000000006, }, series: 30, }, { x: 1230768000000, y: 0, index: 29, seriesIndex: 30, display: { y: 0, y0: 323.57657904990293, }, series: 30, }, { x: 1262304000000, y: 0, index: 30, seriesIndex: 30, display: { y: 0, y0: 353.63872327506743, }, series: 30, }, { x: 1293840000000, y: 0, index: 31, seriesIndex: 30, display: { y: 0, y0: 346.7617397094945, }, series: 30, }, { x: 1325376000000, y: 0, index: 32, seriesIndex: 30, display: { y: 0, y0: 355.2033114760125, }, series: 30, }, { x: 1356998400000, y: 0, index: 33, seriesIndex: 30, display: { y: 0, y0: 347.01434975261475, }, series: 30, }, { x: 1388534400000, y: 0, index: 34, seriesIndex: 30, display: { y: 0, y0: 356.1414727314012, }, series: 30, }, { x: 1420070400000, y: 0, index: 35, seriesIndex: 30, display: { y: 0, y0: 352.9817622110564, }, series: 30, }, { x: 1451606400000, y: 0, index: 36, seriesIndex: 30, display: { y: 0, y0: 323.31515851727374, }, series: 30, }, { x: 1483228800000, y: 0, index: 37, seriesIndex: 30, display: { y: 0, y0: 293.5851585172737, }, series: 30, }, ], }, ], applied_filters: [], rejected_filters: [], }, ], triggerQuery: false, lastRendered: 0, form_data: { datasource: '20__table', viz_type: 'area', slice_id: 103, url_params: { preselect_filters: '{"1389": {"platform": ["PS", "PS2", "PS3", "PS4"], "genre": null, "__time_range": "No filter"}}', }, granularity_sqla: 'year', time_grain_sqla: null, time_range: 'No filter', metrics: [ { aggregate: 'SUM', column: { column_name: 'global_sales', description: null, expression: null, filterable: true, groupby: true, id: 887, is_dttm: false, optionName: '_col_Global_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: false, isNew: false, label: 'SUM(Global_Sales)', optionName: 'metric_ufl75addr8c_oqqhdumirpn', sqlExpression: null, }, ], adhoc_filters: [], groupby: ['platform'], order_desc: true, contribution: false, row_limit: null, show_brush: 'auto', show_legend: false, line_interpolation: 'linear', stacked_style: 'stream', color_scheme: 'supersetColors', rich_tooltip: true, x_axis_label: 'Year Published', bottom_margin: 'auto', x_ticks_layout: 'auto', x_axis_format: 'smart_date', x_axis_showminmax: true, y_axis_format: 'SMART_NUMBER', y_axis_bounds: [null, null], rolling_type: 'None', comparison_type: 'values', annotation_layers: [], label_colors: { '0': '#1FA8C9', '1': '#454E7C', '2600': '#666666', '3DO': '#B2B2B2', '3DS': '#D1C6BC', Action: '#1FA8C9', Adventure: '#454E7C', DC: '#A38F79', DS: '#8FD3E4', Europe: '#5AC189', Fighting: '#5AC189', GB: '#FDE380', GBA: '#ACE1C4', GC: '#5AC189', GEN: '#3CCCCB', GG: '#EFA1AA', Japan: '#FF7F44', 'Microsoft Game Studios': '#D1C6BC', Misc: '#FF7F44', N64: '#1FA8C9', NES: '#9EE5E5', NG: '#A1A6BD', Nintendo: '#D3B3DA', 'North America': '#666666', Other: '#E04355', PC: '#EFA1AA', PCFX: '#FDE380', PS: '#A1A6BD', PS2: '#FCC700', PS3: '#3CCCCB', PS4: '#B2B2B2', PSP: '#FEC0A1', PSV: '#FCC700', Platform: '#666666', Puzzle: '#E04355', Racing: '#FCC700', 'Role-Playing': '#A868B7', SAT: '#A868B7', SCD: '#8FD3E4', SNES: '#454E7C', Shooter: '#3CCCCB', Simulation: '#A38F79', Sports: '#8FD3E4', Strategy: '#A1A6BD', TG16: '#FEC0A1', 'Take-Two Interactive': '#9EE5E5', WS: '#ACE1C4', Wii: '#A38F79', WiiU: '#E04355', X360: '#A868B7', XB: '#D3B3DA', XOne: '#FF7F44', }, queryFields: { groupby: 'groupby', metrics: 'metrics', }, }, }, '113': { id: 113, chartAlert: null, chartStatus: 'rendered', chartStackTrace: null, chartUpdateEndTime: 1673047001005, chartUpdateStartTime: 1673046994648, latestQueryFormData: { datasource: '20__table', viz_type: 'dist_bar', slice_id: 113, url_params: {}, granularity_sqla: 'year', time_range: 'No filter', metrics: [ { aggregate: 'SUM', column: { column_name: 'na_sales', description: null, expression: null, filterable: true, groupby: true, id: 883, is_dttm: false, optionName: '_col_NA_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: true, isNew: false, label: 'North America', optionName: 'metric_a943v7wg5g_0mm03hrsmpf', sqlExpression: null, }, { aggregate: 'SUM', column: { column_name: 'eu_sales', description: null, expression: null, filterable: true, groupby: true, id: 884, is_dttm: false, optionName: '_col_EU_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: true, isNew: false, label: 'Europe', optionName: 'metric_bibau54x0rb_dwrjtqkbyso', sqlExpression: null, }, { aggregate: 'SUM', column: { column_name: 'jp_sales', description: null, expression: null, filterable: true, groupby: true, id: 885, is_dttm: false, optionName: '_col_JP_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: true, isNew: false, label: 'Japan', optionName: 'metric_06whpr2oyhw_4l88xxu6zvd', sqlExpression: null, }, { aggregate: 'SUM', column: { column_name: 'other_sales', description: null, expression: null, filterable: true, groupby: true, id: 886, is_dttm: false, optionName: '_col_Other_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: true, isNew: false, label: 'Other', optionName: 'metric_pcx05ioxums_ibr16zvi74', sqlExpression: null, }, ], adhoc_filters: [ { clause: 'WHERE', comparator: '10', expressionType: 'SIMPLE', filterOptionName: 'filter_juemdnqji5_d6fm8tuf4rc', isExtra: false, isNew: false, operator: '<=', sqlExpression: null, subject: 'rank', }, ], groupby: ['name'], columns: [], row_limit: null, order_desc: true, contribution: true, color_scheme: 'supersetColors', show_legend: true, rich_tooltip: true, bar_stacked: true, y_axis_format: 'SMART_NUMBER', y_axis_bounds: [null, null], bottom_margin: 'auto', x_ticks_layout: 'staggered', queryFields: { columns: 'groupby', groupby: 'groupby', metrics: 'metrics', }, shared_label_colors: {}, extra_filters: [ { col: '__time_range', op: '==', val: 'No filter', }, ], extra_form_data: {}, dashboardId: 9, }, sliceFormData: null, queryController: {}, queriesResponse: [ { cache_key: '420a73a7c686ce86838126ba14e5c69a', cached_dttm: null, cache_timeout: 86400, errors: [], form_data: { datasource: '20__table', viz_type: 'dist_bar', slice_id: 113, url_params: {}, granularity_sqla: 'year', time_range: 'No filter', metrics: [ { aggregate: 'SUM', column: { column_name: 'na_sales', description: null, expression: null, filterable: true, groupby: true, id: 883, is_dttm: false, optionName: '_col_NA_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: true, isNew: false, label: 'North America', optionName: 'metric_a943v7wg5g_0mm03hrsmpf', sqlExpression: null, }, { aggregate: 'SUM', column: { column_name: 'eu_sales', description: null, expression: null, filterable: true, groupby: true, id: 884, is_dttm: false, optionName: '_col_EU_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: true, isNew: false, label: 'Europe', optionName: 'metric_bibau54x0rb_dwrjtqkbyso', sqlExpression: null, }, { aggregate: 'SUM', column: { column_name: 'jp_sales', description: null, expression: null, filterable: true, groupby: true, id: 885, is_dttm: false, optionName: '_col_JP_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: true, isNew: false, label: 'Japan', optionName: 'metric_06whpr2oyhw_4l88xxu6zvd', sqlExpression: null, }, { aggregate: 'SUM', column: { column_name: 'other_sales', description: null, expression: null, filterable: true, groupby: true, id: 886, is_dttm: false, optionName: '_col_Other_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: true, isNew: false, label: 'Other', optionName: 'metric_pcx05ioxums_ibr16zvi74', sqlExpression: null, }, ], adhoc_filters: [ { clause: 'WHERE', comparator: '10', expressionType: 'SIMPLE', filterOptionName: 'filter_juemdnqji5_d6fm8tuf4rc', isExtra: false, isNew: false, operator: '<=', sqlExpression: null, subject: 'rank', }, ], groupby: ['name'], columns: [], row_limit: null, order_desc: true, contribution: true, color_scheme: 'supersetColors', show_legend: true, rich_tooltip: true, bar_stacked: true, y_axis_format: 'SMART_NUMBER', y_axis_bounds: [null, null], bottom_margin: 'auto', x_ticks_layout: 'staggered', queryFields: { columns: 'groupby', groupby: 'groupby', metrics: 'metrics', }, shared_label_colors: {}, dashboardId: 9, applied_time_extras: {}, where: '', having: '', filters: [ { col: 'rank', op: '<=', val: '10', }, ], }, is_cached: false, query: 'SELECT name AS name,\n sum(na_sales) AS "North America",\n sum(eu_sales) AS "Europe",\n sum(jp_sales) AS "Japan",\n sum(other_sales) AS "Other"\nFROM main.video_game_sales\nWHERE rank <= 10\nGROUP BY name\nORDER BY "North America" DESC\nLIMIT 50000\nOFFSET 0', from_dttm: null, to_dttm: null, status: 'success', stacktrace: null, rowcount: 10, colnames: ['name', 'North America', 'Europe', 'Japan', 'Other'], coltypes: [1, 0, 0, 0, 0], data: [ { key: 'North America', values: [ { x: 'Wii Sports', y: 0.5014503263234228, y0: 0, series: 0, key: 'North America', size: 0.5014503263234228, y1: 0.5014503263234228, }, { x: 'Super Mario Bros.', y: 0.7226640159045725, y0: 0, series: 0, key: 'North America', size: 0.7226640159045725, y1: 0.7226640159045725, }, { x: 'Duck Hunt', y: 0.9512539738608266, y0: 0, series: 0, key: 'North America', size: 0.9512539738608266, y1: 0.9512539738608266, }, { x: 'Tetris', y: 0.7666886979510906, y0: 0, series: 0, key: 'North America', size: 0.7666886979510906, y1: 0.7666886979510906, }, { x: 'Mario Kart Wii', y: 0.44236673178900354, y0: 0, series: 0, key: 'North America', size: 0.44236673178900354, y1: 0.44236673178900354, }, { x: 'Wii Sports Resort', y: 0.4772727272727273, y0: 0, series: 0, key: 'North America', size: 0.4772727272727273, y1: 0.4772727272727273, }, { x: 'New Super Mario Bros. Wii', y: 0.5099615519049283, y0: 0, series: 0, key: 'North America', size: 0.5099615519049283, y1: 0.5099615519049283, }, { x: 'Wii Play', y: 0.4836263357462944, y0: 0, series: 0, key: 'North America', size: 0.4836263357462944, y1: 0.4836263357462944, }, { x: 'New Super Mario Bros.', y: 0.3792069310229924, y0: 0, series: 0, key: 'North America', size: 0.3792069310229924, y1: 0.3792069310229924, }, { x: 'Pokemon Red/Pokemon Blue', y: 0.3591459528362014, y0: 0, series: 0, key: 'North America', size: 0.3591459528362014, y1: 0.3591459528362014, }, ], }, { key: 'Europe', values: [ { x: 'Wii Sports', y: 0.3507372492144065, y0: 0.5014503263234228, series: 1, key: 'Europe', size: 0.3507372492144065, y1: 0.8521875755378293, }, { x: 'Super Mario Bros.', y: 0.0889662027833002, y0: 0.7226640159045725, series: 1, key: 'Europe', size: 0.0889662027833002, y1: 0.8116302186878728, }, { x: 'Duck Hunt', y: 0.022253620628753093, y0: 0.9512539738608266, series: 1, key: 'Europe', size: 0.022253620628753093, y1: 0.9735075944895797, }, { x: 'Tetris', y: 0.07468605419695969, y0: 0.7666886979510906, series: 1, key: 'Europe', size: 0.07468605419695969, y1: 0.8413747521480504, }, { x: 'Mario Kart Wii', y: 0.35947530002790956, y0: 0.44236673178900354, series: 1, key: 'Europe', size: 0.35947530002790956, y1: 0.801842031816913, }, { x: 'Wii Sports Resort', y: 0.3336363636363636, y0: 0.4772727272727273, series: 1, key: 'Europe', size: 0.3336363636363636, y1: 0.8109090909090909, }, { x: 'New Super Mario Bros. Wii', y: 0.24676686473261097, y0: 0.5099615519049283, series: 1, key: 'Europe', size: 0.24676686473261097, y1: 0.7567284166375393, }, { x: 'Wii Play', y: 0.31713202344019303, y0: 0.4836263357462944, series: 1, key: 'Europe', size: 0.31713202344019303, y1: 0.8007583591864874, }, { x: 'New Super Mario Bros.', y: 0.30756414528490506, y0: 0.3792069310229924, series: 1, key: 'Europe', size: 0.30756414528490506, y1: 0.6867710763078975, }, { x: 'Pokemon Red/Pokemon Blue', y: 0.28330146590184835, y0: 0.3591459528362014, series: 1, key: 'Europe', size: 0.28330146590184835, y1: 0.6424474187380498, }, ], }, { key: 'Japan', values: [ { x: 'Wii Sports', y: 0.04556441866086536, y0: 0.8521875755378293, series: 2, key: 'Japan', size: 0.04556441866086536, y1: 0.8977519941986947, }, { x: 'Super Mario Bros.', y: 0.169234592445328, y0: 0.8116302186878728, series: 2, key: 'Japan', size: 0.169234592445328, y1: 0.9808648111332008, }, { x: 'Duck Hunt', y: 0.009890498057223597, y0: 0.9735075944895797, series: 2, key: 'Japan', size: 0.009890498057223597, y1: 0.9833980925468033, }, { x: 'Tetris', y: 0.1394580304031725, y0: 0.8413747521480504, series: 2, key: 'Japan', size: 0.1394580304031725, y1: 0.9808327825512229, }, { x: 'Mario Kart Wii', y: 0.1057772816075914, y0: 0.801842031816913, series: 2, key: 'Japan', size: 0.1057772816075914, y1: 0.9076193134245044, }, { x: 'Wii Sports Resort', y: 0.09939393939393938, y0: 0.8109090909090909, series: 2, key: 'Japan', size: 0.09939393939393938, y1: 0.9103030303030303, }, { x: 'New Super Mario Bros. Wii', y: 0.16427822439706397, y0: 0.7567284166375393, series: 2, key: 'Japan', size: 0.16427822439706397, y1: 0.9210066410346033, }, { x: 'Wii Play', y: 0.10099965529127888, y0: 0.8007583591864874, series: 2, key: 'Japan', size: 0.10099965529127888, y1: 0.9017580144777663, }, { x: 'New Super Mario Bros.', y: 0.21659446851049652, y0: 0.6867710763078975, series: 2, key: 'Japan', size: 0.21659446851049652, y1: 0.9033655448183939, }, { x: 'Pokemon Red/Pokemon Blue', y: 0.32568514977692803, y0: 0.6424474187380498, series: 2, key: 'Japan', size: 0.32568514977692803, y1: 0.9681325685149778, }, ], }, { key: 'Other', values: [ { x: 'Wii Sports', y: 0.10224800580130529, y0: 0.8977519941986947, series: 3, key: 'Other', size: 0.10224800580130529, y1: 1, }, { x: 'Super Mario Bros.', y: 0.019135188866799203, y0: 0.9808648111332008, series: 3, key: 'Other', size: 0.019135188866799203, y1: 1, }, { x: 'Duck Hunt', y: 0.01660190745319675, y0: 0.9833980925468033, series: 3, key: 'Other', size: 0.01660190745319675, y1: 1, }, { x: 'Tetris', y: 0.019167217448777262, y0: 0.9808327825512229, series: 3, key: 'Other', size: 0.019167217448777262, y1: 1.0000000000000002, }, { x: 'Mario Kart Wii', y: 0.09238068657549538, y0: 0.9076193134245044, series: 3, key: 'Other', size: 0.09238068657549538, y1: 0.9999999999999998, }, { x: 'Wii Sports Resort', y: 0.08969696969696969, y0: 0.9103030303030303, series: 3, key: 'Other', size: 0.08969696969696969, y1: 1, }, { x: 'New Super Mario Bros. Wii', y: 0.0789933589653967, y0: 0.9210066410346033, series: 3, key: 'Other', size: 0.0789933589653967, y1: 1, }, { x: 'Wii Play', y: 0.09824198552223372, y0: 0.9017580144777663, series: 3, key: 'Other', size: 0.09824198552223372, y1: 1, }, { x: 'New Super Mario Bros.', y: 0.09663445518160614, y0: 0.9033655448183939, series: 3, key: 'Other', size: 0.09663445518160614, y1: 1, }, { x: 'Pokemon Red/Pokemon Blue', y: 0.03186743148502231, y0: 0.9681325685149778, series: 3, key: 'Other', size: 0.03186743148502231, y1: 1, }, ], }, ], applied_filters: [ { column: 'rank', }, ], rejected_filters: [], }, ], triggerQuery: false, lastRendered: 0, form_data: { datasource: '20__table', viz_type: 'dist_bar', slice_id: 113, url_params: {}, granularity_sqla: 'year', time_range: 'No filter', metrics: [ { aggregate: 'SUM', column: { column_name: 'na_sales', description: null, expression: null, filterable: true, groupby: true, id: 883, is_dttm: false, optionName: '_col_NA_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: true, isNew: false, label: 'North America', optionName: 'metric_a943v7wg5g_0mm03hrsmpf', sqlExpression: null, }, { aggregate: 'SUM', column: { column_name: 'eu_sales', description: null, expression: null, filterable: true, groupby: true, id: 884, is_dttm: false, optionName: '_col_EU_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: true, isNew: false, label: 'Europe', optionName: 'metric_bibau54x0rb_dwrjtqkbyso', sqlExpression: null, }, { aggregate: 'SUM', column: { column_name: 'jp_sales', description: null, expression: null, filterable: true, groupby: true, id: 885, is_dttm: false, optionName: '_col_JP_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: true, isNew: false, label: 'Japan', optionName: 'metric_06whpr2oyhw_4l88xxu6zvd', sqlExpression: null, }, { aggregate: 'SUM', column: { column_name: 'other_sales', description: null, expression: null, filterable: true, groupby: true, id: 886, is_dttm: false, optionName: '_col_Other_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: true, isNew: false, label: 'Other', optionName: 'metric_pcx05ioxums_ibr16zvi74', sqlExpression: null, }, ], adhoc_filters: [ { clause: 'WHERE', comparator: '10', expressionType: 'SIMPLE', filterOptionName: 'filter_juemdnqji5_d6fm8tuf4rc', isExtra: false, isNew: false, operator: '<=', sqlExpression: null, subject: 'rank', }, ], groupby: ['name'], columns: [], row_limit: null, order_desc: true, contribution: true, color_scheme: 'supersetColors', show_legend: true, rich_tooltip: true, bar_stacked: true, y_axis_format: 'SMART_NUMBER', y_axis_bounds: [null, null], bottom_margin: 'auto', x_ticks_layout: 'staggered', label_colors: {}, queryFields: { columns: 'groupby', groupby: 'groupby', metrics: 'metrics', }, }, }, '120': { id: 120, chartAlert: null, chartStatus: 'loading', chartStackTrace: null, chartUpdateEndTime: null, chartUpdateStartTime: 0, latestQueryFormData: {}, sliceFormData: null, queryController: null, queriesResponse: null, triggerQuery: true, lastRendered: 0, form_data: { datasource: '20__table', viz_type: 'dist_bar', slice_id: 120, url_params: { preselect_filters: '{"1389": {"platform": ["PS", "PS2", "PS3", "PS4"], "genre": null, "__time_range": "No filter"}}', }, granularity_sqla: 'year', time_range: 'No filter', metrics: [ { aggregate: 'SUM', column: { column_name: 'na_sales', description: null, expression: null, filterable: true, groupby: true, id: 883, is_dttm: false, optionName: '_col_NA_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: true, isNew: false, label: 'North America', optionName: 'metric_3pl6jwmyd72_p9o4j2xxgyp', sqlExpression: null, }, { aggregate: 'SUM', column: { column_name: 'eu_sales', description: null, expression: null, filterable: true, groupby: true, id: 884, is_dttm: false, optionName: '_col_EU_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: true, isNew: false, label: 'Europe', optionName: 'metric_e8rdyfxxjdu_6dgyhf7xcne', sqlExpression: null, }, { aggregate: 'SUM', column: { column_name: 'jp_sales', description: null, expression: null, filterable: true, groupby: true, id: 885, is_dttm: false, optionName: '_col_JP_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: true, isNew: false, label: 'Japan', optionName: 'metric_6gesefugzy6_517l3wowdwu', sqlExpression: null, }, { aggregate: 'SUM', column: { column_name: 'other_sales', description: null, expression: null, filterable: true, groupby: true, id: 886, is_dttm: false, optionName: '_col_Other_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: true, isNew: false, label: 'Other', optionName: 'metric_cf6kbre28f_2sg5b5pfq5a', sqlExpression: null, }, ], adhoc_filters: [], groupby: ['genre'], columns: [], row_limit: null, order_desc: true, contribution: false, color_scheme: 'supersetColors', show_legend: true, show_bar_value: false, rich_tooltip: true, bar_stacked: true, order_bars: false, y_axis_format: 'SMART_NUMBER', show_controls: true, y_axis_bounds: [null, null], x_axis_label: 'Genre', bottom_margin: 'auto', x_ticks_layout: 'flat', label_colors: { '0': '#1FA8C9', '1': '#454E7C', '2600': '#666666', '3DO': '#B2B2B2', '3DS': '#D1C6BC', Action: '#1FA8C9', Adventure: '#454E7C', DC: '#A38F79', DS: '#8FD3E4', Europe: '#5AC189', Fighting: '#5AC189', GB: '#FDE380', GBA: '#ACE1C4', GC: '#5AC189', GEN: '#3CCCCB', GG: '#EFA1AA', Japan: '#FF7F44', 'Microsoft Game Studios': '#D1C6BC', Misc: '#FF7F44', N64: '#1FA8C9', NES: '#9EE5E5', NG: '#A1A6BD', Nintendo: '#D3B3DA', 'North America': '#666666', Other: '#E04355', PC: '#EFA1AA', PCFX: '#FDE380', PS: '#A1A6BD', PS2: '#FCC700', PS3: '#3CCCCB', PS4: '#B2B2B2', PSP: '#FEC0A1', PSV: '#FCC700', Platform: '#666666', Puzzle: '#E04355', Racing: '#FCC700', 'Role-Playing': '#A868B7', SAT: '#A868B7', SCD: '#8FD3E4', SNES: '#454E7C', Shooter: '#3CCCCB', Simulation: '#A38F79', Sports: '#8FD3E4', Strategy: '#A1A6BD', TG16: '#FEC0A1', 'Take-Two Interactive': '#9EE5E5', WS: '#ACE1C4', Wii: '#A38F79', WiiU: '#E04355', X360: '#A868B7', XB: '#D3B3DA', XOne: '#FF7F44', }, queryFields: { columns: 'groupby', groupby: 'groupby', metrics: 'metrics', }, }, }, '123': { id: 123, chartAlert: null, chartStatus: 'rendered', chartStackTrace: null, chartUpdateEndTime: 1673046998143, chartUpdateStartTime: 1673046994604, latestQueryFormData: { datasource: '20__table', viz_type: 'pie', slice_id: 123, url_params: {}, granularity_sqla: 'year', time_range: 'No filter', groupby: ['publisher'], metric: { aggregate: 'SUM', column: { column_name: 'global_sales', description: null, expression: null, filterable: true, groupby: true, id: 887, is_dttm: false, optionName: '_col_Global_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: false, isNew: false, label: 'SUM(Global_Sales)', optionName: 'metric_k2rqz0zqhkf_49hu4kq9h3u', sqlExpression: null, }, adhoc_filters: [ { clause: 'WHERE', comparator: '25', expressionType: 'SIMPLE', filterOptionName: 'filter_znxs4o61aod_n5blgxo29r', isExtra: false, isNew: false, operator: '<=', sqlExpression: null, subject: 'rank', }, ], row_limit: null, sort_by_metric: true, color_scheme: 'supersetColors', show_labels_threshold: 5, show_legend: false, legendType: 'scroll', legendOrientation: 'top', label_type: 'key', number_format: 'SMART_NUMBER', date_format: 'smart_date', show_labels: true, labels_outside: true, label_line: true, outerRadius: 67, donut: true, innerRadius: 45, queryFields: { groupby: 'groupby', metric: 'metrics', }, label_colors: { '0': '#1FA8C9', '1': '#454E7C', '2600': '#666666', Europe: '#5AC189', Japan: '#FF7F44', 'North America': '#666666', Other: '#E04355', PS2: '#FCC700', X360: '#A868B7', PS3: '#3CCCCB', Wii: '#A38F79', DS: '#8FD3E4', PS: '#A1A6BD', GBA: '#ACE1C4', PSP: '#FEC0A1', PS4: '#B2B2B2', PC: '#EFA1AA', GB: '#FDE380', XB: '#D3B3DA', NES: '#9EE5E5', '3DS': '#D1C6BC', N64: '#1FA8C9', SNES: '#454E7C', GC: '#5AC189', XOne: '#FF7F44', WiiU: '#E04355', PSV: '#FCC700', SAT: '#A868B7', GEN: '#3CCCCB', DC: '#A38F79', SCD: '#8FD3E4', NG: '#A1A6BD', WS: '#ACE1C4', TG16: '#FEC0A1', '3DO': '#B2B2B2', GG: '#EFA1AA', PCFX: '#FDE380', Nintendo: '#D3B3DA', 'Take-Two Interactive': '#9EE5E5', 'Microsoft Game Studios': '#D1C6BC', Action: '#1FA8C9', Adventure: '#454E7C', Fighting: '#5AC189', Misc: '#FF7F44', Platform: '#666666', Puzzle: '#E04355', Racing: '#FCC700', 'Role-Playing': '#A868B7', Shooter: '#3CCCCB', Simulation: '#A38F79', Sports: '#8FD3E4', Strategy: '#A1A6BD', }, shared_label_colors: {}, extra_filters: [ { col: '__time_range', op: '==', val: 'No filter', }, ], extra_form_data: {}, dashboardId: 9, }, sliceFormData: null, queryController: {}, queriesResponse: [ { cache_key: '18929e0056e248f9ae6e413e91a3e0ef', cached_dttm: null, cache_timeout: 86400, applied_template_filters: [], annotation_data: {}, error: null, is_cached: null, query: 'SELECT publisher AS publisher,\n sum(global_sales) AS "SUM(Global_Sales)"\nFROM main.video_game_sales\nWHERE rank <= 25\nGROUP BY publisher\nORDER BY "SUM(Global_Sales)" DESC\nLIMIT 50000\nOFFSET 0;\n\n', status: 'success', stacktrace: null, rowcount: 3, from_dttm: null, to_dttm: null, label_map: { publisher: ['publisher'], 'SUM(Global_Sales)': ['SUM(Global_Sales)'], }, colnames: ['publisher', 'SUM(Global_Sales)'], indexnames: [0, 1, 2], coltypes: [1, 0], data: [ { publisher: 'Nintendo', 'SUM(Global_Sales)': 580, }, { publisher: 'Take-Two Interactive', 'SUM(Global_Sales)': 74.73999999999998, }, { publisher: 'Microsoft Game Studios', 'SUM(Global_Sales)': 21.82, }, ], result_format: 'json', applied_filters: [ { column: 'rank', }, { column: '__time_range', }, ], rejected_filters: [], }, ], triggerQuery: false, lastRendered: 0, form_data: { datasource: '20__table', viz_type: 'pie', slice_id: 123, url_params: {}, granularity_sqla: 'year', time_range: 'No filter', groupby: ['publisher'], metric: { aggregate: 'SUM', column: { column_name: 'global_sales', description: null, expression: null, filterable: true, groupby: true, id: 887, is_dttm: false, optionName: '_col_Global_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: false, isNew: false, label: 'SUM(Global_Sales)', optionName: 'metric_k2rqz0zqhkf_49hu4kq9h3u', sqlExpression: null, }, adhoc_filters: [ { clause: 'WHERE', comparator: '25', expressionType: 'SIMPLE', filterOptionName: 'filter_znxs4o61aod_n5blgxo29r', isExtra: false, isNew: false, operator: '<=', sqlExpression: null, subject: 'rank', }, ], row_limit: null, sort_by_metric: true, color_scheme: 'supersetColors', show_labels_threshold: 5, show_legend: false, legendType: 'scroll', legendOrientation: 'top', label_type: 'key', number_format: 'SMART_NUMBER', date_format: 'smart_date', show_labels: true, labels_outside: true, label_line: true, outerRadius: 67, donut: true, innerRadius: 45, queryFields: { groupby: 'groupby', metric: 'metrics', }, }, }, '125': { id: 125, chartAlert: null, chartStatus: 'rendered', chartStackTrace: null, chartUpdateEndTime: 1673046997626, chartUpdateStartTime: 1673046994618, latestQueryFormData: { datasource: '20__table', viz_type: 'treemap_v2', slice_id: 125, url_params: {}, granularity_sqla: 'year', time_range: 'No filter', metric: 'count', adhoc_filters: [], groupby: ['platform'], row_limit: 10, order_desc: true, color_scheme: 'supersetColors', treemap_ratio: 1.618033988749895, number_format: 'SMART_NUMBER', queryFields: { groupby: 'groupby', metrics: 'metrics', }, shared_label_colors: {}, extra_filters: [ { col: '__time_range', op: '==', val: 'No filter', }, ], dashboardId: 9, }, sliceFormData: null, queryController: {}, queriesResponse: [ { cache_key: '9a7e15121b29cddbb238559d031557df', cached_dttm: null, cache_timeout: 86400, errors: [], form_data: { datasource: '20__table', viz_type: 'treemap_v2', slice_id: 125, url_params: {}, granularity_sqla: 'year', time_range: 'No filter', metric: 'count', adhoc_filters: [], groupby: ['platform'], row_limit: 10, order_desc: true, color_scheme: 'supersetColors', treemap_ratio: 1.618033988749895, number_format: 'SMART_NUMBER', queryFields: { groupby: 'groupby', metrics: 'metrics', }, shared_label_colors: {}, dashboardId: 9, applied_time_extras: {}, where: '', having: '', filters: [], }, is_cached: false, query: 'SELECT platform AS platform,\n COUNT(*) AS count\nFROM main.video_game_sales\nGROUP BY platform\nLIMIT 10\nOFFSET 0', from_dttm: null, to_dttm: null, status: 'success', stacktrace: null, rowcount: 10, colnames: ['platform', 'count'], coltypes: [1, 0], data: [ { name: 'count', children: [ { name: '2600', value: 133, }, { name: '3DO', value: 3, }, { name: '3DS', value: 509, }, { name: 'DC', value: 52, }, { name: 'DS', value: 2162, }, { name: 'GB', value: 98, }, { name: 'GBA', value: 822, }, { name: 'GC', value: 556, }, { name: 'GEN', value: 27, }, { name: 'GG', value: 1, }, ], }, ], applied_filters: [], rejected_filters: [], }, ], triggerQuery: false, lastRendered: 0, form_data: { datasource: '20__table', viz_type: 'treemap_v2', slice_id: 125, url_params: {}, granularity_sqla: 'year', time_range: 'No filter', metric: 'count', adhoc_filters: [], groupby: ['platform'], row_limit: 10, order_desc: true, color_scheme: 'supersetColors', treemap_ratio: 1.618033988749895, number_format: 'SMART_NUMBER', label_colors: { '2600': '#D1C6BC', '3DO': '#A38F79', '3DS': '#B2B2B2', Action: '#ACE1C4', Adventure: '#5AC189', 'COUNT(*)': '#1FA8C9', DC: '#666666', DS: '#E04355', Fighting: '#D1C6BC', GB: '#A1A6BD', GBA: '#A868B7', GC: '#D3B3DA', GEN: '#FF7F44', GG: '#8FD3E4', 'Microsoft Game Studios': '#FCC700', Misc: '#D3B3DA', N64: '#EFA1AA', NES: '#FEC0A1', NG: '#FCC700', Nintendo: '#666666', PC: '#8FD3E4', PCFX: '#A1A6BD', PS: '#FCC700', PS2: '#454E7C', PS3: '#FF7F44', PS4: '#A38F79', PSP: '#3CCCCB', PSV: '#454E7C', Platform: '#FDE380', Puzzle: '#454E7C', Racing: '#9EE5E5', 'Role-Playing': '#EFA1AA', SAT: '#5AC189', SCD: '#E04355', SNES: '#FDE380', Shooter: '#B2B2B2', Simulation: '#1FA8C9', Sports: '#FEC0A1', Strategy: '#FF7F44', TG16: '#3CCCCB', 'Take-Two Interactive': '#E04355', WS: '#A868B7', Wii: '#666666', WiiU: '#1FA8C9', X360: '#5AC189', XB: '#ACE1C4', XOne: '#9EE5E5', }, queryFields: { groupby: 'groupby', metrics: 'metrics', }, }, }, '127': { id: 127, chartAlert: null, chartStatus: 'loading', chartStackTrace: null, chartUpdateEndTime: null, chartUpdateStartTime: 0, latestQueryFormData: {}, sliceFormData: null, queryController: null, queriesResponse: null, triggerQuery: true, lastRendered: 0, form_data: { datasource: '20__table', viz_type: 'filter_box', slice_id: 127, url_params: { preselect_filters: '{"1389": {"platform": ["PS", "PS2", "PS3", "PS4"], "genre": null, "__time_range": "No filter"}}', }, granularity_sqla: 'Year', time_range: 'No filter', filter_configs: [ { asc: true, clearable: true, column: 'platform', key: 's3ItH9vhG', label: 'Platform', multiple: true, searchAllOptions: false, }, { asc: true, clearable: true, column: 'genre', key: '202hDeMsG', label: 'Genre', multiple: true, searchAllOptions: false, }, { asc: true, clearable: true, column: 'publisher', key: '5Os6jsJFK', label: 'Publisher', multiple: true, searchAllOptions: false, }, ], date_filter: true, adhoc_filters: [], queryFields: {}, }, }, '131': { id: 131, chartAlert: null, chartStatus: 'loading', chartStackTrace: null, chartUpdateEndTime: null, chartUpdateStartTime: 0, latestQueryFormData: {}, sliceFormData: null, queryController: null, queriesResponse: null, triggerQuery: true, lastRendered: 0, form_data: { datasource: '20__table', viz_type: 'treemap_v2', slice_id: 131, url_params: { preselect_filters: '{"1389": {"platform": ["PS", "PS2", "PS3", "PS4"], "genre": null, "__time_range": "No filter"}}', }, granularity_sqla: 'year', time_range: 'No filter', metric: 'count', adhoc_filters: [], groupby: ['genre'], row_limit: null, order_desc: true, color_scheme: 'supersetColors', treemap_ratio: 1.618033988749895, number_format: 'SMART_NUMBER', label_colors: { '0': '#1FA8C9', '1': '#454E7C', '2600': '#666666', '3DO': '#B2B2B2', '3DS': '#D1C6BC', Action: '#1FA8C9', Adventure: '#454E7C', DC: '#A38F79', DS: '#8FD3E4', Europe: '#5AC189', Fighting: '#5AC189', GB: '#FDE380', GBA: '#ACE1C4', GC: '#5AC189', GEN: '#3CCCCB', GG: '#EFA1AA', Japan: '#FF7F44', 'Microsoft Game Studios': '#D1C6BC', Misc: '#FF7F44', N64: '#1FA8C9', NES: '#9EE5E5', NG: '#A1A6BD', Nintendo: '#D3B3DA', 'North America': '#666666', Other: '#E04355', PC: '#EFA1AA', PCFX: '#FDE380', PS: '#A1A6BD', PS2: '#FCC700', PS3: '#3CCCCB', PS4: '#B2B2B2', PSP: '#FEC0A1', PSV: '#FCC700', Platform: '#666666', Puzzle: '#E04355', Racing: '#FCC700', 'Role-Playing': '#A868B7', SAT: '#A868B7', SCD: '#8FD3E4', SNES: '#454E7C', Shooter: '#3CCCCB', Simulation: '#A38F79', Sports: '#8FD3E4', Strategy: '#A1A6BD', TG16: '#FEC0A1', 'Take-Two Interactive': '#9EE5E5', WS: '#ACE1C4', Wii: '#A38F79', WiiU: '#E04355', X360: '#A868B7', XB: '#D3B3DA', XOne: '#FF7F44', }, queryFields: { groupby: 'groupby', metrics: 'metrics', }, }, }, '132': { id: 132, chartAlert: null, chartStatus: 'loading', chartStackTrace: null, chartUpdateEndTime: null, chartUpdateStartTime: 0, latestQueryFormData: {}, sliceFormData: null, queryController: null, queriesResponse: null, triggerQuery: true, lastRendered: 0, form_data: { datasource: '20__table', viz_type: 'table', slice_id: 132, url_params: {}, granularity_sqla: 'year', time_grain_sqla: 'P1D', time_range: 'No filter', query_mode: 'raw', groupby: ['name'], metrics: [ { aggregate: 'SUM', column: { column_name: 'global_sales', description: null, expression: null, filterable: true, groupby: true, id: 887, is_dttm: false, optionName: '_col_Global_Sales', python_date_format: null, type: 'DOUBLE PRECISION', verbose_name: null, }, expressionType: 'SIMPLE', hasCustomLabel: false, isNew: false, label: 'SUM(Global_Sales)', optionName: 'metric_pkpvgdsf70d_pnqv77v0x2p', sqlExpression: null, }, ], all_columns: [ 'name', 'global_sales', 'platform', 'genre', 'publisher', 'year', ], percent_metrics: [], adhoc_filters: [], order_by_cols: ['["global_sales", false]'], row_limit: null, server_page_length: 10, order_desc: true, table_timestamp_format: 'smart_date', page_length: '15', include_search: true, show_cell_bars: false, color_pn: false, queryFields: { groupby: 'groupby', metrics: 'metrics', }, table_filter: false, }, }, }; const validNodes = [ 'ROOT_ID', 'TABS-97PVJa11D_', 'TAB-2_QXp8aNq', 'ROW-fjg6YQBkH', 'CHART-1L7NIcXvVN', 'ROW-yP9SB89PZ', 'CHART-7mKdnU7OUJ', 'TAB-lg-5ymUDgm', 'ROW-7kAf1blYU', 'CHART-8OG3UJX-Tn', 'CHART-W02beJK7ms', 'CHART-XFag0yZdLk', 'ROW-NuR8GFQTO', 'CHART-XRvRfsMsaQ', 'CHART-XVIYTeubZh', 'CHART-_sx22yawJO', 'CHART-nYns6xr4Ft', 'COLUMN-F53B1OSMcz', 'CHART-uP9GF0z0rT', 'ROW-XT1DsNA_V', 'CHART-wt6ZO8jRXZ', ]; const initiallyExcludedCharts: number[] = []; it('Succeeds with valid', () => { expect(() => { buildTree( // @ts-ignore node, treeItem, layout, charts, validNodes, initiallyExcludedCharts, () => 'Fake title', ); }).not.toThrowError(); }); it('Avoids runtime error with invalid inputs', () => { expect(() => { buildTree( // @ts-expect-error undefined, treeItem, layout, charts, validNodes, initiallyExcludedCharts, () => 'Fake title', ); }).not.toThrowError(); expect(() => { buildTree( // @ts-expect-error node, null, layout, charts, validNodes, initiallyExcludedCharts, () => 'Fake title', ); }).not.toThrowError(); expect(() => { buildTree( // @ts-expect-error node, treeItem, null, charts, validNodes, initiallyExcludedCharts, () => 'Fake title', ); }).not.toThrowError(); expect(() => { buildTree( // @ts-expect-error node, treeItem, layout, null, validNodes, initiallyExcludedCharts, () => 'Fake title', ); }).not.toThrowError(); expect(() => { buildTree( // @ts-expect-error node, treeItem, layout, charts, null, initiallyExcludedCharts, () => 'Fake title', ); }).not.toThrowError(); expect(() => { buildTree( // @ts-expect-error node, treeItem, layout, charts, validNodes, null, () => 'Fake title', ); }).not.toThrowError(); }); });
7,356
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/resizable/ResizableContainer.test.tsx
/** * 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 React from 'react'; import { render } from 'spec/helpers/testing-library'; import ResizableContainer from 'src/dashboard/components/resizable/ResizableContainer'; interface ResizableContainerProps { id: string; children?: object; adjustableWidth?: boolean; adjustableHeight?: boolean; gutterWidth?: number; widthStep?: number; heightStep?: number; widthMultiple?: number; heightMultiple?: number; minWidthMultiple?: number; maxWidthMultiple?: number; minHeightMultiple?: number; maxHeightMultiple?: number; staticHeight?: number; staticHeightMultiple?: number; staticWidth?: number; staticWidthMultiple?: number; onResizeStop?: () => {}; onResize?: () => {}; onResizeStart?: () => {}; editMode: boolean; } describe('ResizableContainer', () => { const props = { editMode: false, id: 'id' }; const setup = (overrides?: ResizableContainerProps) => ( <ResizableContainer {...props} {...overrides} /> ); it('should render a Resizable container', () => { const rendered = render(setup()); const resizableContainer = rendered.container.querySelector( '.resizable-container', ); expect(resizableContainer).toBeVisible(); }); });
7,358
0
petrpan-code/apache/superset/superset-frontend/src/dashboard/components
petrpan-code/apache/superset/superset-frontend/src/dashboard/components/resizable/ResizableHandle.test.tsx
/** * 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 React from 'react'; import { render } from 'spec/helpers/testing-library'; import ResizableHandle from 'src/dashboard/components/resizable/ResizableHandle'; /* eslint-disable react/jsx-pascal-case */ describe('ResizableHandle', () => { it('should render a right resize handle', () => { const rendered = render(<ResizableHandle.right />); expect( rendered.container.querySelector('.resize-handle.resize-handle--right'), ).toBeVisible(); }); it('should render a bottom resize handle', () => { const rendered = render(<ResizableHandle.bottom />); expect( rendered.container.querySelector('.resize-handle.resize-handle--bottom'), ).toBeVisible(); }); it('should render a bottomRight resize handle', () => { const rendered = render(<ResizableHandle.bottomRight />); expect( rendered.container.querySelector( '.resize-handle.resize-handle--bottom-right', ), ).toBeVisible(); }); }); /* eslint-enable react/jsx-pascal-case */
7,376
0
petrpan-code/apache/superset/superset-frontend/src/dashboard
petrpan-code/apache/superset/superset-frontend/src/dashboard/reducers/dashboardState.test.ts
/** * 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 dashboardStateReducer from './dashboardState'; import { setActiveTabs } from '../actions/dashboardState'; describe('DashboardState reducer', () => { it('SET_ACTIVE_TABS', () => { expect( dashboardStateReducer({ activeTabs: [] }, setActiveTabs('tab1')), ).toEqual({ activeTabs: ['tab1'] }); expect( dashboardStateReducer({ activeTabs: ['tab1'] }, setActiveTabs('tab1')), ).toEqual({ activeTabs: ['tab1'] }); expect( dashboardStateReducer( { activeTabs: ['tab1'] }, setActiveTabs('tab2', 'tab1'), ), ).toEqual({ activeTabs: ['tab2'] }); }); });
7,387
0
petrpan-code/apache/superset/superset-frontend/src/dashboard
petrpan-code/apache/superset/superset-frontend/src/dashboard/util/componentIsResizable.test.ts
/** * 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 componentIsResizable from 'src/dashboard/util/componentIsResizable'; import { CHART_TYPE, COLUMN_TYPE, DASHBOARD_GRID_TYPE, DASHBOARD_ROOT_TYPE, DIVIDER_TYPE, HEADER_TYPE, MARKDOWN_TYPE, ROW_TYPE, TABS_TYPE, TAB_TYPE, } from 'src/dashboard/util/componentTypes'; const notResizable = [ DASHBOARD_GRID_TYPE, DASHBOARD_ROOT_TYPE, DIVIDER_TYPE, HEADER_TYPE, ROW_TYPE, TABS_TYPE, TAB_TYPE, ]; const resizable = [COLUMN_TYPE, CHART_TYPE, MARKDOWN_TYPE]; describe('componentIsResizable', () => { resizable.forEach(type => { it(`should return true for ${type}`, () => { expect(componentIsResizable({ type })).toBe(true); }); }); notResizable.forEach(type => { it(`should return false for ${type}`, () => { expect(componentIsResizable({ type })).toBe(false); }); }); });
7,391
0
petrpan-code/apache/superset/superset-frontend/src/dashboard
petrpan-code/apache/superset/superset-frontend/src/dashboard/util/crossFilters.test.ts
/** * 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 sinon, { SinonStub } from 'sinon'; import { Behavior, FeatureFlag } from '@superset-ui/core'; import * as core from '@superset-ui/core'; import { getCrossFiltersConfiguration } from './crossFilters'; import { DEFAULT_CROSS_FILTER_SCOPING } from '../constants'; const DASHBOARD_LAYOUT = { 'CHART-1': { children: [], id: 'CHART-1', meta: { chartId: 1, sliceName: 'Test chart 1', height: 1, width: 1, uuid: '1', }, parents: ['ROOT_ID', 'GRID_ID', 'ROW-6XUMf1rV76'], type: 'CHART', }, 'CHART-2': { children: [], id: 'CHART-2', meta: { chartId: 2, sliceName: 'Test chart 2', height: 1, width: 1, uuid: '2', }, parents: ['ROOT_ID', 'GRID_ID', 'ROW-6XUMf1rV76'], type: 'CHART', }, }; const CHARTS = { '1': { id: 1, form_data: { datasource: '2__table', viz_type: 'echarts_timeseries_line', slice_id: 1, }, chartAlert: null, chartStatus: 'rendered' as const, chartUpdateEndTime: 0, chartUpdateStartTime: 0, lastRendered: 0, latestQueryFormData: {}, sliceFormData: { datasource: '2__table', viz_type: 'echarts_timeseries_line', }, queryController: null, queriesResponse: [{}], triggerQuery: false, }, '2': { id: 2, form_data: { datasource: '2__table', viz_type: 'echarts_timeseries_line', slice_id: 2, }, chartAlert: null, chartStatus: 'rendered' as const, chartUpdateEndTime: 0, chartUpdateStartTime: 0, lastRendered: 0, latestQueryFormData: {}, sliceFormData: { datasource: '2__table', viz_type: 'echarts_timeseries_line', }, queryController: null, queriesResponse: [{}], triggerQuery: false, }, }; const INITIAL_CHART_CONFIG = { '1': { id: 1, crossFilters: { scope: { rootPath: ['ROOT_ID'], excluded: [1, 2], }, chartsInScope: [], }, }, '2': { id: 2, crossFilters: { scope: 'global' as const, chartsInScope: [1], }, }, }; const GLOBAL_CHART_CONFIG = { scope: DEFAULT_CROSS_FILTER_SCOPING, chartsInScope: [1, 2], }; const CHART_CONFIG_METADATA = { chart_configuration: INITIAL_CHART_CONFIG, global_chart_configuration: GLOBAL_CHART_CONFIG, }; let metadataRegistryStub: SinonStub; beforeEach(() => { metadataRegistryStub = sinon .stub(core, 'getChartMetadataRegistry') .callsFake(() => ({ // @ts-ignore get: () => ({ behaviors: [Behavior.INTERACTIVE_CHART], }), })); }); afterEach(() => { metadataRegistryStub.restore(); }); test('Generate correct cross filters configuration without initial configuration', () => { // @ts-ignore global.featureFlags = { [FeatureFlag.DASHBOARD_CROSS_FILTERS]: true, }; // @ts-ignore expect(getCrossFiltersConfiguration(DASHBOARD_LAYOUT, {}, CHARTS)).toEqual({ chartConfiguration: { '1': { id: 1, crossFilters: { scope: 'global', chartsInScope: [2], }, }, '2': { id: 2, crossFilters: { scope: 'global', chartsInScope: [1], }, }, }, globalChartConfiguration: { scope: { excluded: [], rootPath: ['ROOT_ID'], }, chartsInScope: [1, 2], }, }); }); test('Generate correct cross filters configuration with initial configuration', () => { // @ts-ignore global.featureFlags = { [FeatureFlag.DASHBOARD_CROSS_FILTERS]: true, }; expect( getCrossFiltersConfiguration( DASHBOARD_LAYOUT, CHART_CONFIG_METADATA, CHARTS, ), ).toEqual({ chartConfiguration: { '1': { id: 1, crossFilters: { scope: { rootPath: ['ROOT_ID'], excluded: [1, 2], }, chartsInScope: [], }, }, '2': { id: 2, crossFilters: { scope: 'global', chartsInScope: [1], }, }, }, globalChartConfiguration: { scope: { excluded: [], rootPath: ['ROOT_ID'], }, chartsInScope: [1, 2], }, }); }); test('Return undefined if DASHBOARD_CROSS_FILTERS feature flag is disabled', () => { // @ts-ignore global.featureFlags = { [FeatureFlag.DASHBOARD_CROSS_FILTERS]: false, }; expect( getCrossFiltersConfiguration( DASHBOARD_LAYOUT, CHART_CONFIG_METADATA, CHARTS, ), ).toEqual(undefined); }); test('Recalculate charts in global filter scope when charts change', () => { // @ts-ignore global.featureFlags = { [FeatureFlag.DASHBOARD_CROSS_FILTERS]: true, }; expect( getCrossFiltersConfiguration( { ...DASHBOARD_LAYOUT, 'CHART-3': { children: [], id: 'CHART-3', meta: { chartId: 3, sliceName: 'Test chart 3', height: 1, width: 1, uuid: '3', }, parents: ['ROOT_ID', 'GRID_ID', 'ROW-6XUMf1rV76'], type: 'CHART', }, }, CHART_CONFIG_METADATA, { ...CHARTS, '3': { id: 3, form_data: { datasource: '3__table', viz_type: 'echarts_timeseries_line', }, chartAlert: null, chartStatus: 'rendered' as const, chartUpdateEndTime: 0, chartUpdateStartTime: 0, lastRendered: 0, latestQueryFormData: {}, sliceFormData: { datasource: '3__table', viz_type: 'echarts_timeseries_line', }, queryController: null, queriesResponse: [{}], triggerQuery: false, }, }, ), ).toEqual({ chartConfiguration: { '1': { id: 1, crossFilters: { scope: { rootPath: ['ROOT_ID'], excluded: [1, 2] }, chartsInScope: [3], }, }, '2': { id: 2, crossFilters: { scope: 'global', chartsInScope: [1, 3], }, }, '3': { id: 3, crossFilters: { scope: 'global', chartsInScope: [1, 2], }, }, }, globalChartConfiguration: { scope: { excluded: [], rootPath: ['ROOT_ID'], }, chartsInScope: [1, 2, 3], }, }); });
7,397
0
petrpan-code/apache/superset/superset-frontend/src/dashboard
petrpan-code/apache/superset/superset-frontend/src/dashboard/util/extractUrlParams.test.ts
/** * 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 extractUrlParams from './extractUrlParams'; const originalWindowLocation = window.location; describe('extractUrlParams', () => { beforeAll(() => { // @ts-ignore delete window.location; // @ts-ignore window.location = { search: '?edit=true&abc=123' }; }); afterAll(() => { window.location = originalWindowLocation; }); it('returns all urlParams', () => { expect(extractUrlParams('all')).toEqual({ edit: 'true', abc: '123', }); }); it('returns reserved urlParams', () => { expect(extractUrlParams('reserved')).toEqual({ edit: 'true', }); }); it('returns regular urlParams', () => { expect(extractUrlParams('regular')).toEqual({ abc: '123', }); }); });
7,401
0
petrpan-code/apache/superset/superset-frontend/src/dashboard
petrpan-code/apache/superset/superset-frontend/src/dashboard/util/findParentId.test.ts
/** * 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 findParentId from 'src/dashboard/util/findParentId'; describe('findParentId', () => { const layout = { a: { id: 'a', children: ['b', 'r', 'k'], }, b: { id: 'b', children: ['x', 'y', 'z'], }, z: { id: 'z', children: [], }, }; it('should return the correct parentId', () => { expect(findParentId({ childId: 'b', layout })).toBe('a'); expect(findParentId({ childId: 'z', layout })).toBe('b'); }); it('should return null if the parent cannot be found', () => { expect(findParentId({ childId: 'a', layout })).toBeNull(); }); it('should not throw error and return null with bad / missing inputs', () => { // @ts-ignore expect(findParentId(null)).toBeNull(); // @ts-ignore expect(findParentId({ layout })).toBeNull(); // @ts-ignore expect(findParentId({ childId: 'a' })).toBeNull(); // @ts-ignore expect(findParentId({ childId: 'a', layout: null })).toBeNull(); }); });
7,429
0
petrpan-code/apache/superset/superset-frontend/src/dashboard
petrpan-code/apache/superset/superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts
/** * 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 getFormDataWithExtraFilters, { GetFormDataWithExtraFiltersArguments, } from 'src/dashboard/util/charts/getFormDataWithExtraFilters'; import { sliceId as chartId } from 'spec/fixtures/mockChartQueries'; describe('getFormDataWithExtraFilters', () => { const filterId = 'native-filter-1'; const mockChart = { id: chartId, chartAlert: null, chartStatus: null, chartUpdateEndTime: null, chartUpdateStartTime: 1, lastRendered: 1, latestQueryFormData: {}, sliceFormData: null, queryController: null, queriesResponse: null, triggerQuery: false, form_data: { viz_type: 'filter_select', filters: [ { col: 'country_name', op: 'IN', val: ['United States'], }, ], datasource: '123', url_params: {}, }, }; const mockArgs: GetFormDataWithExtraFiltersArguments = { chartConfiguration: {}, chart: mockChart, filters: { region: ['Spain'], color: ['pink', 'purple'], }, sliceId: chartId, nativeFilters: {}, dataMask: { [filterId]: { id: filterId, extraFormData: {}, filterState: {}, ownState: {}, }, }, extraControls: { stack: 'Stacked', }, allSliceIds: [chartId], }; it('should include filters from the passed filters', () => { const result = getFormDataWithExtraFilters(mockArgs); expect(result.extra_filters).toHaveLength(2); expect(result.extra_filters[0]).toEqual({ col: 'region', op: 'IN', val: ['Spain'], }); expect(result.extra_filters[1]).toEqual({ col: 'color', op: 'IN', val: ['pink', 'purple'], }); }); it('should compose extra control', () => { const result = getFormDataWithExtraFilters(mockArgs); expect(result.stack).toEqual('Stacked'); }); });
7,435
0
petrpan-code/apache/superset/superset-frontend/src/dashboard
petrpan-code/apache/superset/superset-frontend/src/dashboard/util/getOverwriteItems.test.ts
/** * 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 getOverwriteItems from './getOverwriteItems'; test('returns diff items', () => { const prevFilterScopes = { filter1: { scope: ['abc'], immune: [], }, }; const nextFilterScopes = { scope: ['ROOT_ID'], immune: ['efg'], }; const prevValue = { css: '', json_metadata: JSON.stringify({ filter_scopes: prevFilterScopes, default_filters: {}, }), }; const nextValue = { css: '.updated_css {color: white;}', json_metadata: JSON.stringify({ filter_scopes: nextFilterScopes, default_filters: {}, }), }; expect(getOverwriteItems(prevValue, nextValue)).toEqual([ { keyPath: 'css', newValue: nextValue.css, oldValue: prevValue.css }, { keyPath: 'json_metadata.filter_scopes', newValue: JSON.stringify(nextFilterScopes, null, 2), oldValue: JSON.stringify(prevFilterScopes, null, 2), }, ]); });
7,442
0
petrpan-code/apache/superset/superset-frontend/src/dashboard
petrpan-code/apache/superset/superset-frontend/src/dashboard/util/isDashboardEmpty.test.ts
/** * 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 isDashboardEmpty from 'src/dashboard/util/isDashboardEmpty'; import getEmptyLayout from 'src/dashboard/util/getEmptyLayout'; describe('isDashboardEmpty', () => { const emptyLayout: object = getEmptyLayout(); const testLayout: object = { ...emptyLayout, 'MARKDOWN-IhTGLhyiTd': { children: [], id: 'MARKDOWN-IhTGLhyiTd', meta: { code: 'test me', height: 50, width: 4 }, parents: ['ROOT_ID', 'GRID_ID', 'ROW-uPjcKNYJQy'], type: 'MARKDOWN', }, }; it('should return true for empty dashboard', () => { expect(isDashboardEmpty(emptyLayout)).toBe(true); }); it('should return false for non-empty dashboard', () => { expect(isDashboardEmpty(testLayout)).toBe(false); }); });
7,446
0
petrpan-code/apache/superset/superset-frontend/src/dashboard
petrpan-code/apache/superset/superset-frontend/src/dashboard/util/isValidChild.test.ts
/** * 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 isValidChild from 'src/dashboard/util/isValidChild'; import { CHART_TYPE as CHART, COLUMN_TYPE as COLUMN, DASHBOARD_GRID_TYPE as GRID, DASHBOARD_ROOT_TYPE as ROOT, DIVIDER_TYPE as DIVIDER, HEADER_TYPE as HEADER, MARKDOWN_TYPE as MARKDOWN, ROW_TYPE as ROW, TABS_TYPE as TABS, TAB_TYPE as TAB, } from 'src/dashboard/util/componentTypes'; const getIndentation = (depth: number) => Array(depth * 3) .fill('') .join('-'); describe('isValidChild', () => { describe('valid calls', () => { // these are representations of nested structures for easy testing // [ROOT (depth 0) > GRID (depth 1) > HEADER (depth 2)] // every unique parent > child relationship is tested, but because this // test representation WILL result in duplicates, we hash each test // to keep track of which we've run const didTest = {}; const validExamples = [ [ROOT, GRID, CHART], // chart is valid because it is wrapped in a row [ROOT, GRID, MARKDOWN], // markdown is valid because it is wrapped in a row [ROOT, GRID, COLUMN], // column is valid because it is wrapped in a row [ROOT, GRID, HEADER], [ROOT, GRID, ROW, MARKDOWN], [ROOT, GRID, ROW, CHART], [ROOT, GRID, ROW, COLUMN, HEADER], [ROOT, GRID, ROW, COLUMN, DIVIDER], [ROOT, GRID, ROW, COLUMN, CHART], [ROOT, GRID, ROW, COLUMN, MARKDOWN], [ROOT, GRID, ROW, COLUMN, ROW, CHART], [ROOT, GRID, ROW, COLUMN, ROW, MARKDOWN], [ROOT, GRID, ROW, COLUMN, ROW, COLUMN, CHART], [ROOT, GRID, ROW, COLUMN, ROW, COLUMN, MARKDOWN], [ROOT, GRID, TABS, TAB, ROW, COLUMN, ROW, COLUMN, MARKDOWN], // tab equivalents [ROOT, TABS, TAB, CHART], [ROOT, TABS, TAB, MARKDOWN], [ROOT, TABS, TAB, COLUMN], [ROOT, TABS, TAB, HEADER], [ROOT, TABS, TAB, ROW, MARKDOWN], [ROOT, TABS, TAB, ROW, CHART], [ROOT, TABS, TAB, ROW, COLUMN, HEADER], [ROOT, TABS, TAB, ROW, COLUMN, DIVIDER], [ROOT, TABS, TAB, ROW, COLUMN, CHART], [ROOT, TABS, TAB, ROW, COLUMN, MARKDOWN], [ROOT, TABS, TAB, ROW, COLUMN, ROW, CHART], [ROOT, TABS, TAB, ROW, COLUMN, ROW, MARKDOWN], [ROOT, TABS, TAB, ROW, COLUMN, ROW, COLUMN, CHART], [ROOT, TABS, TAB, ROW, COLUMN, ROW, COLUMN, MARKDOWN], [ROOT, TABS, TAB, TABS, TAB, ROW, COLUMN, ROW, COLUMN, MARKDOWN], [ROOT, GRID, ROW, COLUMN, TABS], ]; validExamples.forEach((example, exampleIdx) => { let childDepth = 0; example.forEach((childType, i) => { const parentDepth = childDepth - 1; const parentType = example[i - 1]; const testKey = `${parentType}-${childType}-${parentDepth}`; if (i > 0 && !didTest[testKey]) { didTest[testKey] = true; it(`(${exampleIdx})${getIndentation( childDepth, )}${parentType} (depth ${parentDepth}) > ${childType} ✅`, () => { expect( isValidChild({ parentDepth, parentType, childType, }), ).toBe(true); }); } // see isValidChild.js for why tabs do not increment the depth of their children childDepth += childType !== TABS && childType !== TAB ? 1 : 0; }); }); }); describe('invalid calls', () => { // In order to assert that a parent > child hierarchy at a given depth is invalid // we also define some valid hierarchies in doing so. we indicate which // parent > [child] relationships should be asserted as invalid using a nested array const invalidExamples = [ [ROOT, [DIVIDER]], [ROOT, [CHART]], [ROOT, [MARKDOWN]], [ROOT, GRID, [TAB]], [ROOT, GRID, TABS, [ROW]], // [ROOT, GRID, TABS, TAB, [TABS]], // @TODO this needs to be fixed [ROOT, GRID, ROW, [TABS]], [ROOT, GRID, ROW, [TAB]], [ROOT, GRID, ROW, [DIVIDER]], [ROOT, GRID, ROW, COLUMN, [TAB]], [ROOT, GRID, ROW, COLUMN, ROW, [DIVIDER]], [ROOT, GRID, ROW, COLUMN, ROW, COLUMN, [ROW]], // too nested ]; invalidExamples.forEach((example, exampleIdx) => { let childDepth = 0; example.forEach((childType, i) => { // should test child if (i > 0 && Array.isArray(childType)) { const parentDepth = childDepth - 1; const parentType = example[i - 1]; if (typeof parentType !== 'string') throw TypeError('parent must be string'); it(`(${exampleIdx})${getIndentation( childDepth, )}${parentType} (depth ${parentDepth}) > ${childType} ❌`, () => { expect( isValidChild({ parentDepth, parentType, childType: childType[0], }), ).toBe(false); }); } // see isValidChild.js for why tabs do not increment the depth of their children childDepth += childType !== TABS && childType !== TAB ? 1 : 0; }); }); }); });
7,452
0
petrpan-code/apache/superset/superset-frontend/src/dashboard
petrpan-code/apache/superset/superset-frontend/src/dashboard/util/permissionUtils.test.ts
/** * 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 * as uiCore from '@superset-ui/core'; import { UndefinedUser, UserWithPermissionsAndRoles, } from 'src/types/bootstrapTypes'; import { Dashboard } from 'src/types/Dashboard'; import Owner from 'src/types/Owner'; import { userHasPermission, canUserEditDashboard, canUserSaveAsDashboard, isUserAdmin, } from './permissionUtils'; const ownerUser: UserWithPermissionsAndRoles = { createdOn: '2021-05-12T16:56:22.116839', email: '[email protected]', firstName: 'Test', isActive: true, isAnonymous: false, lastName: 'User', userId: 1, username: 'owner', permissions: {}, roles: { Alpha: [['can_write', 'Dashboard']] }, }; const adminUser: UserWithPermissionsAndRoles = { ...ownerUser, roles: { ...(ownerUser?.roles || {}), Admin: [['can_write', 'Dashboard']], }, userId: 2, username: 'admin', }; const outsiderUser: UserWithPermissionsAndRoles = { ...ownerUser, userId: 3, username: 'outsider', }; const owner: Owner = { first_name: 'Test', id: ownerUser.userId!, last_name: 'User', }; const sqlLabMenuAccessPermission: [string, string] = ['menu_access', 'SQL Lab']; const arbitraryPermissions: [string, string][] = [ ['can_write', 'AnArbitraryView'], sqlLabMenuAccessPermission, ]; const sqlLabUser: UserWithPermissionsAndRoles = { ...ownerUser, roles: { ...ownerUser.roles, sql_lab: [sqlLabMenuAccessPermission], }, }; const undefinedUser: UndefinedUser = {}; const dashboard: Dashboard = { id: 1, dashboard_title: 'Test Dash', url: 'https://dashboard.example.com/1', thumbnail_url: 'https://dashboard.example.com/1/thumbnail.png', published: true, css: null, changed_by_name: 'Test User', changed_by: owner, changed_on: '2021-05-12T16:56:22.116839', charts: [], owners: [owner], roles: [], }; let isFeatureEnabledMock: jest.MockInstance< boolean, [feature: uiCore.FeatureFlag] >; describe('canUserEditDashboard', () => { it('allows owners to edit', () => { expect(canUserEditDashboard(dashboard, ownerUser)).toEqual(true); }); it('allows admin users to edit regardless of ownership', () => { expect(canUserEditDashboard(dashboard, adminUser)).toEqual(true); }); it('rejects non-owners', () => { expect(canUserEditDashboard(dashboard, outsiderUser)).toEqual(false); }); it('rejects nonexistent users', () => { expect(canUserEditDashboard(dashboard, null)).toEqual(false); }); it('rejects missing roles', () => { // in redux, when there is no user, the user is actually set to an empty object, // so we need to handle missing roles as well as a missing user.s expect(canUserEditDashboard(dashboard, {})).toEqual(false); }); it('rejects "admins" if the admin role does not have edit rights for some reason', () => { expect( canUserEditDashboard(dashboard, { ...adminUser, roles: { Admin: [] }, }), ).toEqual(false); }); }); test('isUserAdmin returns true for admin user', () => { expect(isUserAdmin(adminUser)).toEqual(true); }); test('isUserAdmin returns false for undefined', () => { expect(isUserAdmin(undefined)).toEqual(false); }); test('isUserAdmin returns false for undefined user', () => { expect(isUserAdmin(undefinedUser)).toEqual(false); }); test('isUserAdmin returns false for non-admin user', () => { expect(isUserAdmin(ownerUser)).toEqual(false); }); test('userHasPermission always returns true for admin user', () => { arbitraryPermissions.forEach(permissionView => { expect( userHasPermission(adminUser, permissionView[1], permissionView[0]), ).toEqual(true); }); }); test('userHasPermission always returns false for undefined user', () => { arbitraryPermissions.forEach(permissionView => { expect( userHasPermission(undefinedUser, permissionView[1], permissionView[0]), ).toEqual(false); }); }); test('userHasPermission returns false if user does not have permission', () => { expect( userHasPermission( ownerUser, sqlLabMenuAccessPermission[1], sqlLabMenuAccessPermission[0], ), ).toEqual(false); }); test('userHasPermission returns true if user has permission', () => { expect( userHasPermission( sqlLabUser, sqlLabMenuAccessPermission[1], sqlLabMenuAccessPermission[0], ), ).toEqual(true); }); describe('canUserSaveAsDashboard with RBAC feature flag disabled', () => { beforeAll(() => { isFeatureEnabledMock = jest .spyOn(uiCore, 'isFeatureEnabled') .mockImplementation( (featureFlag: uiCore.FeatureFlag) => featureFlag !== uiCore.FeatureFlag.DASHBOARD_RBAC, ); }); afterAll(() => { // @ts-ignore isFeatureEnabledMock.restore(); }); it('allows owners', () => { expect(canUserSaveAsDashboard(dashboard, ownerUser)).toEqual(true); }); it('allows admin users', () => { expect(canUserSaveAsDashboard(dashboard, adminUser)).toEqual(true); }); it('allows non-owners', () => { expect(canUserSaveAsDashboard(dashboard, outsiderUser)).toEqual(true); }); }); describe('canUserSaveAsDashboard with RBAC feature flag enabled', () => { beforeAll(() => { isFeatureEnabledMock = jest .spyOn(uiCore, 'isFeatureEnabled') .mockImplementation( (featureFlag: uiCore.FeatureFlag) => featureFlag === uiCore.FeatureFlag.DASHBOARD_RBAC, ); }); afterAll(() => { // @ts-ignore isFeatureEnabledMock.restore(); }); it('allows owners', () => { expect(canUserSaveAsDashboard(dashboard, ownerUser)).toEqual(true); }); it('allows admin users', () => { expect(canUserSaveAsDashboard(dashboard, adminUser)).toEqual(true); }); it('reject non-owners', () => { expect(canUserSaveAsDashboard(dashboard, outsiderUser)).toEqual(false); }); });
7,463
0
petrpan-code/apache/superset/superset-frontend/src/dashboard
petrpan-code/apache/superset/superset-frontend/src/dashboard/util/useFilterFocusHighlightStyles.test.tsx
/** * 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 React from 'react'; import { combineReducers, createStore, applyMiddleware, compose } from 'redux'; import thunk from 'redux-thunk'; import mockState from 'spec/fixtures/mockState'; import reducerIndex from 'spec/helpers/reducerIndex'; import { screen, render } from 'spec/helpers/testing-library'; import { initialState } from 'src/SqlLab/fixtures'; import { dashboardFilters } from 'spec/fixtures/mockDashboardFilters'; import { dashboardWithFilter } from 'spec/fixtures/mockDashboardLayout'; import { buildActiveFilters } from './activeDashboardFilters'; import useFilterFocusHighlightStyles from './useFilterFocusHighlightStyles'; const TestComponent = ({ chartId }: { chartId: number }) => { const styles = useFilterFocusHighlightStyles(chartId); return <div data-test="test-component" style={styles} />; }; describe('useFilterFocusHighlightStyles', () => { const createMockStore = (customState: any = {}) => createStore( combineReducers(reducerIndex), { ...mockState, ...(initialState as any), ...customState }, compose(applyMiddleware(thunk)), ); const renderWrapper = (chartId: number, store = createMockStore()) => render(<TestComponent chartId={chartId} />, { useRouter: true, useDnd: true, useRedux: true, store, }); it('should return no style if filter not in scope', async () => { renderWrapper(10); const container = screen.getByTestId('test-component'); const styles = getComputedStyle(container); expect(styles.opacity).toBeFalsy(); }); it('should return unfocused styles if chart is not in scope of focused native filter', async () => { const store = createMockStore({ nativeFilters: { focusedFilterId: 'test-filter', filters: { otherId: { chartsInScope: [], }, }, }, }); renderWrapper(10, store); const container = screen.getByTestId('test-component'); const styles = getComputedStyle(container); expect(parseFloat(styles.opacity)).toBe(0.3); }); it('should return unfocused styles if chart is not in scope of hovered native filter', async () => { const store = createMockStore({ nativeFilters: { hoveredFilterId: 'test-filter', filters: { otherId: { chartsInScope: [], }, }, }, }); renderWrapper(10, store); const container = screen.getByTestId('test-component'); const styles = getComputedStyle(container); expect(parseFloat(styles.opacity)).toBe(0.3); }); it('should return focused styles if chart is in scope of focused native filter', async () => { const chartId = 18; const store = createMockStore({ nativeFilters: { focusedFilterId: 'testFilter', filters: { testFilter: { chartsInScope: [chartId], }, }, }, }); renderWrapper(chartId, store); const container = screen.getByTestId('test-component'); const styles = getComputedStyle(container); expect(parseFloat(styles.opacity)).toBe(1); }); it('should return focused styles if chart is in scope of hovered native filter', async () => { const chartId = 18; const store = createMockStore({ nativeFilters: { hoveredFilterId: 'testFilter', filters: { testFilter: { chartsInScope: [chartId], }, }, }, }); renderWrapper(chartId, store); const container = screen.getByTestId('test-component'); const styles = getComputedStyle(container); expect(parseFloat(styles.opacity)).toBe(1); }); it('should return unfocused styles if focusedFilterField is targeting a different chart', async () => { const chartId = 18; const store = createMockStore({ dashboardState: { focusedFilterField: { chartId: 10, column: 'test', }, }, dashboardFilters: { 10: { scopes: {}, }, }, }); renderWrapper(chartId, store); const container = screen.getByTestId('test-component'); const styles = getComputedStyle(container); expect(parseFloat(styles.opacity)).toBe(0.3); }); it('should return focused styles if focusedFilterField chart equals our own', async () => { const chartId = 18; const store = createMockStore({ dashboardState: { focusedFilterField: { chartId, column: 'test', }, }, dashboardFilters: { [chartId]: { scopes: { otherColumn: {}, }, }, }, }); renderWrapper(chartId, store); const container = screen.getByTestId('test-component'); const styles = getComputedStyle(container); expect(parseFloat(styles.opacity)).toBe(1); }); it('should return unfocused styles if chart is not inside filter box scope', async () => { buildActiveFilters({ dashboardFilters, components: dashboardWithFilter, }); const chartId = 18; const store = createMockStore({ dashboardState: { focusedFilterField: { chartId, column: 'test', }, }, dashboardFilters: { [chartId]: { scopes: { column: {}, }, }, }, }); renderWrapper(20, store); const container = screen.getByTestId('test-component'); const styles = getComputedStyle(container); expect(parseFloat(styles.opacity)).toBe(0.3); }); it('should return focused styles if chart is inside filter box scope', async () => { buildActiveFilters({ dashboardFilters, components: dashboardWithFilter, }); const chartId = 18; const store = createMockStore({ dashboardState: { focusedFilterField: { chartId, column: 'test', }, }, dashboardFilters: { [chartId]: { scopes: { column: {}, }, }, }, }); renderWrapper(chartId, store); const container = screen.getByTestId('test-component'); const styles = getComputedStyle(container); expect(parseFloat(styles.opacity)).toBe(1); }); });
7,483
0
petrpan-code/apache/superset/superset-frontend/src/explore
petrpan-code/apache/superset/superset-frontend/src/explore/actions/datasourcesActions.test.ts
/** * 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 { DatasourceType } from '@superset-ui/core'; import fetchMock from 'fetch-mock'; import { setDatasource, changeDatasource, saveDataset, } from 'src/explore/actions/datasourcesActions'; import sinon from 'sinon'; import * as ClientError from 'src/utils/getClientErrorObject'; import datasourcesReducer from '../reducers/datasourcesReducer'; import { updateFormDataByDatasource } from './exploreActions'; const CURRENT_DATASOURCE = { id: 1, uid: '1__table', type: DatasourceType.Table, columns: [], metrics: [], column_formats: {}, currency_formats: {}, verbose_map: {}, main_dttm_col: '__timestamp', // eg. ['["ds", true]', 'ds [asc]'] datasource_name: 'test datasource', description: null, }; const NEW_DATASOURCE = { id: 2, type: DatasourceType.Table, columns: [], metrics: [], column_formats: {}, currency_formats: {}, verbose_map: {}, main_dttm_col: '__timestamp', // eg. ['["ds", true]', 'ds [asc]'] datasource_name: 'test datasource', description: null, }; const SAVE_DATASET_POST_ARGS = { schema: 'foo', sql: 'select * from bar', database: { id: 1 }, templateParams: undefined, datasourceName: 'new dataset', columns: [], }; const defaultDatasourcesReducerState = { [CURRENT_DATASOURCE.uid]: CURRENT_DATASOURCE, }; const saveDatasetEndpoint = `glob:*/api/v1/dataset/`; test('sets new datasource', () => { const newState = datasourcesReducer( defaultDatasourcesReducerState, setDatasource(NEW_DATASOURCE), ); expect(newState).toEqual({ ...defaultDatasourcesReducerState, '2__table': NEW_DATASOURCE, }); }); test('change datasource action', () => { const dispatch = jest.fn(); const getState = jest.fn(() => ({ explore: { datasource: CURRENT_DATASOURCE, }, })); // ignore getState type check - we dont need explore.datasource field for this test // @ts-ignore changeDatasource(NEW_DATASOURCE)(dispatch, getState); expect(dispatch).toHaveBeenCalledTimes(2); expect(dispatch).toHaveBeenNthCalledWith(1, setDatasource(NEW_DATASOURCE)); expect(dispatch).toHaveBeenNthCalledWith( 2, updateFormDataByDatasource(CURRENT_DATASOURCE, NEW_DATASOURCE), ); }); test('saveDataset handles success', async () => { const datasource = { id: 1 }; const saveDatasetResponse = { data: datasource, }; fetchMock.reset(); fetchMock.post(saveDatasetEndpoint, saveDatasetResponse); const dispatch = sinon.spy(); const getState = sinon.spy(() => ({ explore: { datasource } })); const dataset = await saveDataset(SAVE_DATASET_POST_ARGS)(dispatch); expect(fetchMock.calls(saveDatasetEndpoint)).toHaveLength(1); expect(dispatch.callCount).toBe(1); const thunk = dispatch.getCall(0).args[0]; thunk(dispatch, getState); expect(dispatch.getCall(1).args[0].type).toEqual('SET_DATASOURCE'); expect(dataset).toEqual(datasource); }); test('updateSlice with add to existing dashboard handles failure', async () => { fetchMock.reset(); const sampleError = new Error('sampleError'); fetchMock.post(saveDatasetEndpoint, { throws: sampleError }); const dispatch = sinon.spy(); const errorSpy = jest.spyOn(ClientError, 'getClientErrorObject'); let caughtError; try { await saveDataset(SAVE_DATASET_POST_ARGS)(dispatch); } catch (error) { caughtError = error; } expect(caughtError).toEqual(sampleError); expect(fetchMock.calls(saveDatasetEndpoint)).toHaveLength(4); expect(errorSpy).toHaveBeenCalledWith(sampleError); });
7,487
0
petrpan-code/apache/superset/superset-frontend/src/explore
petrpan-code/apache/superset/superset-frontend/src/explore/actions/hydrateExplore.test.ts
/** * 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 { hydrateExplore, HYDRATE_EXPLORE } from './hydrateExplore'; import { exploreInitialData } from '../fixtures'; test('creates hydrate action from initial data', () => { const dispatch = jest.fn(); const getState = jest.fn(() => ({ user: {}, charts: {}, datasources: {}, common: {}, explore: {}, })); // ignore type check - we dont need exact explore state for this test // @ts-ignore hydrateExplore(exploreInitialData)(dispatch, getState); expect(dispatch).toHaveBeenCalledWith( expect.objectContaining({ type: HYDRATE_EXPLORE, data: { charts: { 371: { id: 371, chartAlert: null, chartStatus: null, chartStackTrace: null, chartUpdateEndTime: null, chartUpdateStartTime: 0, latestQueryFormData: { cache_timeout: undefined, datasource: '8__table', slice_id: 371, url_params: undefined, viz_type: 'table', }, sliceFormData: { cache_timeout: undefined, datasource: '8__table', slice_id: 371, url_params: undefined, viz_type: 'table', }, queryController: null, queriesResponse: null, triggerQuery: false, lastRendered: 0, }, }, datasources: { '8__table': exploreInitialData.dataset, }, saveModal: { dashboards: [], saveModalAlert: null, isVisible: false, }, explore: { can_add: false, can_download: false, can_overwrite: false, isDatasourceMetaLoading: false, isStarred: false, triggerRender: false, datasource: exploreInitialData.dataset, controls: expect.any(Object), form_data: exploreInitialData.form_data, slice: exploreInitialData.slice, standalone: null, force: null, saveAction: null, common: {}, }, }, }), ); }); test('creates hydrate action with existing state', () => { const dispatch = jest.fn(); const getState = jest.fn(() => ({ user: {}, charts: {}, datasources: {}, common: {}, explore: { controlsTransferred: ['all_columns'] }, })); // ignore type check - we dont need exact explore state for this test // @ts-ignore hydrateExplore(exploreInitialData)(dispatch, getState); expect(dispatch).toHaveBeenCalledWith( expect.objectContaining({ type: HYDRATE_EXPLORE, data: { charts: { 371: { id: 371, chartAlert: null, chartStatus: null, chartStackTrace: null, chartUpdateEndTime: null, chartUpdateStartTime: 0, latestQueryFormData: { cache_timeout: undefined, datasource: '8__table', slice_id: 371, url_params: undefined, viz_type: 'table', }, sliceFormData: { cache_timeout: undefined, datasource: '8__table', slice_id: 371, url_params: undefined, viz_type: 'table', }, queryController: null, queriesResponse: null, triggerQuery: false, lastRendered: 0, }, }, datasources: { '8__table': exploreInitialData.dataset, }, saveModal: { dashboards: [], saveModalAlert: null, isVisible: false, }, explore: { can_add: false, can_download: false, can_overwrite: false, isDatasourceMetaLoading: false, isStarred: false, triggerRender: false, datasource: exploreInitialData.dataset, controls: expect.any(Object), controlsTransferred: ['all_columns'], form_data: exploreInitialData.form_data, slice: exploreInitialData.slice, standalone: null, force: null, saveAction: null, common: {}, }, }, }), ); }); test('uses configured default time range if not set', () => { const dispatch = jest.fn(); const getState = jest.fn(() => ({ user: {}, charts: {}, datasources: {}, common: { conf: { DEFAULT_TIME_FILTER: 'Last year', }, }, explore: {}, })); // @ts-ignore hydrateExplore({ form_data: {}, slice: {}, dataset: {} })(dispatch, getState); expect(dispatch).toHaveBeenCalledWith( expect.objectContaining({ data: expect.objectContaining({ explore: expect.objectContaining({ form_data: expect.objectContaining({ time_range: 'Last year', }), }), }), }), ); const withTimeRangeSet = { form_data: { time_range: 'Last day' }, slice: {}, dataset: {}, }; // @ts-ignore hydrateExplore(withTimeRangeSet)(dispatch, getState); expect(dispatch).toHaveBeenCalledWith( expect.objectContaining({ data: expect.objectContaining({ explore: expect.objectContaining({ form_data: expect.objectContaining({ time_range: 'Last day', }), }), }), }), ); });
7,492
0
petrpan-code/apache/superset/superset-frontend/src/explore
petrpan-code/apache/superset/superset-frontend/src/explore/components/Control.test.tsx
/** * 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 { mount } from 'enzyme'; import { ThemeProvider, supersetTheme, promiseTimeout, } from '@superset-ui/core'; import React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import Control, { ControlProps } from 'src/explore/components/Control'; const defaultProps: ControlProps = { type: 'CheckboxControl', name: 'checkbox', value: true, actions: { setControlValue: jest.fn(), }, }; const setup = (overrides = {}) => ( <ThemeProvider theme={supersetTheme}> <Control {...defaultProps} {...overrides} /> </ThemeProvider> ); describe('Control', () => { it('render a control', () => { render(setup()); const checkbox = screen.getByRole('checkbox'); expect(checkbox).toBeVisible(); }); it('render null if type is not exit', () => { render( setup({ type: undefined, }), ); expect(screen.queryByRole('checkbox')).not.toBeInTheDocument(); }); it('render null if type is not valid', () => { render( setup({ type: 'UnknownControl', }), ); expect(screen.queryByRole('checkbox')).not.toBeInTheDocument(); }); it('render null if isVisible is false', () => { render( setup({ isVisible: false, }), ); expect(screen.queryByRole('checkbox')).not.toBeInTheDocument(); }); it('call setControlValue if isVisible is false', () => { const wrapper = mount( setup({ isVisible: true, default: false, }), ); wrapper.setProps({ isVisible: false, default: false, }); promiseTimeout(() => { expect(defaultProps.actions.setControlValue).toBeCalled(); }, 100); }); });
7,496
0
petrpan-code/apache/superset/superset-frontend/src/explore
petrpan-code/apache/superset/superset-frontend/src/explore/components/ControlPanelsContainer.test.tsx
/** * 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 React from 'react'; import userEvent from '@testing-library/user-event'; import { render, screen } from 'spec/helpers/testing-library'; import { DatasourceType, getChartControlPanelRegistry, t, } from '@superset-ui/core'; import { defaultControls } from 'src/explore/store'; import { getFormDataFromControls } from 'src/explore/controlUtils'; import { ControlPanelsContainer, ControlPanelsContainerProps, } from 'src/explore/components/ControlPanelsContainer'; describe('ControlPanelsContainer', () => { beforeAll(() => { getChartControlPanelRegistry().registerValue('table', { controlPanelSections: [ { label: t('GROUP BY'), description: t( 'Use this section if you want a query that aggregates', ), expanded: true, controlSetRows: [ ['groupby'], ['metrics'], ['percent_metrics'], ['timeseries_limit_metric', 'row_limit'], ['include_time', 'order_desc'], ], }, { label: t('NOT GROUPED BY'), description: t('Use this section if you want to query atomic rows'), expanded: true, controlSetRows: [ ['all_columns'], ['order_by_cols'], ['row_limit', null], ], }, { label: t('Query'), expanded: true, controlSetRows: [['adhoc_filters']], }, { label: t('Options'), expanded: true, controlSetRows: [ ['table_timestamp_format'], ['page_length', null], ['include_search', 'table_filter'], ['align_pn', 'color_pn'], ], }, ], }); }); afterAll(() => { getChartControlPanelRegistry().remove('table'); }); function getDefaultProps() { const controls = defaultControls as ControlPanelsContainerProps['controls']; return { datasource_type: DatasourceType.Table, actions: {}, controls, form_data: getFormDataFromControls(controls), isDatasourceMetaLoading: false, exploreState: {}, chart: { queriesResponse: null, chartStatus: 'success', }, } as ControlPanelsContainerProps; } test('renders ControlPanelSections', async () => { render(<ControlPanelsContainer {...getDefaultProps()} />, { useRedux: true, }); expect( await screen.findAllByTestId('collapsible-control-panel-header'), ).toHaveLength(4); expect(screen.getByRole('tab', { name: /customize/i })).toBeInTheDocument(); userEvent.click(screen.getByRole('tab', { name: /customize/i })); expect( await screen.findAllByTestId('collapsible-control-panel-header'), ).toHaveLength(5); }); test('renders ControlPanelSections no Customize Tab', async () => { getChartControlPanelRegistry().registerValue('table', { controlPanelSections: [ { label: t('GROUP BY'), description: t( 'Use this section if you want a query that aggregates', ), expanded: true, controlSetRows: [ ['groupby'], ['metrics'], ['percent_metrics'], ['timeseries_limit_metric', 'row_limit'], ['include_time', 'order_desc'], ], }, { label: t('Options'), expanded: true, controlSetRows: [], }, ], }); render(<ControlPanelsContainer {...getDefaultProps()} />, { useRedux: true, }); expect(screen.queryByText(/customize/i)).not.toBeInTheDocument(); expect( await screen.findAllByTestId('collapsible-control-panel-header'), ).toHaveLength(2); }); });
7,498
0
petrpan-code/apache/superset/superset-frontend/src/explore
petrpan-code/apache/superset/superset-frontend/src/explore/components/ControlRow.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import ControlSetRow from 'src/explore/components/ControlRow'; const MockControl = (props: { children: React.ReactElement; type?: string; isVisible?: boolean; }) => <div>{props.children}</div>; describe('ControlSetRow', () => { it('renders a single row with one element', () => { render(<ControlSetRow controls={[<p>My Control 1</p>]} />); expect(screen.getAllByText('My Control 1').length).toBe(1); }); it('renders a single row with two elements', () => { render( <ControlSetRow controls={[<p>My Control 1</p>, <p>My Control 2</p>]} />, ); expect(screen.getAllByText(/My Control/)).toHaveLength(2); }); it('renders a single row with one elements if is HiddenControl', () => { render( <ControlSetRow controls={[ <p>My Control 1</p>, <MockControl type="HiddenControl"> <p>My Control 2</p> </MockControl>, ]} />, ); expect(screen.getAllByText(/My Control/)).toHaveLength(2); }); it('renders a single row with one elements if is invisible', () => { render( <ControlSetRow controls={[ <p>My Control 1</p>, <MockControl isVisible={false}> <p>My Control 2</p> </MockControl>, ]} />, ); expect(screen.getAllByText(/My Control/)).toHaveLength(2); }); });
7,508
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/DataTableControl/CopyButton.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import { CopyButton } from '.'; test('Render a button', () => { render(<CopyButton>btn</CopyButton>); expect(screen.getByRole('button')).toBeInTheDocument(); expect(screen.getByRole('button')).toHaveClass('superset-button'); });
7,509
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/DataTableControl/CopyToClipboardButton.test.tsx
/** * 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 userEvent from '@testing-library/user-event'; import React from 'react'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; import { CopyToClipboardButton } from '.'; test('Render a button', () => { render(<CopyToClipboardButton data={{ copy: 'data', data: 'copy' }} />, { useRedux: true, }); expect(screen.getByRole('button')).toBeInTheDocument(); }); test('Should copy to clipboard', async () => { const callback = jest.fn(); document.execCommand = callback; const originalClipboard = { ...global.navigator.clipboard }; // @ts-ignore global.navigator.clipboard = { write: callback, writeText: callback }; render(<CopyToClipboardButton data={{ copy: 'data', data: 'copy' }} />, { useRedux: true, }); expect(callback).toHaveBeenCalledTimes(0); userEvent.click(screen.getByRole('button')); await waitFor(() => { expect(callback).toHaveBeenCalled(); }); jest.resetAllMocks(); // @ts-ignore global.navigator.clipboard = originalClipboard; });
7,510
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/DataTableControl/FilterInput.test.tsx
/** * 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 userEvent from '@testing-library/user-event'; import React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import { FilterInput } from '.'; jest.mock('lodash/debounce', () => ({ __esModule: true, default: (fuc: Function) => fuc, })); test('Render a FilterInput', async () => { const onChangeHandler = jest.fn(); render(<FilterInput onChangeHandler={onChangeHandler} />); expect(await screen.findByRole('textbox')).toBeInTheDocument(); expect(onChangeHandler).toBeCalledTimes(0); userEvent.type(screen.getByRole('textbox'), 'test'); expect(onChangeHandler).toBeCalledTimes(4); });
7,511
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/DataTableControl/RowCount.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import { RowCount } from '.'; test('Render a RowCount with a single row', () => { render(<RowCount data={[{}]} loading={false} />); expect(screen.getByText('1 row')).toBeInTheDocument(); }); test('Render a RowCount with multiple rows', () => { render(<RowCount data={[{}, {}, {}]} loading={false} />); expect(screen.getByText('3 rows')).toBeInTheDocument(); }); test('Render a RowCount on loading', () => { render(<RowCount data={[{}, {}, {}]} loading />); expect(screen.getByText('Loading...')).toBeInTheDocument(); });
7,513
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/DataTableControl/useFilteredTableData.test.ts
/** * 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 { renderHook } from '@testing-library/react-hooks'; import { useFilteredTableData } from '.'; const data = [ { col01: 'some', col02: 'data' }, { col01: 'any', col02: 'data' }, { col01: 'some', col02: 'thing' }, { col01: 'any', col02: 'things' }, ]; test('Empty filter', () => { const hook = renderHook(() => useFilteredTableData('', data)); expect(hook.result.current).toEqual(data); }); test('Filter by the word "data"', () => { const hook = renderHook(() => useFilteredTableData('data', data)); expect(hook.result.current).toEqual([ { col01: 'some', col02: 'data' }, { col01: 'any', col02: 'data' }, ]); }); test('Filter by the word "thing"', () => { const hook = renderHook(() => useFilteredTableData('thing', data)); expect(hook.result.current).toEqual([ { col01: 'some', col02: 'thing' }, { col01: 'any', col02: 'things' }, ]); }); test('Filter by the word "any"', () => { const hook = renderHook(() => useFilteredTableData('any', data)); expect(hook.result.current).toEqual([ { col01: 'any', col02: 'data' }, { col01: 'any', col02: 'things' }, ]); });
7,514
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/DataTableControl/useTableColumns.test.ts
/** * 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 { GenericDataType } from '@superset-ui/core'; import { renderHook } from '@testing-library/react-hooks'; import { BOOL_FALSE_DISPLAY, BOOL_TRUE_DISPLAY } from 'src/constants'; import { useTableColumns } from '.'; // eslint-disable-next-line @typescript-eslint/no-explicit-any type JsonObject = { [member: string]: any }; const asciiChars = []; for (let i = 32; i < 127; i += 1) { asciiChars.push(String.fromCharCode(i)); } const ASCII_KEY = asciiChars.join(''); const UNICODE_KEY = '你好. 吃了吗?'; const NUMTIME_KEY = 'numtime'; const STRTIME_KEY = 'strtime'; const NUMTIME_VALUE = 1640995200000; const NUMTIME_FORMATTED_VALUE = '2022-01-01 00:00:00'; const STRTIME_VALUE = '2022-01-01'; const colnames = [ 'col01', 'col02', ASCII_KEY, UNICODE_KEY, NUMTIME_KEY, STRTIME_KEY, ]; const coltypes = [ GenericDataType.BOOLEAN, GenericDataType.BOOLEAN, GenericDataType.STRING, GenericDataType.STRING, GenericDataType.TEMPORAL, GenericDataType.TEMPORAL, ]; const cellValues = { col01: true, col02: false, [ASCII_KEY]: ASCII_KEY, [UNICODE_KEY]: UNICODE_KEY, [NUMTIME_KEY]: NUMTIME_VALUE, [STRTIME_KEY]: STRTIME_VALUE, }; const data = [cellValues, cellValues, cellValues, cellValues]; const expectedDisplayValues = { col01: BOOL_TRUE_DISPLAY, col02: BOOL_FALSE_DISPLAY, [ASCII_KEY]: ASCII_KEY, [UNICODE_KEY]: UNICODE_KEY, [NUMTIME_KEY]: NUMTIME_FORMATTED_VALUE, [STRTIME_KEY]: STRTIME_VALUE, }; test('useTableColumns with no options', () => { const hook = renderHook(() => useTableColumns(colnames, coltypes, data)); expect(hook.result.current).toEqual([ { Cell: expect.any(Function), Header: 'col01', accessor: expect.any(Function), id: 'col01', }, { Cell: expect.any(Function), Header: 'col02', accessor: expect.any(Function), id: 'col02', }, { Cell: expect.any(Function), Header: ASCII_KEY, accessor: expect.any(Function), id: ASCII_KEY, }, { Cell: expect.any(Function), Header: UNICODE_KEY, accessor: expect.any(Function), id: UNICODE_KEY, }, { Cell: expect.any(Function), Header: expect.objectContaining({ type: expect.objectContaining({ name: 'DataTableTemporalHeaderCell', }), props: expect.objectContaining({ onTimeColumnChange: expect.any(Function), }), }), accessor: expect.any(Function), id: NUMTIME_KEY, }, { Cell: expect.any(Function), Header: STRTIME_KEY, accessor: expect.any(Function), id: STRTIME_KEY, }, ]); hook.result.current.forEach((col: JsonObject) => { expect(col.accessor(data[0])).toBe(data[0][col.id]); }); hook.result.current.forEach((col: JsonObject) => { data.forEach(row => { expect(col.Cell({ value: row[col.id] })).toBe( expectedDisplayValues[col.id], ); }); }); }); test('useTableColumns with options', () => { const hook = renderHook(() => useTableColumns(colnames, coltypes, data, undefined, true, { col01: { Header: 'Header' }, }), ); expect(hook.result.current).toEqual([ { Cell: expect.any(Function), Header: 'Header', accessor: expect.any(Function), id: 'col01', }, { Cell: expect.any(Function), Header: 'col02', accessor: expect.any(Function), id: 'col02', }, { Cell: expect.any(Function), Header: ASCII_KEY, accessor: expect.any(Function), id: ASCII_KEY, }, { Cell: expect.any(Function), Header: UNICODE_KEY, accessor: expect.any(Function), id: UNICODE_KEY, }, { Cell: expect.any(Function), Header: expect.objectContaining({ type: expect.objectContaining({ name: 'DataTableTemporalHeaderCell', }), props: expect.objectContaining({ onTimeColumnChange: expect.any(Function), }), }), accessor: expect.any(Function), id: NUMTIME_KEY, }, { Cell: expect.any(Function), Header: STRTIME_KEY, accessor: expect.any(Function), id: STRTIME_KEY, }, ]); hook.result.current.forEach((col: JsonObject) => { expect(col.accessor(data[0])).toBe(data[0][col.id]); }); hook.result.current.forEach((col: JsonObject) => { data.forEach(row => { expect(col.Cell({ value: row[col.id] })).toBe( expectedDisplayValues[col.id], ); }); }); });
7,525
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/DataTablesPane
petrpan-code/apache/superset/superset-frontend/src/explore/components/DataTablesPane/test/DataTablesPane.test.tsx
/** * 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 React from 'react'; import userEvent from '@testing-library/user-event'; import fetchMock from 'fetch-mock'; import { FeatureFlag } from '@superset-ui/core'; import * as copyUtils from 'src/utils/copy'; import { render, screen, waitForElementToBeRemoved, } from 'spec/helpers/testing-library'; import { setItem, LocalStorageKeys } from 'src/utils/localStorageHelpers'; import { DataTablesPane } from '..'; import { createDataTablesPaneProps } from './fixture'; describe('DataTablesPane', () => { // Collapsed/expanded state depends on local storage // We need to clear it manually - otherwise initial state would depend on the order of tests beforeEach(() => { localStorage.clear(); }); afterAll(() => { localStorage.clear(); }); test('Rendering DataTablesPane correctly', async () => { const props = createDataTablesPaneProps(0); render(<DataTablesPane {...props} />, { useRedux: true }); expect(await screen.findByText('Results')).toBeVisible(); expect(screen.getByText('Samples')).toBeVisible(); expect(screen.getByLabelText('Expand data panel')).toBeVisible(); }); test('Collapse/Expand buttons', async () => { const props = createDataTablesPaneProps(0); render(<DataTablesPane {...props} />, { useRedux: true, }); expect( screen.queryByLabelText('Collapse data panel'), ).not.toBeInTheDocument(); userEvent.click(screen.getByLabelText('Expand data panel')); expect(await screen.findByLabelText('Collapse data panel')).toBeVisible(); expect( screen.queryByLabelText('Expand data panel'), ).not.toBeInTheDocument(); }); test('Should show tabs: View results', async () => { const props = createDataTablesPaneProps(0); render(<DataTablesPane {...props} />, { useRedux: true, }); userEvent.click(screen.getByText('Results')); expect(await screen.findByText('0 rows')).toBeVisible(); expect(await screen.findByLabelText('Collapse data panel')).toBeVisible(); localStorage.clear(); }); test('Should show tabs: View samples', async () => { const props = createDataTablesPaneProps(0); render(<DataTablesPane {...props} />, { useRedux: true, }); userEvent.click(screen.getByText('Samples')); expect(await screen.findByText('0 rows')).toBeVisible(); expect(await screen.findByLabelText('Collapse data panel')).toBeVisible(); }); test('Should copy data table content correctly', async () => { fetchMock.post( 'glob:*/api/v1/chart/data?form_data=%7B%22slice_id%22%3A456%7D', { result: [ { data: [{ __timestamp: 1230768000000, genre: 'Action' }], colnames: ['__timestamp', 'genre'], coltypes: [2, 1], }, ], }, ); const copyToClipboardSpy = jest.spyOn(copyUtils, 'default'); const props = createDataTablesPaneProps(456); render(<DataTablesPane {...props} />, { useRedux: true, }); userEvent.click(screen.getByText('Results')); expect(await screen.findByText('1 row')).toBeVisible(); userEvent.click(screen.getByLabelText('Copy')); expect(copyToClipboardSpy).toHaveBeenCalledTimes(1); const value = await copyToClipboardSpy.mock.calls[0][0](); expect(value).toBe('__timestamp\tgenre\n2009-01-01 00:00:00\tAction\n'); copyToClipboardSpy.mockRestore(); fetchMock.restore(); }); test('Search table', async () => { fetchMock.post( 'glob:*/api/v1/chart/data?form_data=%7B%22slice_id%22%3A789%7D', { result: [ { data: [ { __timestamp: 1230768000000, genre: 'Action' }, { __timestamp: 1230768000010, genre: 'Horror' }, ], colnames: ['__timestamp', 'genre'], coltypes: [2, 1], }, ], }, ); const props = createDataTablesPaneProps(789); render(<DataTablesPane {...props} />, { useRedux: true, }); userEvent.click(screen.getByText('Results')); expect(await screen.findByText('2 rows')).toBeVisible(); expect(screen.getByText('Action')).toBeVisible(); expect(screen.getByText('Horror')).toBeVisible(); userEvent.type(screen.getByPlaceholderText('Search'), 'hor'); await waitForElementToBeRemoved(() => screen.queryByText('Action')); expect(screen.getByText('Horror')).toBeVisible(); expect(screen.queryByText('Action')).not.toBeInTheDocument(); fetchMock.restore(); }); test('Displaying the data pane is under featureflag', () => { // @ts-ignore global.featureFlags = { [FeatureFlag.DATAPANEL_CLOSED_BY_DEFAULT]: true, }; const props = createDataTablesPaneProps(0); setItem(LocalStorageKeys.is_datapanel_open, true); render(<DataTablesPane {...props} />, { useRedux: true, }); expect( screen.queryByLabelText('Collapse data panel'), ).not.toBeInTheDocument(); }); });
7,526
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/DataTablesPane
petrpan-code/apache/superset/superset-frontend/src/explore/components/DataTablesPane/test/ResultsPaneOnDashboard.test.tsx
/** * 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 React from 'react'; import fetchMock from 'fetch-mock'; import userEvent from '@testing-library/user-event'; import { render, waitForElementToBeRemoved, waitFor, } from 'spec/helpers/testing-library'; import { exploreActions } from 'src/explore/actions/exploreActions'; import { ChartMetadata, ChartPlugin } from '@superset-ui/core'; import { ResultsPaneOnDashboard } from '../components'; import { createResultsPaneOnDashboardProps } from './fixture'; describe('ResultsPaneOnDashboard', () => { // render and render errorMessage fetchMock.post( 'end:/api/v1/chart/data?form_data=%7B%22slice_id%22%3A121%7D', { result: [], }, ); // force query, render and search fetchMock.post( 'end:/api/v1/chart/data?form_data=%7B%22slice_id%22%3A144%7D&force=true', { result: [ { data: [ { __timestamp: 1230768000000, genre: 'Action' }, { __timestamp: 1230768000010, genre: 'Horror' }, ], colnames: ['__timestamp', 'genre'], coltypes: [2, 1], }, ], }, ); // error response fetchMock.post( 'end:/api/v1/chart/data?form_data=%7B%22slice_id%22%3A169%7D', 400, ); // multiple results pane fetchMock.post( 'end:/api/v1/chart/data?form_data=%7B%22slice_id%22%3A196%7D', { result: [ { data: [ { __timestamp: 1230768000000 }, { __timestamp: 1230768000010 }, ], colnames: ['__timestamp'], coltypes: [2], }, { data: [{ genre: 'Action' }, { genre: 'Horror' }], colnames: ['genre'], coltypes: [1], }, ], }, ); const setForceQuery = jest.spyOn(exploreActions, 'setForceQuery'); afterAll(() => { fetchMock.reset(); jest.resetAllMocks(); }); test('render', async () => { const props = createResultsPaneOnDashboardProps({ sliceId: 121 }); const { findByText } = render(<ResultsPaneOnDashboard {...props} />, { useRedux: true, }); expect( await findByText('No results were returned for this query'), ).toBeVisible(); }); test('render errorMessage', async () => { const props = createResultsPaneOnDashboardProps({ sliceId: 121, errorMessage: <p>error</p>, }); const { findByText } = render(<ResultsPaneOnDashboard {...props} />, { useRedux: true, }); expect(await findByText('Run a query to display results')).toBeVisible(); }); test('error response', async () => { const props = createResultsPaneOnDashboardProps({ sliceId: 169, }); const { findByText } = render(<ResultsPaneOnDashboard {...props} />, { useRedux: true, }); expect(await findByText('0 rows')).toBeVisible(); expect(await findByText('Bad Request')).toBeVisible(); }); test('force query, render and search', async () => { const props = createResultsPaneOnDashboardProps({ sliceId: 144, queryForce: true, }); const { queryByText, getByPlaceholderText } = render( <ResultsPaneOnDashboard {...props} />, { useRedux: true, }, ); await waitFor(() => { expect(setForceQuery).toHaveBeenCalledTimes(1); }); expect(queryByText('2 rows')).toBeVisible(); expect(queryByText('Action')).toBeVisible(); expect(queryByText('Horror')).toBeVisible(); userEvent.type(getByPlaceholderText('Search'), 'hor'); await waitForElementToBeRemoved(() => queryByText('Action')); expect(queryByText('Horror')).toBeVisible(); expect(queryByText('Action')).not.toBeInTheDocument(); }); test('multiple results pane', async () => { const FakeChart = () => <span>test</span>; const metadata = new ChartMetadata({ name: 'test-chart', thumbnail: '', queryObjectCount: 2, }); const plugin = new ChartPlugin({ metadata, Chart: FakeChart, }); plugin.configure({ key: 'mixed_timeseries' }).register(); const props = createResultsPaneOnDashboardProps({ sliceId: 196, vizType: 'mixed_timeseries', }); const { findByText } = render(<ResultsPaneOnDashboard {...props} />, { useRedux: true, }); expect(await findByText('Results')).toBeVisible(); expect(await findByText('Results 2')).toBeVisible(); }); });
7,527
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/DataTablesPane
petrpan-code/apache/superset/superset-frontend/src/explore/components/DataTablesPane/test/SamplesPane.test.tsx
/** * 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 React from 'react'; import fetchMock from 'fetch-mock'; import userEvent from '@testing-library/user-event'; import { render, waitForElementToBeRemoved, waitFor, } from 'spec/helpers/testing-library'; import { exploreActions } from 'src/explore/actions/exploreActions'; import { SamplesPane } from '../components'; import { createSamplesPaneProps } from './fixture'; describe('SamplesPane', () => { fetchMock.post( 'end:/datasource/samples?force=false&datasource_type=table&datasource_id=34', { result: { data: [], colnames: [], coltypes: [], }, }, ); fetchMock.post( 'end:/datasource/samples?force=true&datasource_type=table&datasource_id=35', { result: { data: [ { __timestamp: 1230768000000, genre: 'Action' }, { __timestamp: 1230768000010, genre: 'Horror' }, ], colnames: ['__timestamp', 'genre'], coltypes: [2, 1], }, }, ); fetchMock.post( 'end:/datasource/samples?force=false&datasource_type=table&datasource_id=36', 400, ); const setForceQuery = jest.spyOn(exploreActions, 'setForceQuery'); afterAll(() => { fetchMock.reset(); jest.resetAllMocks(); }); test('render', async () => { const props = createSamplesPaneProps({ datasourceId: 34 }); const { findByText } = render(<SamplesPane {...props} />); expect( await findByText('No samples were returned for this dataset'), ).toBeVisible(); await waitFor(() => { expect(setForceQuery).toHaveBeenCalledTimes(0); }); }); test('error response', async () => { const props = createSamplesPaneProps({ datasourceId: 36, }); const { findByText } = render(<SamplesPane {...props} />, { useRedux: true, }); expect(await findByText('Error: Bad Request')).toBeVisible(); }); test('force query, render and search', async () => { const props = createSamplesPaneProps({ datasourceId: 35, queryForce: true, }); const { queryByText, getByPlaceholderText } = render( <SamplesPane {...props} />, { useRedux: true, }, ); await waitFor(() => { expect(setForceQuery).toHaveBeenCalledTimes(1); }); expect(queryByText('2 rows')).toBeVisible(); expect(queryByText('Action')).toBeVisible(); expect(queryByText('Horror')).toBeVisible(); userEvent.type(getByPlaceholderText('Search'), 'hor'); await waitForElementToBeRemoved(() => queryByText('Action')); expect(queryByText('Horror')).toBeVisible(); expect(queryByText('Action')).not.toBeInTheDocument(); }); });
7,529
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/DatasourcePanel/DatasourcePanel.test.tsx
/** * 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 React from 'react'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import DatasourcePanel, { IDatasource, Props as DatasourcePanelProps, } from 'src/explore/components/DatasourcePanel'; import { columns, metrics, } from 'src/explore/components/DatasourcePanel/fixtures'; import { DatasourceType } from '@superset-ui/core'; import DatasourceControl from 'src/explore/components/controls/DatasourceControl'; const datasource: IDatasource = { id: 1, type: DatasourceType.Table, columns, metrics, database: { id: 1, }, datasource_name: 'table1', }; const mockUser = { createdOn: '2021-04-27T18:12:38.952304', email: 'admin', firstName: 'admin', isActive: true, lastName: 'admin', permissions: {}, roles: { Admin: Array(173) }, userId: 1, username: 'admin', isAnonymous: false, }; const props: DatasourcePanelProps = { datasource, controls: { datasource: { validationErrors: null, mapStateToProps: () => ({ value: undefined }), type: DatasourceControl, label: 'hello', datasource, user: mockUser, }, }, actions: { setControlValue: jest.fn(), }, }; const search = (value: string, input: HTMLElement) => { userEvent.clear(input); userEvent.type(input, value); }; test('should render', async () => { const { container } = render(<DatasourcePanel {...props} />, { useRedux: true, useDnd: true, }); expect(await screen.findByText(/metrics/i)).toBeInTheDocument(); expect(container).toBeVisible(); }); test('should display items in controls', async () => { render(<DatasourcePanel {...props} />, { useRedux: true, useDnd: true }); expect(await screen.findByText('Metrics')).toBeInTheDocument(); expect(screen.getByText('Columns')).toBeInTheDocument(); }); test('should render the metrics', async () => { render(<DatasourcePanel {...props} />, { useRedux: true, useDnd: true }); const metricsNum = metrics.length; metrics.forEach(metric => expect(screen.getByText(metric.metric_name)).toBeInTheDocument(), ); expect( await screen.findByText(`Showing ${metricsNum} of ${metricsNum}`), ).toBeInTheDocument(); }); test('should render the columns', async () => { render(<DatasourcePanel {...props} />, { useRedux: true, useDnd: true }); const columnsNum = columns.length; columns.forEach(col => expect(screen.getByText(col.column_name)).toBeInTheDocument(), ); expect( await screen.findByText(`Showing ${columnsNum} of ${columnsNum}`), ).toBeInTheDocument(); }); test('should render 0 search results', async () => { render(<DatasourcePanel {...props} />, { useRedux: true, useDnd: true }); const searchInput = screen.getByPlaceholderText('Search Metrics & Columns'); search('nothing', searchInput); expect(await screen.findAllByText('Showing 0 of 0')).toHaveLength(2); }); test('should search and render matching columns', async () => { render(<DatasourcePanel {...props} />, { useRedux: true, useDnd: true }); const searchInput = screen.getByPlaceholderText('Search Metrics & Columns'); search(columns[0].column_name, searchInput); await waitFor(() => { expect(screen.getByText(columns[0].column_name)).toBeInTheDocument(); expect(screen.queryByText(columns[1].column_name)).not.toBeInTheDocument(); }); }); test('should search and render matching metrics', async () => { render(<DatasourcePanel {...props} />, { useRedux: true, useDnd: true }); const searchInput = screen.getByPlaceholderText('Search Metrics & Columns'); search(metrics[0].metric_name, searchInput); await waitFor(() => { expect(screen.getByText(metrics[0].metric_name)).toBeInTheDocument(); expect(screen.queryByText(metrics[1].metric_name)).not.toBeInTheDocument(); }); }); test('should render a warning', async () => { const deprecatedDatasource = { ...datasource, extra: JSON.stringify({ warning_markdown: 'This is a warning.' }), }; const newProps = { ...props, datasource: deprecatedDatasource, controls: { datasource: { ...props.controls.datasource, datasource: deprecatedDatasource, user: mockUser, }, }, }; render(<DatasourcePanel {...newProps} />, { useRedux: true, useDnd: true }); expect( await screen.findByRole('img', { name: 'alert-solid' }), ).toBeInTheDocument(); }); test('should render a create dataset infobox', async () => { const newProps = { ...props, datasource: { ...datasource, type: DatasourceType.Query, }, }; render(<DatasourcePanel {...newProps} />, { useRedux: true, useDnd: true }); const createButton = await screen.findByRole('button', { name: /create a dataset/i, }); const infoboxText = screen.getByText(/to edit or add columns and metrics./i); expect(createButton).toBeVisible(); expect(infoboxText).toBeVisible(); }); test('should not render a save dataset modal when datasource is not query or dataset', async () => { const newProps = { ...props, datasource: { ...datasource, type: DatasourceType.Table, }, }; render(<DatasourcePanel {...newProps} />, { useRedux: true, useDnd: true }); expect(await screen.findByText(/metrics/i)).toBeInTheDocument(); expect(screen.queryByText(/create a dataset/i)).toBe(null); });
7,533
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/DatasourcePanel
petrpan-code/apache/superset/superset-frontend/src/explore/components/DatasourcePanel/DatasourcePanelDragOption/DatasourcePanelDragOption.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import { DndItemType } from 'src/explore/components/DndItemType'; import DatasourcePanelDragOption from '.'; test('should render', async () => { render( <DatasourcePanelDragOption value={{ metric_name: 'test' }} type={DndItemType.Metric} />, { useDnd: true }, ); expect( await screen.findByTestId('DatasourcePanelDragOption'), ).toBeInTheDocument(); expect(screen.getByText('test')).toBeInTheDocument(); }); test('should have attribute draggable:true', async () => { render( <DatasourcePanelDragOption value={{ metric_name: 'test' }} type={DndItemType.Metric} />, { useDnd: true }, ); expect( await screen.findByTestId('DatasourcePanelDragOption'), ).toHaveAttribute('draggable', 'true'); });
7,535
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx
/** * 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 React from 'react'; import sinon from 'sinon'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import fetchMock from 'fetch-mock'; import * as chartAction from 'src/components/Chart/chartAction'; import * as saveModalActions from 'src/explore/actions/saveModalActions'; import * as downloadAsImage from 'src/utils/downloadAsImage'; import * as exploreUtils from 'src/explore/exploreUtils'; import { FeatureFlag } from '@superset-ui/core'; import ExploreHeader from '.'; const chartEndpoint = 'glob:*api/v1/chart/*'; fetchMock.get(chartEndpoint, { json: 'foo' }); window.featureFlags = { [FeatureFlag.EMBEDDABLE_CHARTS]: true, }; const createProps = (additionalProps = {}) => ({ chart: { id: 1, latestQueryFormData: { viz_type: 'histogram', datasource: '49__table', slice_id: 318, url_params: {}, granularity_sqla: 'time_start', time_range: 'No filter', all_columns_x: ['age'], adhoc_filters: [], row_limit: 10000, groupby: null, color_scheme: 'supersetColors', label_colors: {}, link_length: '25', x_axis_label: 'age', y_axis_label: 'count', }, chartStatus: 'rendered', }, slice: { cache_timeout: null, changed_on: '2021-03-19T16:30:56.750230', changed_on_humanized: '7 days ago', datasource: 'FCC 2018 Survey', description: 'Simple description', description_markeddown: '', edit_url: '/chart/edit/318', form_data: { adhoc_filters: [], all_columns_x: ['age'], color_scheme: 'supersetColors', datasource: '49__table', granularity_sqla: 'time_start', groupby: null, label_colors: {}, link_length: '25', queryFields: { groupby: 'groupby' }, row_limit: 10000, slice_id: 318, time_range: 'No filter', url_params: {}, viz_type: 'histogram', x_axis_label: 'age', y_axis_label: 'count', }, modified: '<span class="no-wrap">7 days ago</span>', owners: [ { text: 'Superset Admin', value: 1, }, ], slice_id: 318, slice_name: 'Age distribution of respondents', slice_url: '/explore/?form_data=%7B%22slice_id%22%3A%20318%7D', }, slice_name: 'Age distribution of respondents', actions: { postChartFormData: jest.fn(), updateChartTitle: jest.fn(), fetchFaveStar: jest.fn(), saveFaveStar: jest.fn(), redirectSQLLab: jest.fn(), }, user: { userId: 1, }, metadata: { created_on_humanized: 'a week ago', changed_on_humanized: '2 days ago', owners: ['John Doe'], created_by: 'John Doe', changed_by: 'John Doe', dashboards: [{ id: 1, dashboard_title: 'Test' }], }, canOverwrite: false, canDownload: false, isStarred: false, ...additionalProps, }); fetchMock.post( 'http://api/v1/chart/data?form_data=%7B%22slice_id%22%3A318%7D', { body: {} }, { sendAsJson: false, }, ); test('Cancelling changes to the properties should reset previous properties', async () => { const props = createProps(); render(<ExploreHeader {...props} />, { useRedux: true }); const newChartName = 'New chart name'; const prevChartName = props.slice_name; expect( await screen.findByText(/add the name of the chart/i), ).toBeInTheDocument(); userEvent.click(screen.getByLabelText('Menu actions trigger')); userEvent.click(screen.getByText('Edit chart properties')); const nameInput = await screen.findByRole('textbox', { name: 'Name' }); userEvent.clear(nameInput); userEvent.type(nameInput, newChartName); expect(screen.getByDisplayValue(newChartName)).toBeInTheDocument(); userEvent.click(screen.getByRole('button', { name: 'Cancel' })); userEvent.click(screen.getByLabelText('Menu actions trigger')); userEvent.click(screen.getByText('Edit chart properties')); expect(await screen.findByDisplayValue(prevChartName)).toBeInTheDocument(); }); test('renders the metadata bar when saved', async () => { const props = createProps({ showTitlePanelItems: true }); render(<ExploreHeader {...props} />, { useRedux: true }); expect(await screen.findByText('Added to 1 dashboard')).toBeInTheDocument(); expect(await screen.findByText('Simple description')).toBeInTheDocument(); expect(await screen.findByText('John Doe')).toBeInTheDocument(); expect(await screen.findByText('2 days ago')).toBeInTheDocument(); }); test('Changes "Added to X dashboards" to plural when more than 1 dashboard', async () => { const props = createProps({ showTitlePanelItems: true }); render( <ExploreHeader {...props} metadata={{ ...props.metadata, dashboards: [ { id: 1, dashboard_title: 'Test' }, { id: 2, dashboard_title: 'Test2' }, ], }} />, { useRedux: true }, ); expect(await screen.findByText('Added to 2 dashboards')).toBeInTheDocument(); }); test('does not render the metadata bar when not saved', async () => { const props = createProps({ showTitlePanelItems: true, slice: null }); render(<ExploreHeader {...props} />, { useRedux: true }); await waitFor(() => expect(screen.queryByText('Added to 1 dashboard')).not.toBeInTheDocument(), ); }); test('Save chart', async () => { const setSaveChartModalVisibility = jest.spyOn( saveModalActions, 'setSaveChartModalVisibility', ); const props = createProps(); render(<ExploreHeader {...props} />, { useRedux: true }); expect(await screen.findByText('Save')).toBeInTheDocument(); userEvent.click(screen.getByText('Save')); expect(setSaveChartModalVisibility).toHaveBeenCalledWith(true); setSaveChartModalVisibility.mockClear(); }); test('Save disabled', async () => { const setSaveChartModalVisibility = jest.spyOn( saveModalActions, 'setSaveChartModalVisibility', ); const props = createProps(); render(<ExploreHeader {...props} saveDisabled />, { useRedux: true }); expect(await screen.findByText('Save')).toBeInTheDocument(); userEvent.click(screen.getByText('Save')); expect(setSaveChartModalVisibility).not.toHaveBeenCalled(); setSaveChartModalVisibility.mockClear(); }); describe('Additional actions tests', () => { test('Should render a button', async () => { const props = createProps(); render(<ExploreHeader {...props} />, { useRedux: true }); expect( await screen.findByLabelText('Menu actions trigger'), ).toBeInTheDocument(); }); test('Should open a menu', async () => { const props = createProps(); render(<ExploreHeader {...props} />, { useRedux: true, }); userEvent.click(screen.getByLabelText('Menu actions trigger')); expect( await screen.findByText('Edit chart properties'), ).toBeInTheDocument(); expect(screen.getByText('Download')).toBeInTheDocument(); expect(screen.getByText('Share')).toBeInTheDocument(); expect(screen.getByText('View query')).toBeInTheDocument(); expect(screen.getByText('Run in SQL Lab')).toBeInTheDocument(); expect( screen.queryByText('Set up an email report'), ).not.toBeInTheDocument(); expect(screen.queryByText('Manage email report')).not.toBeInTheDocument(); }); test('Should open download submenu', async () => { const props = createProps(); render(<ExploreHeader {...props} />, { useRedux: true, }); userEvent.click(screen.getByLabelText('Menu actions trigger')); expect(screen.queryByText('Export to .CSV')).not.toBeInTheDocument(); expect(screen.queryByText('Export to .JSON')).not.toBeInTheDocument(); expect(screen.queryByText('Download as image')).not.toBeInTheDocument(); expect(screen.getByText('Download')).toBeInTheDocument(); userEvent.hover(screen.getByText('Download')); expect(await screen.findByText('Export to .CSV')).toBeInTheDocument(); expect(await screen.findByText('Export to .JSON')).toBeInTheDocument(); expect(await screen.findByText('Download as image')).toBeInTheDocument(); }); test('Should open share submenu', async () => { const props = createProps(); render(<ExploreHeader {...props} />, { useRedux: true, }); userEvent.click(screen.getByLabelText('Menu actions trigger')); expect( screen.queryByText('Copy permalink to clipboard'), ).not.toBeInTheDocument(); expect(screen.queryByText('Embed code')).not.toBeInTheDocument(); expect(screen.queryByText('Share chart by email')).not.toBeInTheDocument(); expect(screen.getByText('Share')).toBeInTheDocument(); userEvent.hover(screen.getByText('Share')); expect( await screen.findByText('Copy permalink to clipboard'), ).toBeInTheDocument(); expect(await screen.findByText('Embed code')).toBeInTheDocument(); expect(await screen.findByText('Share chart by email')).toBeInTheDocument(); }); test('Should call onOpenPropertiesModal when click on "Edit chart properties"', async () => { const props = createProps(); render(<ExploreHeader {...props} />, { useRedux: true, }); expect(props.actions.redirectSQLLab).toBeCalledTimes(0); userEvent.click(screen.getByLabelText('Menu actions trigger')); userEvent.click( screen.getByRole('menuitem', { name: 'Edit chart properties' }), ); expect(await screen.findByText('Edit Chart Properties')).toBeVisible(); }); test('Should call getChartDataRequest when click on "View query"', async () => { const props = createProps(); const getChartDataRequest = jest.spyOn(chartAction, 'getChartDataRequest'); render(<ExploreHeader {...props} />, { useRedux: true, }); expect(getChartDataRequest).toBeCalledTimes(0); userEvent.click(screen.getByLabelText('Menu actions trigger')); expect(getChartDataRequest).toBeCalledTimes(0); const menuItem = screen.getByText('View query').parentElement!; userEvent.click(menuItem); await waitFor(() => expect(getChartDataRequest).toBeCalledTimes(1)); }); test('Should call onOpenInEditor when click on "Run in SQL Lab"', async () => { const props = createProps(); render(<ExploreHeader {...props} />, { useRedux: true, }); expect(await screen.findByText('Save')).toBeInTheDocument(); expect(props.actions.redirectSQLLab).toBeCalledTimes(0); userEvent.click(screen.getByLabelText('Menu actions trigger')); expect(props.actions.redirectSQLLab).toBeCalledTimes(0); userEvent.click(screen.getByRole('menuitem', { name: 'Run in SQL Lab' })); expect(props.actions.redirectSQLLab).toBeCalledTimes(1); }); describe('Download', () => { let spyDownloadAsImage = sinon.spy(); let spyExportChart = sinon.spy(); beforeEach(() => { spyDownloadAsImage = sinon.spy(downloadAsImage, 'default'); spyExportChart = sinon.spy(exploreUtils, 'exportChart'); }); afterEach(() => { spyDownloadAsImage.restore(); spyExportChart.restore(); }); test('Should call downloadAsImage when click on "Download as image"', async () => { const props = createProps(); const spy = jest.spyOn(downloadAsImage, 'default'); render(<ExploreHeader {...props} />, { useRedux: true, }); expect(spy).toBeCalledTimes(0); userEvent.click(screen.getByLabelText('Menu actions trigger')); expect(spy).toBeCalledTimes(0); userEvent.hover(screen.getByText('Download')); const downloadAsImageElement = await screen.findByText( 'Download as image', ); userEvent.click(downloadAsImageElement); expect(spy).toBeCalledTimes(1); }); test('Should not export to CSV if canDownload=false', async () => { const props = createProps(); render(<ExploreHeader {...props} />, { useRedux: true, }); userEvent.click(screen.getByLabelText('Menu actions trigger')); userEvent.hover(screen.getByText('Download')); const exportCSVElement = await screen.findByText('Export to .CSV'); userEvent.click(exportCSVElement); expect(spyExportChart.callCount).toBe(0); spyExportChart.restore(); }); test('Should export to CSV if canDownload=true', async () => { const props = createProps(); props.canDownload = true; render(<ExploreHeader {...props} />, { useRedux: true, }); userEvent.click(screen.getByLabelText('Menu actions trigger')); userEvent.hover(screen.getByText('Download')); const exportCSVElement = await screen.findByText('Export to .CSV'); userEvent.click(exportCSVElement); expect(spyExportChart.callCount).toBe(1); spyExportChart.restore(); }); test('Should export to JSON', async () => { const props = createProps(); render(<ExploreHeader {...props} />, { useRedux: true, }); userEvent.click(screen.getByLabelText('Menu actions trigger')); userEvent.hover(screen.getByText('Download')); const exportJsonElement = await screen.findByText('Export to .JSON'); userEvent.click(exportJsonElement); expect(spyExportChart.callCount).toBe(1); }); test('Should export to pivoted CSV if canDownloadCSV=true and viz_type=pivot_table_v2', async () => { const props = createProps(); props.canDownload = true; props.chart.latestQueryFormData.viz_type = 'pivot_table_v2'; render(<ExploreHeader {...props} />, { useRedux: true, }); userEvent.click(screen.getByLabelText('Menu actions trigger')); userEvent.hover(screen.getByText('Download')); const exportCSVElement = await screen.findByText( 'Export to pivoted .CSV', ); userEvent.click(exportCSVElement); expect(spyExportChart.callCount).toBe(1); }); }); });
7,540
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/ExploreViewContainer/ExploreViewContainer.test.tsx
/** * 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 React from 'react'; import fetchMock from 'fetch-mock'; import { getChartControlPanelRegistry, getChartMetadataRegistry, ChartMetadata, } from '@superset-ui/core'; import { MemoryRouter, Route } from 'react-router-dom'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import ExploreViewContainer from '.'; const reduxState = { explore: { controls: { datasource: { value: '1__table' }, viz_type: { value: 'table' }, }, datasource: { id: 1, type: 'table', columns: [{ is_dttm: false }], metrics: [{ id: 1, metric_name: 'count' }], }, isStarred: false, slice: { slice_id: 1, }, metadata: { created_on_humanized: 'a week ago', changed_on_humanized: '2 days ago', owners: ['John Doe'], created_by: 'John Doe', changed_by: 'John Doe', dashboards: [{ id: 1, dashboard_title: 'Test' }], }, }, charts: { 1: { id: 1, latestQueryFormData: { datasource: '1__table', }, }, }, user: { userId: 1, }, common: { conf: { SUPERSET_WEBSERVER_TIMEOUT: 60 } }, datasources: { '1__table': { id: 1, type: 'table', columns: [{ is_dttm: false }], metrics: [{ id: 1, metric_name: 'count' }], }, }, }; const KEY = 'aWrs7w29sd'; const SEARCH = `?form_data_key=${KEY}&dataset_id=1`; jest.mock( 'src/explore/components/ExploreChartPanel/useResizeDetectorByObserver', () => ({ __esModule: true, default: () => ({ height: 100, width: 100 }), }), ); jest.mock('lodash/debounce', () => ({ __esModule: true, default: (fuc: Function) => fuc, })); fetchMock.post('glob:*/api/v1/explore/form_data*', { key: KEY }); fetchMock.put('glob:*/api/v1/explore/form_data*', { key: KEY }); fetchMock.get('glob:*/api/v1/explore/form_data*', {}); fetchMock.get('glob:*/api/v1/chart/favorite_status*', { result: [{ value: true }], }); fetchMock.get('glob:*/api/v1/chart/*', { result: {}, }); const defaultPath = '/explore/'; const renderWithRouter = ({ search = '', overridePathname, initialState = reduxState, }: { search?: string; overridePathname?: string; initialState?: object; } = {}) => { const path = overridePathname ?? defaultPath; Object.defineProperty(window, 'location', { get() { return { pathname: path, search }; }, }); return render( <MemoryRouter initialEntries={[`${path}${search}`]}> <Route path={path}> <ExploreViewContainer /> </Route> </MemoryRouter>, { useRedux: true, initialState }, ); }; test('generates a new form_data param when none is available', async () => { getChartMetadataRegistry().registerValue( 'table', new ChartMetadata({ name: 'fake table', thumbnail: '.png', useLegacyApi: false, }), ); const replaceState = jest.spyOn(window.history, 'replaceState'); await waitFor(() => renderWithRouter()); expect(replaceState).toHaveBeenCalledWith( expect.anything(), undefined, expect.stringMatching('form_data_key'), ); expect(replaceState).toHaveBeenCalledWith( expect.anything(), undefined, expect.stringMatching('datasource_id'), ); replaceState.mockRestore(); }); test('renders chart in standalone mode', () => { const { queryByTestId } = renderWithRouter({ initialState: { ...reduxState, explore: { ...reduxState.explore, standalone: true }, }, }); expect(queryByTestId('standalone-app')).toBeTruthy(); }); test('generates a different form_data param when one is provided and is mounting', async () => { const replaceState = jest.spyOn(window.history, 'replaceState'); await waitFor(() => renderWithRouter({ search: SEARCH })); expect(replaceState).not.toHaveBeenLastCalledWith( 0, expect.anything(), undefined, expect.stringMatching(KEY), ); expect(replaceState).toHaveBeenCalledWith( expect.anything(), undefined, expect.stringMatching('datasource_id'), ); replaceState.mockRestore(); }); test('reuses the same form_data param when updating', async () => { getChartControlPanelRegistry().registerValue('table', { controlPanelSections: [], }); const replaceState = jest.spyOn(window.history, 'replaceState'); const pushState = jest.spyOn(window.history, 'pushState'); await waitFor(() => renderWithRouter({ search: SEARCH })); expect(replaceState.mock.calls.length).toBe(1); userEvent.click(screen.getByText('Update chart')); await waitFor(() => expect(pushState.mock.calls.length).toBe(1)); expect(replaceState.mock.calls[0]).toEqual(pushState.mock.calls[0]); replaceState.mockRestore(); pushState.mockRestore(); getChartControlPanelRegistry().remove('table'); }); test('doesnt call replaceState when pathname is not /explore', async () => { getChartMetadataRegistry().registerValue( 'table', new ChartMetadata({ name: 'fake table', thumbnail: '.png', useLegacyApi: false, }), ); const replaceState = jest.spyOn(window.history, 'replaceState'); await waitFor(() => renderWithRouter({ overridePathname: '/dashboard' })); expect(replaceState).not.toHaveBeenCalled(); replaceState.mockRestore(); }); test('preserves unknown parameters', async () => { const replaceState = jest.spyOn(window.history, 'replaceState'); const unknownParam = 'test=123'; await waitFor(() => renderWithRouter({ search: `${SEARCH}&${unknownParam}` }), ); expect(replaceState).toHaveBeenCalledWith( expect.anything(), undefined, expect.stringMatching(unknownParam), ); replaceState.mockRestore(); });
7,542
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/ExportToCSVDropdown/ExportToCSVDropdown.test.tsx
/** * 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 React from 'react'; import userEvent from '@testing-library/user-event'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; import { ExportToCSVDropdown } from './index'; const exportCSVOriginal = jest.fn(); const exportCSVPivoted = jest.fn(); const waitForRender = () => { waitFor(() => render( <ExportToCSVDropdown exportCSVOriginal={exportCSVOriginal} exportCSVPivoted={exportCSVPivoted} > <div>.CSV</div> </ExportToCSVDropdown>, ), ); }; test('Dropdown button with menu renders', () => { waitForRender(); expect(screen.getByText('.CSV')).toBeVisible(); userEvent.click(screen.getByText('.CSV')); expect(screen.getByRole('menu')).toBeInTheDocument(); expect(screen.getByText('Original')).toBeInTheDocument(); expect(screen.getByText('Pivoted')).toBeInTheDocument(); }); test('Call export csv original on click', () => { waitForRender(); userEvent.click(screen.getByText('.CSV')); userEvent.click(screen.getByText('Original')); expect(exportCSVOriginal).toHaveBeenCalled(); }); test('Call export csv pivoted on click', () => { waitForRender(); userEvent.click(screen.getByText('.CSV')); userEvent.click(screen.getByText('Pivoted')); expect(exportCSVPivoted).toHaveBeenCalled(); });
7,544
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/PropertiesModal/PropertiesModal.test.tsx
/** * 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 React from 'react'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; import fetchMock from 'fetch-mock'; import userEvent from '@testing-library/user-event'; import PropertiesModal, { PropertiesModalProps } from '.'; const createProps = () => ({ slice: { cache_timeout: null, certified_by: 'John Doe', certification_details: 'Sample certification', description: null, slice_id: 318, slice_name: 'Age distribution of respondents', is_managed_externally: false, }, show: true, onHide: jest.fn(), onSave: jest.fn(), addSuccessToast: jest.fn(), } as PropertiesModalProps); fetchMock.get('glob:*/api/v1/chart/318', { body: { description_columns: {}, id: 318, label_columns: { cache_timeout: 'Cache Timeout', 'dashboards.dashboard_title': 'Dashboards Dashboard Title', 'dashboards.id': 'Dashboards Id', description: 'Description', 'owners.first_name': 'Owners First Name', 'owners.id': 'Owners Id', 'owners.last_name': 'Owners Last Name', 'owners.username': 'Owners Username', params: 'Params', slice_name: 'Slice Name', viz_type: 'Viz Type', }, result: { cache_timeout: null, certified_by: 'John Doe', certification_details: 'Sample certification', dashboards: [ { dashboard_title: 'FCC New Coder Survey 2018', id: 23, }, ], description: null, owners: [ { first_name: 'Superset', id: 1, last_name: 'Admin', username: 'admin', }, ], params: '{"adhoc_filters": [], "all_columns_x": ["age"], "color_scheme": "supersetColors", "datasource": "42__table", "granularity_sqla": "time_start", "groupby": null, "label_colors": {}, "link_length": "25", "queryFields": {"groupby": "groupby"}, "row_limit": 10000, "slice_id": 1380, "time_range": "No filter", "url_params": {}, "viz_type": "histogram", "x_axis_label": "age", "y_axis_label": "count"}', slice_name: 'Age distribution of respondents', viz_type: 'histogram', }, show_columns: [ 'cache_timeout', 'dashboards.dashboard_title', 'dashboards.id', 'description', 'owners.first_name', 'owners.id', 'owners.last_name', 'owners.username', 'params', 'slice_name', 'viz_type', ], show_title: 'Show Slice', }, }); fetchMock.get('glob:*/api/v1/chart/related/owners?q=(filter:%27%27)', { body: { count: 1, result: [ { text: 'Superset Admin', value: 1, }, ], }, sendAsJson: true, }); fetchMock.put('glob:*/api/v1/chart/318', { body: { id: 318, result: { cache_timeout: null, certified_by: 'John Doe', certification_details: 'Sample certification', description: null, owners: [], slice_name: 'Age distribution of respondents', }, }, sendAsJson: true, }); afterAll(() => { fetchMock.resetBehavior(); }); const renderModal = (props: PropertiesModalProps) => render(<PropertiesModal {...props} />, { useRedux: true }); test('Should render null when show:false', async () => { const props = createProps(); props.show = false; renderModal(props); await waitFor(() => { expect( screen.queryByRole('dialog', { name: 'Edit Chart Properties' }), ).not.toBeInTheDocument(); }); }); test('Should render when show:true', async () => { const props = createProps(); renderModal(props); await waitFor(() => { expect( screen.getByRole('dialog', { name: 'Edit Chart Properties' }), ).toBeVisible(); }); }); test('Should have modal header', async () => { const props = createProps(); renderModal(props); await waitFor(() => { expect(screen.getByText('Edit Chart Properties')).toBeVisible(); expect(screen.getByText('×')).toBeVisible(); expect(screen.getByRole('button', { name: 'Close' })).toBeVisible(); }); }); test('"Close" button should call "onHide"', async () => { const props = createProps(); renderModal(props); await waitFor(() => { expect(props.onHide).toBeCalledTimes(0); }); userEvent.click(screen.getByRole('button', { name: 'Close' })); await waitFor(() => { expect(props.onHide).toBeCalledTimes(1); expect(props.onSave).toBeCalledTimes(0); }); }); test('Should render all elements inside modal', async () => { const props = createProps(); renderModal(props); await waitFor(() => { expect(screen.getAllByRole('textbox')).toHaveLength(5); expect(screen.getByRole('combobox')).toBeInTheDocument(); expect( screen.getByRole('heading', { name: 'Basic information' }), ).toBeVisible(); expect(screen.getByText('Name')).toBeVisible(); expect(screen.getByText('Description')).toBeVisible(); expect( screen.getByRole('heading', { name: 'Configuration' }), ).toBeVisible(); expect(screen.getByText('Cache timeout')).toBeVisible(); expect(screen.getByRole('heading', { name: 'Access' })).toBeVisible(); expect(screen.getByText('Owners')).toBeVisible(); expect( screen.getByRole('heading', { name: 'Configuration' }), ).toBeVisible(); expect(screen.getByText('Certified by')).toBeVisible(); expect(screen.getByText('Certification details')).toBeVisible(); }); }); test('Should have modal footer', async () => { const props = createProps(); renderModal(props); await waitFor(() => { expect(screen.getByText('Cancel')).toBeVisible(); expect(screen.getByRole('button', { name: 'Cancel' })).toBeVisible(); expect(screen.getByText('Save')).toBeVisible(); expect(screen.getByRole('button', { name: 'Save' })).toBeVisible(); expect(screen.getByRole('button', { name: 'Save' })).toBeEnabled(); }); }); test('"Cancel" button should call "onHide"', async () => { const props = createProps(); renderModal(props); await waitFor(() => { expect(props.onHide).toBeCalledTimes(0); }); userEvent.click(screen.getByRole('button', { name: 'Cancel' })); await waitFor(() => { expect(props.onHide).toBeCalledTimes(1); expect(props.onSave).toBeCalledTimes(0); }); }); test('"Save" button should call only "onSave"', async () => { const props = createProps(); renderModal(props); await waitFor(() => { expect(props.onSave).toBeCalledTimes(0); expect(props.onHide).toBeCalledTimes(0); expect(screen.getByRole('button', { name: 'Save' })).toBeEnabled(); }); userEvent.click(screen.getByRole('button', { name: 'Save' })); await waitFor(() => { expect(props.onSave).toBeCalledTimes(1); expect(props.onHide).toBeCalledTimes(1); }); }); test('Empty "Certified by" should clear "Certification details"', async () => { const props = createProps(); const noCertifiedByProps = { ...props, slice: { ...props.slice, certified_by: '', }, }; renderModal(noCertifiedByProps); expect( await screen.findByRole('textbox', { name: 'Certification details' }), ).toBeInTheDocument(); expect( screen.getByRole('textbox', { name: 'Certification details' }), ).toHaveValue(''); }); test('"Name" should not be empty', async () => { const props = createProps(); renderModal(props); const name = screen.getByRole('textbox', { name: 'Name' }); userEvent.clear(name); expect(name).toHaveValue(''); userEvent.click(screen.getByRole('button', { name: 'Save' })); await waitFor(() => { expect(props.onSave).toBeCalledTimes(0); }); }); test('"Name" should not be empty when saved', async () => { const props = createProps(); renderModal(props); const name = screen.getByRole('textbox', { name: 'Name' }); userEvent.clear(name); userEvent.type(name, 'Test chart new name'); expect(name).toHaveValue('Test chart new name'); userEvent.click(screen.getByRole('button', { name: 'Save' })); await waitFor(() => { expect(props.onSave).toBeCalledTimes(1); expect(props.onSave).toBeCalledWith( expect.objectContaining({ slice_name: 'Test chart new name' }), ); }); }); test('"Cache timeout" should not be empty when saved', async () => { const props = createProps(); renderModal(props); const cacheTimeout = screen.getByRole('textbox', { name: 'Cache timeout' }); userEvent.clear(cacheTimeout); userEvent.type(cacheTimeout, '1000'); expect(cacheTimeout).toHaveValue('1000'); userEvent.click(screen.getByRole('button', { name: 'Save' })); await waitFor(() => { expect(props.onSave).toBeCalledTimes(1); expect(props.onSave).toBeCalledWith( expect.objectContaining({ cache_timeout: '1000' }), ); }); }); test('"Description" should not be empty when saved', async () => { const props = createProps(); renderModal(props); const description = screen.getByRole('textbox', { name: 'Description' }); userEvent.clear(description); userEvent.type(description, 'Test description'); expect(description).toHaveValue('Test description'); userEvent.click(screen.getByRole('button', { name: 'Save' })); await waitFor(() => { expect(props.onSave).toBeCalledTimes(1); expect(props.onSave).toBeCalledWith( expect.objectContaining({ description: 'Test description' }), ); }); }); test('"Certified by" should not be empty when saved', async () => { const props = createProps(); renderModal(props); const certifiedBy = screen.getByRole('textbox', { name: 'Certified by' }); userEvent.clear(certifiedBy); userEvent.type(certifiedBy, 'Test certified by'); expect(certifiedBy).toHaveValue('Test certified by'); userEvent.click(screen.getByRole('button', { name: 'Save' })); await waitFor(() => { expect(props.onSave).toBeCalledTimes(1); expect(props.onSave).toBeCalledWith( expect.objectContaining({ certified_by: 'Test certified by' }), ); }); }); test('"Certification details" should not be empty when saved', async () => { const props = createProps(); renderModal(props); const certificationDetails = screen.getByRole('textbox', { name: 'Certification details', }); userEvent.clear(certificationDetails); userEvent.type(certificationDetails, 'Test certification details'); expect(certificationDetails).toHaveValue('Test certification details'); userEvent.click(screen.getByRole('button', { name: 'Save' })); await waitFor(() => { expect(props.onSave).toBeCalledTimes(1); expect(props.onSave).toBeCalledWith( expect.objectContaining({ certification_details: 'Test certification details', }), ); }); });
7,547
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/RowCountLabel/RowCountLabel.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import RowCountLabel from '.'; test('RowCountLabel renders singular result', () => { render(<RowCountLabel rowcount={1} limit={100} />); const expectedText = '1 row'; expect(screen.getByText(expectedText)).toBeInTheDocument(); userEvent.hover(screen.getByText(expectedText)); expect(screen.queryByRole('tooltip')).not.toBeInTheDocument(); }); test('RowCountLabel renders plural result', () => { render(<RowCountLabel rowcount={2} limit={100} />); const expectedText = '2 rows'; expect(screen.getByText(expectedText)).toBeInTheDocument(); userEvent.hover(screen.getByText(expectedText)); expect(screen.queryByRole('tooltip')).not.toBeInTheDocument(); }); test('RowCountLabel renders formatted result', () => { render(<RowCountLabel rowcount={1000} limit={10000} />); const expectedText = '1k rows'; expect(screen.getByText(expectedText)).toBeInTheDocument(); userEvent.hover(screen.getByText(expectedText)); expect(screen.queryByRole('tooltip')).not.toBeInTheDocument(); }); test('RowCountLabel renders limit with danger and tooltip', async () => { render(<RowCountLabel rowcount={100} limit={100} />); const expectedText = '100 rows'; expect(screen.getByText(expectedText)).toBeInTheDocument(); userEvent.hover(screen.getByText(expectedText)); const tooltip = await screen.findByRole('tooltip'); expect(tooltip).toHaveTextContent('Limit reached'); expect(tooltip).toHaveStyle('background: rgba(0, 0, 0, 0.902);'); }); test('RowCountLabel renders loading', () => { render(<RowCountLabel loading />); const expectedText = 'Loading...'; expect(screen.getByText(expectedText)).toBeInTheDocument(); userEvent.hover(screen.getByText(expectedText)); expect(screen.queryByRole('tooltip')).not.toBeInTheDocument(); });
7,550
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/RunQueryButton/RunQueryButton.test.tsx
/** * 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 React from 'react'; import userEvent from '@testing-library/user-event'; import { render, screen } from 'spec/helpers/testing-library'; import { RunQueryButton } from './index'; const createProps = (overrides: Record<string, any> = {}) => ({ loading: false, onQuery: jest.fn(), onStop: jest.fn(), errorMessage: null, isNewChart: false, canStopQuery: true, chartIsStale: true, ...overrides, }); test('renders update chart button', () => { const props = createProps(); render(<RunQueryButton {...props} />); expect(screen.getByText('Update chart')).toBeVisible(); userEvent.click(screen.getByRole('button')); expect(props.onQuery).toHaveBeenCalled(); }); test('renders create chart button', () => { const props = createProps({ isNewChart: true }); render(<RunQueryButton {...props} />); expect(screen.getByText('Create chart')).toBeVisible(); userEvent.click(screen.getByRole('button')); expect(props.onQuery).toHaveBeenCalled(); }); test('renders disabled button', () => { const props = createProps({ errorMessage: 'error' }); render(<RunQueryButton {...props} />); expect(screen.getByText('Update chart')).toBeVisible(); expect(screen.getByRole('button')).toBeDisabled(); userEvent.click(screen.getByRole('button')); expect(props.onQuery).not.toHaveBeenCalled(); }); test('renders query running button', () => { const props = createProps({ loading: true }); render(<RunQueryButton {...props} />); expect(screen.getByText('Stop')).toBeVisible(); userEvent.click(screen.getByRole('button')); expect(props.onStop).toHaveBeenCalled(); }); test('renders query running button disabled', () => { const props = createProps({ loading: true, canStopQuery: false }); render(<RunQueryButton {...props} />); expect(screen.getByText('Stop')).toBeVisible(); expect(screen.getByRole('button')).toBeDisabled(); userEvent.click(screen.getByRole('button')); expect(props.onStop).not.toHaveBeenCalled(); });
7,556
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/CheckboxControl.test.tsx
/** * 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. */ /* eslint-disable no-unused-expressions */ import React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import { ThemeProvider, supersetTheme } from '@superset-ui/core'; import CheckboxControl from 'src/explore/components/controls/CheckboxControl'; import userEvent from '@testing-library/user-event'; const defaultProps = { name: 'show_legend', onChange: jest.fn(), value: false, label: 'checkbox label', }; const setup = (overrides = {}) => ( <ThemeProvider theme={supersetTheme}> <CheckboxControl {...defaultProps} {...overrides} />; </ThemeProvider> ); describe('CheckboxControl', () => { it('renders a Checkbox', () => { render(setup()); const checkbox = screen.getByRole('checkbox'); expect(checkbox).toBeVisible(); expect(checkbox).not.toBeChecked(); }); it('Checks the box when the label is clicked', () => { render(setup()); const label = screen.getByRole('button', { name: /checkbox label/i, }); userEvent.click(label); expect(defaultProps.onChange).toHaveBeenCalled(); }); });
7,558
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/ColorPickerControl.test.tsx
/** * 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 React from 'react'; import { render } from 'spec/helpers/testing-library'; import { CategoricalScheme, getCategoricalSchemeRegistry, } from '@superset-ui/core'; import ColorPickerControl from 'src/explore/components/controls/ColorPickerControl'; const defaultProps = { value: {}, }; describe('ColorPickerControl', () => { beforeAll(() => { getCategoricalSchemeRegistry() .registerValue( 'test', new CategoricalScheme({ id: 'test', colors: ['red', 'green', 'blue'], }), ) .setDefaultKey('test'); render(<ColorPickerControl {...defaultProps} />); }); it('renders an OverlayTrigger', () => { const rendered = render(<ColorPickerControl {...defaultProps} />); // This is the div wrapping the OverlayTrigger and SketchPicker const controlWrapper = rendered.container.querySelectorAll('div')[1]; expect(controlWrapper.childElementCount).toBe(2); // This is the div containing the OverlayTrigger const overlayTrigger = rendered.container.querySelectorAll('div')[2]; expect(overlayTrigger).toHaveStyle( 'position: absolute; width: 50px; height: 20px; top: 0px; left: 0px; right: 0px; bottom: 0px; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==) center;', ); }); it('renders a Popover with a SketchPicker', () => { const rendered = render(<ColorPickerControl {...defaultProps} />); // This is the div wrapping the OverlayTrigger and SketchPicker const controlWrapper = rendered.container.querySelectorAll('div')[1]; expect(controlWrapper.childElementCount).toBe(2); // This is the div containing the SketchPicker const sketchPicker = rendered.container.querySelectorAll('div')[3]; expect(sketchPicker).toHaveStyle( 'position: absolute; width: 50px; height: 20px; top: 0px; left: 0px; right: 0px; bottom: 0px; border-radius: 2px;', ); }); });
7,574
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/withAsyncVerification.test.tsx
/** * 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 React from 'react'; import { ReactWrapper } from 'enzyme'; import { styledMount as mount } from 'spec/helpers/theming'; import { act } from 'react-dom/test-utils'; import withAsyncVerification, { ControlPropsWithExtras, WithAsyncVerificationOptions, } from 'src/explore/components/controls/withAsyncVerification'; import { ExtraControlProps } from '@superset-ui/chart-controls'; import MetricsControl from 'src/explore/components/controls/MetricControl/MetricsControl'; const VALID_METRIC = { metric_name: 'sum__value', expression: 'SUM(energy_usage.value)', }; const mockSetControlValue = jest.fn(); const defaultProps = { name: 'metrics', label: 'Metrics', value: undefined, multi: true, needAsyncVerification: true, actions: { setControlValue: mockSetControlValue }, onChange: () => {}, columns: [ { type: 'VARCHAR(255)', column_name: 'source' }, { type: 'VARCHAR(255)', column_name: 'target' }, { type: 'DOUBLE', column_name: 'value' }, ], savedMetrics: [ VALID_METRIC, { metric_name: 'avg__value', expression: 'AVG(energy_usage.value)' }, ], datasourceType: 'sqla', }; function verify(sourceProp: string) { const mock = jest.fn(); mock.mockImplementation(async (props: ControlPropsWithExtras) => ({ [sourceProp]: props.validMetrics || [VALID_METRIC], })); return mock; } async function setup({ extraProps, baseControl = MetricsControl as WithAsyncVerificationOptions['baseControl'], onChange, }: Partial<WithAsyncVerificationOptions> & { extraProps?: ExtraControlProps; } = {}) { const props = { ...defaultProps, ...extraProps, }; const verifier = verify('savedMetrics'); const VerifiedControl = withAsyncVerification({ baseControl, verify: verifier, onChange, }); type Wrapper = ReactWrapper<typeof props & ExtraControlProps>; let wrapper: Wrapper | undefined; await act(async () => { wrapper = mount(<VerifiedControl {...props} />); }); return { props, wrapper: wrapper as Wrapper, onChange, verifier }; } describe('VerifiedMetricsControl', () => { it('should calls verify correctly', async () => { expect.assertions(5); const { wrapper, verifier, props } = await setup(); expect(wrapper.find(MetricsControl).length).toBe(1); expect(verifier).toBeCalledTimes(1); expect(verifier).toBeCalledWith( expect.objectContaining({ savedMetrics: props.savedMetrics }), ); // should call verifier with new props when props are updated. await act(async () => { wrapper.setProps({ validMetric: ['abc'] }); }); expect(verifier).toBeCalledTimes(2); expect(verifier).toBeCalledWith( expect.objectContaining({ validMetric: ['abc'] }), ); }); it('should trigger onChange event', async () => { expect.assertions(3); const mockOnChange = jest.fn(); const { wrapper } = await setup({ // should allow specify baseControl with control component name baseControl: 'MetricsControl', onChange: mockOnChange, }); const child = wrapper.find(MetricsControl); child.props().onChange?.(['abc']); expect(child.length).toBe(1); expect(mockOnChange).toBeCalledTimes(1); expect(mockOnChange).toBeCalledWith(['abc'], { actions: defaultProps.actions, columns: defaultProps.columns, datasourceType: defaultProps.datasourceType, label: defaultProps.label, multi: defaultProps.multi, name: defaultProps.name, // in real life, `onChange` should have been called with the updated // props (both savedMetrics and value should have been updated), but // because of the limitation of enzyme (it cannot get props updated from // useEffect hooks), we are not able to check that here. savedMetrics: defaultProps.savedMetrics, value: undefined, }); }); });
7,577
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.test.tsx
/** * 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 React from 'react'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import { getChartMetadataRegistry, ChartMetadata } from '@superset-ui/core'; import fetchMock from 'fetch-mock'; import setupColors from 'src/setup/setupColors'; import { ANNOTATION_TYPES_METADATA } from './AnnotationTypes'; import AnnotationLayer from './AnnotationLayer'; const defaultProps = { value: '', vizType: 'table', annotationType: ANNOTATION_TYPES_METADATA.FORMULA.value, }; beforeAll(() => { const supportedAnnotationTypes = Object.values(ANNOTATION_TYPES_METADATA).map( value => value.value, ); fetchMock.get('glob:*/api/v1/annotation_layer/*', { result: [{ label: 'Chart A', value: 'a' }], }); fetchMock.get('glob:*/api/v1/chart/*', { result: [ { id: 'a', slice_name: 'Chart A', viz_type: 'table', form_data: {} }, ], }); setupColors(); getChartMetadataRegistry().registerValue( 'table', new ChartMetadata({ name: 'Table', thumbnail: '', supportedAnnotationTypes, canBeAnnotationTypes: ['EVENT'], }), ); }); const waitForRender = (props?: any) => waitFor(() => render(<AnnotationLayer {...defaultProps} {...props} />)); test('renders with default props', async () => { await waitForRender(); expect(screen.getByRole('button', { name: 'Apply' })).toBeDisabled(); expect(screen.getByRole('button', { name: 'OK' })).toBeDisabled(); expect(screen.getByRole('button', { name: 'Cancel' })).toBeEnabled(); }); test('renders extra checkboxes when type is time series', async () => { await waitForRender(); expect( screen.queryByRole('button', { name: 'Show Markers' }), ).not.toBeInTheDocument(); expect( screen.queryByRole('button', { name: 'Hide Line' }), ).not.toBeInTheDocument(); userEvent.click(screen.getAllByText('Formula')[0]); userEvent.click(screen.getByText('Time series')); expect( await screen.findByRole('button', { name: 'Show Markers' }), ).toBeInTheDocument(); expect(screen.getByRole('button', { name: 'Hide Line' })).toBeInTheDocument(); }); test('enables apply and ok buttons', async () => { const { container } = render(<AnnotationLayer {...defaultProps} />); await waitFor(() => { expect(container).toBeInTheDocument(); }); const nameInput = screen.getByRole('textbox', { name: 'Name' }); const formulaInput = screen.getByRole('textbox', { name: 'Formula' }); expect(nameInput).toBeInTheDocument(); expect(formulaInput).toBeInTheDocument(); userEvent.type(nameInput, 'Name'); userEvent.type(formulaInput, '2x'); await waitFor(() => { expect(screen.getByRole('button', { name: 'Apply' })).toBeEnabled(); expect(screen.getByRole('button', { name: 'OK' })).toBeEnabled(); }); }); test('triggers addAnnotationLayer when apply button is clicked', async () => { const addAnnotationLayer = jest.fn(); await waitForRender({ name: 'Test', value: '2x', addAnnotationLayer }); userEvent.click(screen.getByRole('button', { name: 'Apply' })); expect(addAnnotationLayer).toHaveBeenCalled(); }); test('triggers addAnnotationLayer and close when ok button is clicked', async () => { const addAnnotationLayer = jest.fn(); const close = jest.fn(); await waitForRender({ name: 'Test', value: '2x', addAnnotationLayer, close }); userEvent.click(screen.getByRole('button', { name: 'OK' })); expect(addAnnotationLayer).toHaveBeenCalled(); expect(close).toHaveBeenCalled(); }); test('triggers close when cancel button is clicked', async () => { const close = jest.fn(); await waitForRender({ close }); userEvent.click(screen.getByRole('button', { name: 'Cancel' })); expect(close).toHaveBeenCalled(); }); test('triggers removeAnnotationLayer and close when remove button is clicked', async () => { const removeAnnotationLayer = jest.fn(); const close = jest.fn(); await waitForRender({ name: 'Test', value: '2x', removeAnnotationLayer, close, }); userEvent.click(screen.getByRole('button', { name: 'Remove' })); expect(removeAnnotationLayer).toHaveBeenCalled(); expect(close).toHaveBeenCalled(); }); test('renders chart options', async () => { await waitForRender({ annotationType: ANNOTATION_TYPES_METADATA.EVENT.value, }); userEvent.click( screen.getByRole('combobox', { name: 'Annotation source type' }), ); userEvent.click(screen.getByText('Superset annotation')); expect(await screen.findByText('Annotation layer')).toBeInTheDocument(); userEvent.click( screen.getByRole('combobox', { name: 'Annotation source type' }), ); userEvent.click(screen.getByText('Table')); expect(await screen.findByText('Chart')).toBeInTheDocument(); }); test('keeps apply disabled when missing required fields', async () => { await waitForRender({ annotationType: ANNOTATION_TYPES_METADATA.EVENT.value, sourceType: 'Table', }); userEvent.click( screen.getByRole('combobox', { name: 'Annotation layer value' }), ); expect(await screen.findByText('Chart A')).toBeInTheDocument(); userEvent.click(screen.getByText('Chart A')); userEvent.click(screen.getByRole('button', { name: 'Automatic Color' })); userEvent.click( screen.getByRole('combobox', { name: 'Annotation layer title column' }), ); expect(await screen.findByText(/none/i)).toBeInTheDocument(); userEvent.click(screen.getByText('None')); userEvent.click(screen.getByText('Style')); userEvent.click( screen.getByRole('combobox', { name: 'Annotation layer stroke' }), ); expect(await screen.findByText('Dashed')).toBeInTheDocument(); userEvent.click(screen.getByText('Dashed')); userEvent.click(screen.getByText('Opacity')); userEvent.click( screen.getByRole('combobox', { name: 'Annotation layer opacity' }), ); expect(await screen.findByText(/0.5/i)).toBeInTheDocument(); userEvent.click(screen.getByText('0.5')); const checkboxes = screen.getAllByRole('checkbox'); checkboxes.forEach(checkbox => userEvent.click(checkbox)); expect(screen.getByRole('button', { name: 'Apply' })).toBeDisabled(); }); test.skip('Disable apply button if formula is incorrect', async () => { // TODO: fix flaky test that passes locally but fails on CI await waitForRender({ name: 'test' }); userEvent.clear(screen.getByLabelText('Formula')); userEvent.type(screen.getByLabelText('Formula'), 'x+1'); await waitFor(() => { expect(screen.getByLabelText('Formula')).toHaveValue('x+1'); expect(screen.getByRole('button', { name: 'OK' })).toBeEnabled(); expect(screen.getByRole('button', { name: 'Apply' })).toBeEnabled(); }); userEvent.clear(screen.getByLabelText('Formula')); userEvent.type(screen.getByLabelText('Formula'), 'y = x*2+1'); await waitFor(() => { expect(screen.getByLabelText('Formula')).toHaveValue('y = x*2+1'); expect(screen.getByRole('button', { name: 'OK' })).toBeEnabled(); expect(screen.getByRole('button', { name: 'Apply' })).toBeEnabled(); }); userEvent.clear(screen.getByLabelText('Formula')); userEvent.type(screen.getByLabelText('Formula'), 'y+1'); await waitFor(() => { expect(screen.getByLabelText('Formula')).toHaveValue('y+1'); expect(screen.getByRole('button', { name: 'OK' })).toBeDisabled(); expect(screen.getByRole('button', { name: 'Apply' })).toBeDisabled(); }); userEvent.clear(screen.getByLabelText('Formula')); userEvent.type(screen.getByLabelText('Formula'), 'x+'); await waitFor(() => { expect(screen.getByLabelText('Formula')).toHaveValue('x+'); expect(screen.getByRole('button', { name: 'OK' })).toBeDisabled(); expect(screen.getByRole('button', { name: 'Apply' })).toBeDisabled(); }); userEvent.clear(screen.getByLabelText('Formula')); userEvent.type(screen.getByLabelText('Formula'), 'y = z+1'); await waitFor(() => { expect(screen.getByLabelText('Formula')).toHaveValue('y = z+1'); expect(screen.getByRole('button', { name: 'OK' })).toBeDisabled(); expect(screen.getByRole('button', { name: 'Apply' })).toBeDisabled(); }); });
7,580
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/CollectionControl/CollectionControl.test.tsx
/** * 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 userEvent from '@testing-library/user-event'; import React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import CollectionControl from '.'; jest.mock('@superset-ui/chart-controls', () => ({ InfoTooltipWithTrigger: (props: any) => ( <button onClick={props.onClick} type="button" data-icon={props.icon} data-tooltip={props.tooltip} > {props.label} </button> ), })); jest.mock('..', () => ({ __esModule: true, default: { TestControl: (props: any) => ( <button type="button" onClick={() => props.onChange(0, 'update')} data-test="TestControl" > TestControl </button> ), }, })); const createProps = () => ({ actions: { addDangerToast: jest.fn(), addInfoToast: jest.fn(), addSuccessToast: jest.fn(), addWarningToast: jest.fn(), createNewSlice: jest.fn(), fetchDatasourcesStarted: jest.fn(), fetchDatasourcesSucceeded: jest.fn(), fetchFaveStar: jest.fn(), saveFaveStar: jest.fn(), setControlValue: jest.fn(), setDatasource: jest.fn(), setDatasourceType: jest.fn(), setDatasources: jest.fn(), setExploreControls: jest.fn(), sliceUpdated: jest.fn(), toggleFaveStar: jest.fn(), updateChartTitle: jest.fn(), }, addTooltip: 'Add an item', controlName: 'TestControl', description: null, hovered: false, itemGenerator: jest.fn(), keyAccessor: jest.fn(() => 'hrYAZ5iBH'), label: 'Time series columns', name: 'column_collection', onChange: jest.fn(), placeholder: 'Empty collection', type: 'CollectionControl', validationErrors: [], validators: [jest.fn()], value: [{ key: 'hrYAZ5iBH' }], }); test('Should render', async () => { const props = createProps(); render(<CollectionControl {...props} />); expect(await screen.findByTestId('CollectionControl')).toBeInTheDocument(); }); test('Should show the button with the label', async () => { const props = createProps(); render(<CollectionControl {...props} />); expect( await screen.findByRole('button', { name: props.label }), ).toBeInTheDocument(); expect(screen.getByRole('button', { name: props.label })).toHaveTextContent( props.label, ); }); test('Should have add button', async () => { const props = createProps(); render(<CollectionControl {...props} />); expect( await screen.findByRole('button', { name: 'plus-large' }), ).toBeInTheDocument(); expect(props.onChange).toBeCalledTimes(0); userEvent.click(screen.getByRole('button', { name: 'plus-large' })); expect(props.onChange).toBeCalledWith([{ key: 'hrYAZ5iBH' }, undefined]); }); test('Should have remove button', async () => { const props = createProps(); render(<CollectionControl {...props} />); expect( await screen.findByRole('button', { name: 'remove-item' }), ).toBeInTheDocument(); expect(props.onChange).toBeCalledTimes(0); userEvent.click(screen.getByRole('button', { name: 'remove-item' })); expect(props.onChange).toBeCalledWith([]); }); test('Should have SortableDragger icon', async () => { const props = createProps(); render(<CollectionControl {...props} />); expect(await screen.findByLabelText('drag')).toBeVisible(); }); test('Should call Control component', async () => { const props = createProps(); render(<CollectionControl {...props} />); expect(await screen.findByTestId('TestControl')).toBeInTheDocument(); expect(props.onChange).toBeCalledTimes(0); userEvent.click(screen.getByTestId('TestControl')); expect(props.onChange).toBeCalledWith([{ key: 'hrYAZ5iBH' }]); });
7,582
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/ColorSchemeControl/ColorSchemeControl.test.tsx
/** * 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 React from 'react'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; import ColorSchemeControl, { ColorSchemes } from '.'; const defaultProps = { hasCustomLabelColors: false, label: 'Color scheme', labelMargin: 0, name: 'color', value: 'supersetDefault', clearable: true, choices: [], schemes: () => ({} as ColorSchemes), isLinear: false, }; const setup = (overrides?: Record<string, any>) => render(<ColorSchemeControl {...defaultProps} {...overrides} />); test('should render', async () => { const { container } = setup(); await waitFor(() => expect(container).toBeVisible()); }); test('should display a label', async () => { setup(); expect(await screen.findByText('Color scheme')).toBeTruthy(); }); test('should not display an alert icon if hasCustomLabelColors=false', async () => { setup(); await waitFor(() => { expect( screen.queryByRole('img', { name: 'alert-solid' }), ).not.toBeInTheDocument(); }); }); test('should display an alert icon if hasCustomLabelColors=true', async () => { const hasCustomLabelColorsProps = { ...defaultProps, hasCustomLabelColors: true, }; setup(hasCustomLabelColorsProps); await waitFor(() => { expect( screen.getByRole('img', { name: 'alert-solid' }), ).toBeInTheDocument(); }); });
7,583
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/ColorSchemeControl/ColorSchemeLabel.test.tsx
/** * 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 React from 'react'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; import ColorSchemeLabel from './ColorSchemeLabel'; const defaultProps = { colors: [ '#000000', '#FFFFFF', '#CCCCCC', '#000000', '#FFFFFF', '#CCCCCC', '#000000', '#FFFFFF', '#CCCCCC', '#000000', '#FFFFFF', '#CCCCCC', ], label: 'Superset Colors', id: 'colorScheme', }; const setup = (overrides?: Record<string, any>) => render(<ColorSchemeLabel {...defaultProps} {...overrides} />); test('should render', async () => { const { container } = setup(); await waitFor(() => expect(container).toBeVisible()); }); test('should render the label', () => { setup(); expect(screen.getByText('Superset Colors')).toBeInTheDocument(); }); test('should render the colors', () => { setup(); const allColors = screen.getAllByTestId('color'); expect(allColors).toHaveLength(12); });
7,605
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/ControlPopover/ControlPopover.test.tsx
/** * 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 React from 'react'; import { render, screen, fireEvent } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import { waitFor } from '@testing-library/react'; import ControlPopover, { PopoverProps } from './ControlPopover'; const createProps = (): Partial<PopoverProps> => ({ trigger: 'click', title: 'Control Popover Test', content: <span data-test="control-popover-content">Information</span>, }); const TestComponent: React.FC<PopoverProps> = props => ( <div id="controlSections"> <div data-test="outer-container"> <ControlPopover {...props}> <span data-test="control-popover">Click me</span> </ControlPopover> </div> </div> ); const setupTest = (props: Partial<PopoverProps> = createProps()) => { const setStateMock = jest.fn(); jest .spyOn(React, 'useState') .mockImplementation(((state: any) => [ state, state === 'right' ? setStateMock : jest.fn(), ]) as any); const { container, rerender } = render(<TestComponent {...props} />); return { props, container, rerender, setStateMock, }; }; afterEach(() => { jest.restoreAllMocks(); }); test('Should render', () => { setupTest(); expect(screen.getByTestId('control-popover')).toBeInTheDocument(); userEvent.click(screen.getByTestId('control-popover')); expect(screen.getByText('Control Popover Test')).toBeInTheDocument(); expect(screen.getByTestId('control-popover-content')).toBeInTheDocument(); }); test('Should lock the vertical scroll when the popover is visible', () => { setupTest(); expect(screen.getByTestId('control-popover')).toBeInTheDocument(); expect(screen.getByTestId('outer-container')).not.toHaveStyle( 'overflowY: hidden', ); userEvent.click(screen.getByTestId('control-popover')); expect(screen.getByTestId('outer-container')).toHaveStyle( 'overflowY: hidden', ); userEvent.click(document.body); expect(screen.getByTestId('outer-container')).not.toHaveStyle( 'overflowY: hidden', ); }); test('Should place popover at the top', async () => { const { setStateMock } = setupTest({ ...createProps(), getVisibilityRatio: () => 0.2, }); expect(screen.getByTestId('control-popover')).toBeInTheDocument(); userEvent.click(screen.getByTestId('control-popover')); await waitFor(() => { expect(setStateMock).toHaveBeenCalledWith('rightTop'); }); }); test('Should place popover at the center', async () => { const { setStateMock } = setupTest({ ...createProps(), getVisibilityRatio: () => 0.5, }); expect(screen.getByTestId('control-popover')).toBeInTheDocument(); userEvent.click(screen.getByTestId('control-popover')); await waitFor(() => { expect(setStateMock).toHaveBeenCalledWith('right'); }); }); test('Should place popover at the bottom', async () => { const { setStateMock } = setupTest({ ...createProps(), getVisibilityRatio: () => 0.7, }); expect(screen.getByTestId('control-popover')).toBeInTheDocument(); userEvent.click(screen.getByTestId('control-popover')); await waitFor(() => { expect(setStateMock).toHaveBeenCalledWith('rightBottom'); }); }); test('Should close popover on escape press', async () => { setupTest({ ...createProps(), destroyTooltipOnHide: true, }); expect(screen.getByTestId('control-popover')).toBeInTheDocument(); expect(screen.queryByText('Control Popover Test')).not.toBeInTheDocument(); userEvent.click(screen.getByTestId('control-popover')); expect(await screen.findByText('Control Popover Test')).toBeInTheDocument(); // Ensure that pressing any other key than escape does nothing fireEvent.keyDown(screen.getByTestId('control-popover'), { key: 'Enter', code: 13, charCode: 13, }); expect(await screen.findByText('Control Popover Test')).toBeInTheDocument(); // Escape should close the popover fireEvent.keyDown(screen.getByTestId('control-popover'), { key: 'Escape', code: 27, charCode: 0, }); await waitFor(() => { expect(screen.queryByText('Control Popover Test')).not.toBeInTheDocument(); }); }); test('Controlled mode', async () => { const baseProps = { ...createProps(), destroyTooltipOnHide: true, visible: false, }; const { rerender } = setupTest(baseProps); expect(screen.getByTestId('control-popover')).toBeInTheDocument(); expect(screen.queryByText('Control Popover Test')).not.toBeInTheDocument(); rerender(<TestComponent {...baseProps} visible />); expect(await screen.findByText('Control Popover Test')).toBeInTheDocument(); rerender(<TestComponent {...baseProps} />); await waitFor(() => { expect(screen.queryByText('Control Popover Test')).not.toBeInTheDocument(); }); });
7,611
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/DatasourceControl/DatasourceControl.test.tsx
/** * 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 React from 'react'; import { Route } from 'react-router-dom'; import fetchMock from 'fetch-mock'; import userEvent from '@testing-library/user-event'; import { DatasourceType, JsonObject, SupersetClient } from '@superset-ui/core'; import { render, screen, act, waitFor } from 'spec/helpers/testing-library'; import { fallbackExploreInitialData } from 'src/explore/fixtures'; import DatasourceControl from '.'; const SupersetClientGet = jest.spyOn(SupersetClient, 'get'); const mockDatasource = { id: 25, database: { name: 'examples', }, name: 'channels', type: 'table', columns: [], owners: [{ first_name: 'john', last_name: 'doe', id: 1, username: 'jd' }], sql: 'SELECT * FROM mock_datasource_sql', }; const createProps = (overrides: JsonObject = {}) => ({ hovered: false, type: 'DatasourceControl', label: 'Datasource', default: null, description: null, value: '25__table', form_data: {}, datasource: mockDatasource, validationErrors: [], name: 'datasource', actions: { changeDatasource: jest.fn(), setControlValue: jest.fn(), }, isEditable: true, user: { createdOn: '2021-04-27T18:12:38.952304', email: 'admin', firstName: 'admin', isActive: true, lastName: 'admin', permissions: {}, roles: { Admin: Array(173) }, userId: 1, username: 'admin', }, onChange: jest.fn(), onDatasourceSave: jest.fn(), ...overrides, }); async function openAndSaveChanges(datasource: any) { fetchMock.put( 'glob:*/api/v1/dataset/*', {}, { overwriteRoutes: true, }, ); fetchMock.get( 'glob:*/api/v1/dataset/*', { result: datasource }, { overwriteRoutes: true, }, ); userEvent.click(screen.getByTestId('datasource-menu-trigger')); userEvent.click(await screen.findByTestId('edit-dataset')); userEvent.click(await screen.findByTestId('datasource-modal-save')); userEvent.click(await screen.findByText('OK')); } test('Should render', async () => { const props = createProps(); render(<DatasourceControl {...props} />, { useRouter: true }); expect(await screen.findByTestId('datasource-control')).toBeVisible(); }); test('Should have elements', async () => { const props = createProps(); render(<DatasourceControl {...props} />, { useRouter: true }); expect(await screen.findByText('channels')).toBeVisible(); expect(screen.getByTestId('datasource-menu-trigger')).toBeVisible(); }); test('Should open a menu', async () => { const props = createProps(); render(<DatasourceControl {...props} />, { useRouter: true }); expect(screen.queryByText('Edit dataset')).not.toBeInTheDocument(); expect(screen.queryByText('Swap dataset')).not.toBeInTheDocument(); expect(screen.queryByText('View in SQL Lab')).not.toBeInTheDocument(); userEvent.click(screen.getByTestId('datasource-menu-trigger')); expect(await screen.findByText('Edit dataset')).toBeInTheDocument(); expect(screen.getByText('Swap dataset')).toBeInTheDocument(); expect(screen.getByText('View in SQL Lab')).toBeInTheDocument(); }); test('Should not show SQL Lab for non sql_lab role', async () => { const props = createProps({ user: { createdOn: '2021-04-27T18:12:38.952304', email: 'gamma', firstName: 'gamma', isActive: true, lastName: 'gamma', permissions: {}, roles: { Gamma: [] }, userId: 2, username: 'gamma', }, }); render(<DatasourceControl {...props} />, { useRouter: true }); userEvent.click(screen.getByTestId('datasource-menu-trigger')); expect(await screen.findByText('Edit dataset')).toBeInTheDocument(); expect(screen.getByText('Swap dataset')).toBeInTheDocument(); expect(screen.queryByText('View in SQL Lab')).not.toBeInTheDocument(); }); test('Should show SQL Lab for sql_lab role', async () => { const props = createProps({ user: { createdOn: '2021-04-27T18:12:38.952304', email: 'sql', firstName: 'sql', isActive: true, lastName: 'sql', permissions: {}, roles: { Gamma: [], sql_lab: [['menu_access', 'SQL Lab']] }, userId: 2, username: 'sql', }, }); render(<DatasourceControl {...props} />, { useRouter: true }); userEvent.click(screen.getByTestId('datasource-menu-trigger')); expect(await screen.findByText('Edit dataset')).toBeInTheDocument(); expect(screen.getByText('Swap dataset')).toBeInTheDocument(); expect(screen.getByText('View in SQL Lab')).toBeInTheDocument(); }); test('Click on Swap dataset option', async () => { const props = createProps(); SupersetClientGet.mockImplementationOnce( async ({ endpoint }: { endpoint: string }) => { if (endpoint.includes('_info')) { return { json: { permissions: ['can_read', 'can_write'] }, } as any; } return { json: { result: [] } } as any; }, ); render(<DatasourceControl {...props} />, { useRedux: true, useRouter: true, }); userEvent.click(screen.getByTestId('datasource-menu-trigger')); await act(async () => { userEvent.click(screen.getByText('Swap dataset')); }); expect( screen.getByText( 'Changing the dataset may break the chart if the chart relies on columns or metadata that does not exist in the target dataset', ), ).toBeInTheDocument(); }); test('Click on Edit dataset', async () => { const props = createProps(); SupersetClientGet.mockImplementationOnce( async () => ({ json: { result: [] } } as any), ); render(<DatasourceControl {...props} />, { useRedux: true, useRouter: true, }); userEvent.click(screen.getByTestId('datasource-menu-trigger')); await act(async () => { userEvent.click(screen.getByText('Edit dataset')); }); expect( screen.getByText( 'Changing these settings will affect all charts using this dataset, including charts owned by other people.', ), ).toBeInTheDocument(); }); test('Edit dataset should be disabled when user is not admin', async () => { const props = createProps(); // @ts-expect-error props.user.roles = {}; props.datasource.owners = []; SupersetClientGet.mockImplementationOnce( async () => ({ json: { result: [] } } as any), ); render(<DatasourceControl {...props} />, { useRedux: true, useRouter: true, }); userEvent.click(screen.getByTestId('datasource-menu-trigger')); expect(await screen.findByTestId('edit-dataset')).toHaveAttribute( 'aria-disabled', 'true', ); }); test('Click on View in SQL Lab', async () => { const props = createProps(); const { queryByTestId, getByTestId } = render( <> <Route path="/sqllab" render={({ location }) => ( <div data-test="mock-sqllab-route"> {JSON.stringify(location.state)} </div> )} /> <DatasourceControl {...props} /> </>, { useRedux: true, useRouter: true, }, ); userEvent.click(screen.getByTestId('datasource-menu-trigger')); expect(queryByTestId('mock-sqllab-route')).not.toBeInTheDocument(); await act(async () => { userEvent.click(screen.getByText('View in SQL Lab')); }); expect(getByTestId('mock-sqllab-route')).toBeInTheDocument(); expect(JSON.parse(`${getByTestId('mock-sqllab-route').textContent}`)).toEqual( { requestedQuery: { datasourceKey: `${mockDatasource.id}__${mockDatasource.type}`, sql: mockDatasource.sql, }, }, ); }); test('Should open a different menu when datasource=query', async () => { const props = createProps(); const queryProps = { ...props, datasource: { ...props.datasource, type: DatasourceType.Query, }, }; render(<DatasourceControl {...queryProps} />, { useRouter: true }); expect(screen.queryByText('Query preview')).not.toBeInTheDocument(); expect(screen.queryByText('View in SQL Lab')).not.toBeInTheDocument(); expect(screen.queryByText('Save as dataset')).not.toBeInTheDocument(); userEvent.click(screen.getByTestId('datasource-menu-trigger')); expect(await screen.findByText('Query preview')).toBeInTheDocument(); expect(screen.getByText('View in SQL Lab')).toBeInTheDocument(); expect(screen.getByText('Save as dataset')).toBeInTheDocument(); }); test('Click on Save as dataset', async () => { const props = createProps(); const queryProps = { ...props, datasource: { ...props.datasource, type: DatasourceType.Query, }, }; render(<DatasourceControl {...queryProps} />, { useRedux: true, useRouter: true, }); userEvent.click(screen.getByTestId('datasource-menu-trigger')); userEvent.click(screen.getByText('Save as dataset')); // Renders a save dataset modal const saveRadioBtn = await screen.findByRole('radio', { name: /save as new/i, }); const overwriteRadioBtn = screen.getByRole('radio', { name: /overwrite existing/i, }); const dropdownField = screen.getByText(/select or type dataset name/i); expect(saveRadioBtn).toBeVisible(); expect(overwriteRadioBtn).toBeVisible(); expect(screen.getByRole('button', { name: /save/i })).toBeVisible(); expect(screen.getByRole('button', { name: /close/i })).toBeVisible(); expect(dropdownField).toBeVisible(); }); test('should set the default temporal column', async () => { const props = createProps(); const overrideProps = { ...props, form_data: { granularity_sqla: 'test-col', }, datasource: { ...props.datasource, main_dttm_col: 'test-default', columns: [ { column_name: 'test-col', is_dttm: false, }, { column_name: 'test-default', is_dttm: true, }, ], }, }; render(<DatasourceControl {...props} {...overrideProps} />, { useRedux: true, useRouter: true, }); await openAndSaveChanges(overrideProps.datasource); await waitFor(() => { expect(props.actions.setControlValue).toHaveBeenCalledWith( 'granularity_sqla', 'test-default', ); }); }); test('should set the first available temporal column', async () => { const props = createProps(); const overrideProps = { ...props, form_data: { granularity_sqla: 'test-col', }, datasource: { ...props.datasource, main_dttm_col: null, columns: [ { column_name: 'test-col', is_dttm: false, }, { column_name: 'test-first', is_dttm: true, }, ], }, }; render(<DatasourceControl {...props} {...overrideProps} />, { useRedux: true, useRouter: true, }); await openAndSaveChanges(overrideProps.datasource); await waitFor(() => { expect(props.actions.setControlValue).toHaveBeenCalledWith( 'granularity_sqla', 'test-first', ); }); }); test('should not set the temporal column', async () => { const props = createProps(); const overrideProps = { ...props, form_data: { granularity_sqla: null, }, datasource: { ...props.datasource, main_dttm_col: null, columns: [ { column_name: 'test-col', is_dttm: false, }, { column_name: 'test-col-2', is_dttm: false, }, ], }, }; render(<DatasourceControl {...props} {...overrideProps} />, { useRedux: true, useRouter: true, }); await openAndSaveChanges(overrideProps.datasource); await waitFor(() => { expect(props.actions.setControlValue).toHaveBeenCalledWith( 'granularity_sqla', null, ); }); }); test('should show missing params state', () => { const props = createProps({ datasource: fallbackExploreInitialData.dataset }); render(<DatasourceControl {...props} />, { useRedux: true, useRouter: true }); expect(screen.getByText(/missing dataset/i)).toBeVisible(); expect(screen.getByText(/missing url parameters/i)).toBeVisible(); expect( screen.getByText( /the url is missing the dataset_id or slice_id parameters\./i, ), ).toBeVisible(); }); test('should show missing dataset state', () => { // @ts-ignore delete window.location; // @ts-ignore window.location = { search: '?slice_id=152' }; const props = createProps({ datasource: fallbackExploreInitialData.dataset }); render(<DatasourceControl {...props} />, { useRedux: true, useRouter: true }); expect(screen.getAllByText(/missing dataset/i)).toHaveLength(2); expect( screen.getByText( /the dataset linked to this chart may have been deleted\./i, ), ).toBeVisible(); });
7,623
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/DateFilterControl
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/DateFilterControl/tests/AdvancedFrame.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import { AdvancedFrame } from '../components'; test('renders with default props', () => { render(<AdvancedFrame onChange={jest.fn()} value="Last week" />); expect(screen.getByText('Configure Advanced Time Range')).toBeInTheDocument(); }); test('render with empty value', () => { render(<AdvancedFrame onChange={jest.fn()} value="" />); expect(screen.getByText('Configure Advanced Time Range')).toBeInTheDocument(); }); test('triggers since onChange', () => { const onChange = jest.fn(); render(<AdvancedFrame onChange={onChange} value="Next week" />); userEvent.type(screen.getAllByRole('textbox')[0], 'Last week'); expect(onChange).toHaveBeenCalled(); }); test('triggers until onChange', () => { const onChange = jest.fn(); render(<AdvancedFrame onChange={onChange} value="today : tomorrow" />); userEvent.type(screen.getAllByRole('textbox')[1], 'dayAfterTomorrow'); expect(onChange).toHaveBeenCalled(); });
7,624
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/DateFilterControl
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/DateFilterControl/tests/CustomFrame.test.tsx
/** * 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 React from 'react'; import thunk from 'redux-thunk'; import { Provider } from 'react-redux'; import configureStore from 'redux-mock-store'; import { render, screen } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import { CustomFrame } from '../components'; jest.useFakeTimers(); const emptyValue = ''; const nowValue = 'now : now'; const todayValue = 'today : today'; const todayNowValue = 'today : now'; const specificValue = '2021-03-16T00:00:00 : 2021-03-17T00:00:00'; const relativeNowValue = `DATEADD(DATETIME("now"), -7, day) : DATEADD(DATETIME("now"), 7, day)`; const relativeTodayValue = `DATEADD(DATETIME("today"), -7, day) : DATEADD(DATETIME("today"), 7, day)`; const mockStore = configureStore([thunk]); const store = mockStore({ common: { locale: 'en' }, }); // case when common.locale is not populated const emptyStore = mockStore({}); // case when common.locale is populated with invalid locale const invalidStore = mockStore({ common: { locale: 'invalid_locale' } }); test('renders with default props', () => { render( <Provider store={store}> <CustomFrame onChange={jest.fn()} value={emptyValue} /> </Provider>, ); expect(screen.getByText('Configure custom time range')).toBeInTheDocument(); expect(screen.getByText('Relative Date/Time')).toBeInTheDocument(); expect(screen.getByRole('spinbutton')).toBeInTheDocument(); expect(screen.getByText('Days Before')).toBeInTheDocument(); expect(screen.getByText('Specific Date/Time')).toBeInTheDocument(); expect(screen.getByRole('img', { name: 'calendar' })).toBeInTheDocument(); }); test('renders with empty store', () => { render( <Provider store={emptyStore}> <CustomFrame onChange={jest.fn()} value={emptyValue} /> </Provider>, ); expect(screen.getByText('Configure custom time range')).toBeInTheDocument(); expect(screen.getByText('Relative Date/Time')).toBeInTheDocument(); expect(screen.getByRole('spinbutton')).toBeInTheDocument(); expect(screen.getByText('Days Before')).toBeInTheDocument(); expect(screen.getByText('Specific Date/Time')).toBeInTheDocument(); expect(screen.getByRole('img', { name: 'calendar' })).toBeInTheDocument(); }); test('renders since and until with specific date/time with default locale', () => { render( <Provider store={emptyStore}> <CustomFrame onChange={jest.fn()} value={specificValue} /> </Provider>, ); expect(screen.getAllByText('Specific Date/Time').length).toBe(2); expect(screen.getAllByRole('img', { name: 'calendar' }).length).toBe(2); }); test('renders with invalid locale', () => { render( <Provider store={invalidStore}> <CustomFrame onChange={jest.fn()} value={emptyValue} /> </Provider>, ); expect(screen.getByText('Configure custom time range')).toBeInTheDocument(); expect(screen.getByText('Relative Date/Time')).toBeInTheDocument(); expect(screen.getByRole('spinbutton')).toBeInTheDocument(); expect(screen.getByText('Days Before')).toBeInTheDocument(); expect(screen.getByText('Specific Date/Time')).toBeInTheDocument(); expect(screen.getByRole('img', { name: 'calendar' })).toBeInTheDocument(); }); test('renders since and until with specific date/time with invalid locale', () => { render( <Provider store={invalidStore}> <CustomFrame onChange={jest.fn()} value={specificValue} /> </Provider>, ); expect(screen.getAllByText('Specific Date/Time').length).toBe(2); expect(screen.getAllByRole('img', { name: 'calendar' }).length).toBe(2); }); test('renders since and until with specific date/time', () => { render( <Provider store={store}> <CustomFrame onChange={jest.fn()} value={specificValue} /> </Provider>, ); expect(screen.getAllByText('Specific Date/Time').length).toBe(2); expect(screen.getAllByRole('img', { name: 'calendar' }).length).toBe(2); }); test('renders since and until with relative date/time', () => { render( <Provider store={store}> <CustomFrame onChange={jest.fn()} value={relativeNowValue} /> </Provider>, ); expect(screen.getAllByText('Relative Date/Time').length).toBe(2); expect(screen.getAllByRole('spinbutton').length).toBe(2); expect(screen.getByText('Days Before')).toBeInTheDocument(); expect(screen.getByText('Days After')).toBeInTheDocument(); }); test('renders since and until with Now option', () => { render( <Provider store={store}> <CustomFrame onChange={jest.fn()} value={nowValue} /> </Provider>, ); expect(screen.getAllByText('Now').length).toBe(2); }); test('renders since and until with Midnight option', () => { render( <Provider store={store}> <CustomFrame onChange={jest.fn()} value={todayValue} /> </Provider>, ); expect(screen.getAllByText('Midnight').length).toBe(2); }); test('renders anchor with now option', () => { render( <Provider store={store}> <CustomFrame onChange={jest.fn()} value={relativeNowValue} /> </Provider>, ); expect(screen.getByText('Anchor to')).toBeInTheDocument(); expect(screen.getByRole('radio', { name: 'NOW' })).toBeInTheDocument(); expect(screen.getByRole('radio', { name: 'Date/Time' })).toBeInTheDocument(); expect(screen.queryByPlaceholderText('Select date')).not.toBeInTheDocument(); }); test('renders anchor with date/time option', () => { render( <Provider store={store}> <CustomFrame onChange={jest.fn()} value={relativeTodayValue} /> </Provider>, ); expect(screen.getByText('Anchor to')).toBeInTheDocument(); expect(screen.getByRole('radio', { name: 'NOW' })).toBeInTheDocument(); expect(screen.getByRole('radio', { name: 'Date/Time' })).toBeInTheDocument(); expect(screen.getByPlaceholderText('Select date')).toBeInTheDocument(); }); test('triggers onChange when the anchor changes', () => { const onChange = jest.fn(); render( <Provider store={store}> <CustomFrame onChange={onChange} value={relativeNowValue} /> </Provider>, ); userEvent.click(screen.getByRole('radio', { name: 'Date/Time' })); expect(onChange).toHaveBeenCalled(); }); test('triggers onChange when the value changes', () => { const onChange = jest.fn(); render( <Provider store={store}> <CustomFrame onChange={onChange} value={emptyValue} /> </Provider>, ); userEvent.click(screen.getByRole('img', { name: 'up' })); expect(onChange).toHaveBeenCalled(); }); test('triggers onChange when the mode changes', async () => { const onChange = jest.fn(); render( <Provider store={store}> <CustomFrame onChange={onChange} value={todayNowValue} /> </Provider>, ); userEvent.click(screen.getByTitle('Midnight')); expect(await screen.findByTitle('Relative Date/Time')).toBeInTheDocument(); userEvent.click(screen.getByTitle('Relative Date/Time')); userEvent.click(screen.getAllByTitle('Now')[1]); expect( await screen.findByText('Configure custom time range'), ).toBeInTheDocument(); userEvent.click(screen.getAllByTitle('Specific Date/Time')[1]); expect(onChange).toHaveBeenCalledTimes(2); }); test('triggers onChange when the grain changes', async () => { const onChange = jest.fn(); render( <Provider store={store}> <CustomFrame onChange={onChange} value={relativeNowValue} /> </Provider>, ); userEvent.click(screen.getByText('Days Before')); expect(await screen.findByText('Weeks Before')).toBeInTheDocument(); userEvent.click(screen.getByText('Weeks Before')); userEvent.click(screen.getByText('Days After')); expect(await screen.findByText('Weeks After')).toBeInTheDocument(); userEvent.click(screen.getByText('Weeks After')); expect(onChange).toHaveBeenCalledTimes(2); }); test('triggers onChange when the date changes', async () => { const onChange = jest.fn(); render( <Provider store={store}> <CustomFrame onChange={onChange} value={specificValue} /> </Provider>, ); const inputs = screen.getAllByPlaceholderText('Select date'); userEvent.click(inputs[0]); userEvent.click(screen.getAllByText('Now')[0]); userEvent.click(inputs[1]); userEvent.click(screen.getAllByText('Now')[1]); expect(onChange).toHaveBeenCalledTimes(2); }); test('should translate Date Picker', () => { const onChange = jest.fn(); const store = mockStore({ common: { locale: 'fr' }, }); render( <Provider store={store}> <CustomFrame onChange={onChange} value={specificValue} /> </Provider>, ); userEvent.click(screen.getAllByRole('img', { name: 'calendar' })[0]); expect(screen.getByText('2021')).toBeInTheDocument(); expect(screen.getByText('lu')).toBeInTheDocument(); expect(screen.getByText('ma')).toBeInTheDocument(); expect(screen.getByText('me')).toBeInTheDocument(); expect(screen.getByText('je')).toBeInTheDocument(); expect(screen.getByText('ve')).toBeInTheDocument(); expect(screen.getByText('sa')).toBeInTheDocument(); expect(screen.getByText('di')).toBeInTheDocument(); });
7,625
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/DateFilterControl
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/DateFilterControl/tests/DateFilterLabel.test.tsx
/** * 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 React from 'react'; import thunk from 'redux-thunk'; import { Provider } from 'react-redux'; import configureStore from 'redux-mock-store'; import { render, screen } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import { NO_TIME_RANGE } from '@superset-ui/core'; import DateFilterLabel from '..'; import { DateFilterControlProps } from '../types'; import { DATE_FILTER_TEST_KEY } from '../utils'; const mockStore = configureStore([thunk]); const defaultProps = { onChange: jest.fn(), onClosePopover: jest.fn(), onOpenPopover: jest.fn(), }; function setup( props: Omit<DateFilterControlProps, 'name'> = defaultProps, store: any = mockStore({}), ) { return ( <Provider store={store}> <DateFilterLabel name="time_range" {...props} /> </Provider> ); } test('DateFilter with default props', () => { render(setup()); // label expect(screen.getByText(NO_TIME_RANGE)).toBeInTheDocument(); // should be popover by default userEvent.click(screen.getByText(NO_TIME_RANGE)); expect( screen.getByTestId(DATE_FILTER_TEST_KEY.popoverOverlay), ).toBeInTheDocument(); }); test('DateFilter should be applied the overlayStyle props', () => { render(setup({ onChange: () => {}, overlayStyle: 'Modal' })); // should be Modal as overlay userEvent.click(screen.getByText(NO_TIME_RANGE)); expect( screen.getByTestId(DATE_FILTER_TEST_KEY.modalOverlay), ).toBeInTheDocument(); }); test('DateFilter should be applied the global config time_filter from the store', () => { render( setup( defaultProps, mockStore({ common: { conf: { DEFAULT_TIME_FILTER: 'Last week' } }, }), ), ); // the label should be 'Last week' expect(screen.getByText('Last week')).toBeInTheDocument(); userEvent.click(screen.getByText('Last week')); expect( screen.getByTestId(DATE_FILTER_TEST_KEY.commonFrame), ).toBeInTheDocument(); }); test('Open and close popover', () => { render(setup()); // click "Cancel" userEvent.click(screen.getByText(NO_TIME_RANGE)); expect(defaultProps.onOpenPopover).toHaveBeenCalled(); expect(screen.getByText('Edit time range')).toBeInTheDocument(); userEvent.click(screen.getByText('CANCEL')); expect(defaultProps.onClosePopover).toHaveBeenCalled(); expect(screen.queryByText('Edit time range')).not.toBeInTheDocument(); // click "Apply" userEvent.click(screen.getByText(NO_TIME_RANGE)); expect(defaultProps.onOpenPopover).toHaveBeenCalled(); expect(screen.getByText('Edit time range')).toBeInTheDocument(); userEvent.click(screen.getByText('APPLY')); expect(defaultProps.onClosePopover).toHaveBeenCalled(); expect(screen.queryByText('Edit time range')).not.toBeInTheDocument(); });
7,626
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/DateFilterControl
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/DateFilterControl/tests/utils.test.ts
/** * 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 { customTimeRangeEncode, customTimeRangeDecode, buildTimeRangeString, formatTimeRange, } from 'src/explore/components/controls/DateFilterControl/utils'; describe('Custom TimeRange', () => { describe('customTimeRangeEncode', () => { it('1) specific : specific', () => { expect( customTimeRangeEncode({ sinceDatetime: '2021-01-20T00:00:00', sinceMode: 'specific', sinceGrain: 'day', sinceGrainValue: -7, untilDatetime: '2021-01-27T00:00:00', untilMode: 'specific', untilGrain: 'day', untilGrainValue: 7, anchorMode: 'now', anchorValue: 'now', }), ).toEqual('2021-01-20T00:00:00 : 2021-01-27T00:00:00'); }); it('2) specific : relative', () => { expect( customTimeRangeEncode({ sinceDatetime: '2021-01-20T00:00:00', sinceMode: 'specific', sinceGrain: 'day', sinceGrainValue: -7, untilDatetime: '2021-01-20T00:00:00', untilMode: 'relative', untilGrain: 'day', untilGrainValue: 7, anchorMode: 'now', anchorValue: 'now', }), ).toEqual( '2021-01-20T00:00:00 : DATEADD(DATETIME("2021-01-20T00:00:00"), 7, day)', ); }); it('3) now : relative', () => { expect( customTimeRangeEncode({ sinceDatetime: 'now', sinceMode: 'now', sinceGrain: 'day', sinceGrainValue: -7, untilDatetime: 'now', untilMode: 'relative', untilGrain: 'day', untilGrainValue: 7, anchorMode: 'now', anchorValue: 'now', }), ).toEqual('now : DATEADD(DATETIME("now"), 7, day)'); }); it('4) today : relative', () => { expect( customTimeRangeEncode({ sinceDatetime: 'today', sinceMode: 'today', sinceGrain: 'day', sinceGrainValue: -7, untilDatetime: 'today', untilMode: 'relative', untilGrain: 'day', untilGrainValue: 7, anchorMode: 'now', anchorValue: 'now', }), ).toEqual('today : DATEADD(DATETIME("today"), 7, day)'); }); it('5) relative : specific', () => { expect( customTimeRangeEncode({ sinceDatetime: '2021-01-27T00:00:00', sinceMode: 'relative', sinceGrain: 'day', sinceGrainValue: -7, untilDatetime: '2021-01-27T00:00:00', untilMode: 'specific', untilGrain: 'day', untilGrainValue: 7, anchorMode: 'now', anchorValue: 'now', }), ).toEqual( 'DATEADD(DATETIME("2021-01-27T00:00:00"), -7, day) : 2021-01-27T00:00:00', ); }); it('6) relative : now', () => { expect( customTimeRangeEncode({ sinceDatetime: 'now', sinceMode: 'relative', sinceGrain: 'day', sinceGrainValue: -7, untilDatetime: 'now', untilMode: 'now', untilGrain: 'day', untilGrainValue: 7, anchorMode: 'now', anchorValue: 'now', }), ).toEqual('DATEADD(DATETIME("now"), -7, day) : now'); }); it('7) relative : today', () => { expect( customTimeRangeEncode({ sinceDatetime: 'today', sinceMode: 'relative', sinceGrain: 'day', sinceGrainValue: -7, untilDatetime: 'today', untilMode: 'today', untilGrain: 'day', untilGrainValue: 7, anchorMode: 'now', anchorValue: 'now', }), ).toEqual('DATEADD(DATETIME("today"), -7, day) : today'); }); it('8) relative : relative (now)', () => { expect( customTimeRangeEncode({ sinceDatetime: 'now', sinceMode: 'relative', sinceGrain: 'day', sinceGrainValue: -7, untilDatetime: 'now', untilMode: 'relative', untilGrain: 'day', untilGrainValue: 7, anchorMode: 'now', anchorValue: 'now', }), ).toEqual( 'DATEADD(DATETIME("now"), -7, day) : DATEADD(DATETIME("now"), 7, day)', ); }); it('9) relative : relative (date/time)', () => { expect( customTimeRangeEncode({ sinceDatetime: '2021-01-27T00:00:00', sinceMode: 'relative', sinceGrain: 'day', sinceGrainValue: -7, untilDatetime: '2021-01-27T00:00:00', untilMode: 'relative', untilGrain: 'day', untilGrainValue: 7, anchorMode: 'specific', anchorValue: '2021-01-27T00:00:00', }), ).toEqual( 'DATEADD(DATETIME("2021-01-27T00:00:00"), -7, day) : DATEADD(DATETIME("2021-01-27T00:00:00"), 7, day)', ); }); }); describe('customTimeRangeDecode', () => { it('1) specific : specific', () => { expect( customTimeRangeDecode('2021-01-20T00:00:00 : 2021-01-27T00:00:00'), ).toEqual({ customRange: { sinceDatetime: '2021-01-20T00:00:00', sinceMode: 'specific', sinceGrain: 'day', sinceGrainValue: -7, untilDatetime: '2021-01-27T00:00:00', untilMode: 'specific', untilGrain: 'day', untilGrainValue: 7, anchorMode: 'now', anchorValue: 'now', }, matchedFlag: true, }); }); it('2) specific : relative', () => { expect( customTimeRangeDecode( '2021-01-20T00:00:00 : DATEADD(DATETIME("2021-01-20T00:00:00"), 7, day)', ), ).toEqual({ customRange: { sinceDatetime: '2021-01-20T00:00:00', sinceMode: 'specific', sinceGrain: 'day', sinceGrainValue: -7, untilDatetime: '2021-01-20T00:00:00', untilMode: 'relative', untilGrain: 'day', untilGrainValue: 7, anchorMode: 'now', anchorValue: 'now', }, matchedFlag: true, }); }); it('3) relative : specific', () => { expect( customTimeRangeDecode( 'DATEADD(DATETIME("2021-01-27T00:00:00"), -7, day) : 2021-01-27T00:00:00', ), ).toEqual({ customRange: { sinceDatetime: '2021-01-27T00:00:00', sinceMode: 'relative', sinceGrain: 'day', sinceGrainValue: -7, untilDatetime: '2021-01-27T00:00:00', untilMode: 'specific', untilGrain: 'day', untilGrainValue: 7, anchorMode: 'now', anchorValue: 'now', }, matchedFlag: true, }); }); it('4) relative : relative (now)', () => { expect( customTimeRangeDecode( 'DATEADD(DATETIME("now"), -7, day) : DATEADD(DATETIME("now"), 7, day)', ), ).toEqual({ customRange: { sinceDatetime: 'now', sinceMode: 'relative', sinceGrain: 'day', sinceGrainValue: -7, untilDatetime: 'now', untilMode: 'relative', untilGrain: 'day', untilGrainValue: 7, anchorMode: 'now', anchorValue: 'now', }, matchedFlag: true, }); }); it('5) relative : relative (date/time)', () => { expect( customTimeRangeDecode( 'DATEADD(DATETIME("2021-01-27T00:00:00"), -7, day) : DATEADD(DATETIME("2021-01-27T00:00:00"), 7, day)', ), ).toEqual({ customRange: { sinceDatetime: '2021-01-27T00:00:00', sinceMode: 'relative', sinceGrain: 'day', sinceGrainValue: -7, untilDatetime: '2021-01-27T00:00:00', untilMode: 'relative', untilGrain: 'day', untilGrainValue: 7, anchorMode: 'specific', anchorValue: '2021-01-27T00:00:00', }, matchedFlag: true, }); }); }); }); describe('buildTimeRangeString', () => { it('generates proper time range string', () => { expect( buildTimeRangeString('2010-07-30T00:00:00', '2020-07-30T00:00:00'), ).toBe('2010-07-30T00:00:00 : 2020-07-30T00:00:00'); expect(buildTimeRangeString('', '2020-07-30T00:00:00')).toBe( ' : 2020-07-30T00:00:00', ); expect(buildTimeRangeString('', '')).toBe(' : '); }); }); describe('formatTimeRange', () => { it('generates a readable time range', () => { expect(formatTimeRange('Last 7 days')).toBe('Last 7 days'); expect(formatTimeRange('No filter')).toBe('No filter'); expect(formatTimeRange('Yesterday : Tomorrow')).toBe( 'Yesterday ≤ col < Tomorrow', ); expect(formatTimeRange('2010-07-30T00:00:00 : 2020-07-30T00:00:00')).toBe( '2010-07-30 ≤ col < 2020-07-30', ); expect(formatTimeRange('2010-07-30T01:00:00 : ')).toBe( '2010-07-30T01:00:00 ≤ col < ∞', ); expect(formatTimeRange(' : 2020-07-30T00:00:00')).toBe( '-∞ ≤ col < 2020-07-30', ); }); });
7,634
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndColumnSelect.test.tsx
/** * 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 { FeatureFlag } from '@superset-ui/core'; import React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import { DndColumnSelect, DndColumnSelectProps, } from 'src/explore/components/controls/DndColumnSelectControl/DndColumnSelect'; const defaultProps: DndColumnSelectProps = { type: 'DndColumnSelect', name: 'Filter', onChange: jest.fn(), options: [{ column_name: 'Column A' }], actions: { setControlValue: jest.fn() }, }; beforeAll(() => { window.featureFlags = { [FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP]: true }; }); afterAll(() => { window.featureFlags = {}; }); test('renders with default props', async () => { render(<DndColumnSelect {...defaultProps} />, { useDnd: true, useRedux: true, }); expect( await screen.findByText('Drop columns here or click'), ).toBeInTheDocument(); }); test('renders with value', async () => { render(<DndColumnSelect {...defaultProps} value="Column A" />, { useDnd: true, useRedux: true, }); expect(await screen.findByText('Column A')).toBeInTheDocument(); }); test('renders adhoc column', async () => { render( <DndColumnSelect {...defaultProps} value={{ sqlExpression: 'Count *', label: 'adhoc column', expressionType: 'SQL', }} />, { useDnd: true, useRedux: true }, ); expect(await screen.findByText('adhoc column')).toBeVisible(); expect(screen.getByLabelText('calculator')).toBeVisible(); });
7,637
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndFilterSelect.test.tsx
/** * 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 React from 'react'; import thunk from 'redux-thunk'; import { Provider } from 'react-redux'; import configureStore from 'redux-mock-store'; import { ensureIsArray, FeatureFlag, GenericDataType, QueryFormData, } from '@superset-ui/core'; import { ColumnMeta } from '@superset-ui/chart-controls'; import { TimeseriesDefaultFormData } from '@superset-ui/plugin-chart-echarts'; import { render, screen } from 'spec/helpers/testing-library'; import AdhocMetric from 'src/explore/components/controls/MetricControl/AdhocMetric'; import AdhocFilter from 'src/explore/components/controls/FilterControl/AdhocFilter'; import { DndFilterSelect, DndFilterSelectProps, } from 'src/explore/components/controls/DndColumnSelectControl/DndFilterSelect'; import { PLACEHOLDER_DATASOURCE } from 'src/dashboard/constants'; import { EXPRESSION_TYPES } from '../FilterControl/types'; const defaultProps: DndFilterSelectProps = { type: 'DndFilterSelect', name: 'Filter', value: [], columns: [], datasource: PLACEHOLDER_DATASOURCE, formData: null, savedMetrics: [], selectedMetrics: [], onChange: jest.fn(), actions: { setControlValue: jest.fn() }, }; const baseFormData = { viz_type: 'my_viz', datasource: 'table__1', }; beforeAll(() => { window.featureFlags = { [FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP]: true }; }); afterAll(() => { window.featureFlags = {}; }); const mockStore = configureStore([thunk]); const store = mockStore({}); function setup({ value = undefined, formData = baseFormData, columns = [], }: { value?: AdhocFilter; formData?: QueryFormData; columns?: ColumnMeta[]; } = {}) { return ( <Provider store={store}> <DndFilterSelect {...defaultProps} value={ensureIsArray(value)} formData={formData} columns={columns} /> </Provider> ); } test('renders with default props', async () => { render(setup(), { useDnd: true }); expect( await screen.findByText('Drop columns/metrics here or click'), ).toBeInTheDocument(); }); test('renders with value', async () => { const value = new AdhocFilter({ sqlExpression: 'COUNT(*)', expressionType: EXPRESSION_TYPES.SQL, }); render(setup({ value }), { useDnd: true, }); expect(await screen.findByText('COUNT(*)')).toBeInTheDocument(); }); test('renders options with saved metric', async () => { render( setup({ formData: { ...baseFormData, ...TimeseriesDefaultFormData, metrics: ['saved_metric'], }, }), { useDnd: true, }, ); expect( await screen.findByText('Drop columns/metrics here or click'), ).toBeInTheDocument(); }); test('renders options with column', async () => { render( setup({ columns: [ { id: 1, type: 'VARCHAR', type_generic: GenericDataType.STRING, column_name: 'Column', }, ], }), { useDnd: true, }, ); expect( await screen.findByText('Drop columns/metrics here or click'), ).toBeInTheDocument(); }); test('renders options with adhoc metric', async () => { const adhocMetric = new AdhocMetric({ expression: 'AVG(birth_names.num)', metric_name: 'avg__num', }); render( setup({ formData: { ...baseFormData, ...TimeseriesDefaultFormData, metrics: [adhocMetric], }, }), { useDnd: true, }, ); expect( await screen.findByText('Drop columns/metrics here or click'), ).toBeInTheDocument(); });
7,639
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndMetricSelect.test.tsx
/** * 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 React from 'react'; import userEvent from '@testing-library/user-event'; import { FeatureFlag } from '@superset-ui/core'; import { render, screen, within, fireEvent, waitFor, } from 'spec/helpers/testing-library'; import { DndMetricSelect } from 'src/explore/components/controls/DndColumnSelectControl/DndMetricSelect'; import { AGGREGATES } from 'src/explore/constants'; import { EXPRESSION_TYPES } from '../MetricControl/AdhocMetric'; const defaultProps = { savedMetrics: [ { metric_name: 'metric_a', expression: 'expression_a', verbose_name: 'metric_a', }, { metric_name: 'metric_b', expression: 'expression_b', verbose_name: 'Metric B', }, ], columns: [ { column_name: 'column_a', }, { column_name: 'column_b', verbose_name: 'Column B', }, ], onChange: () => {}, }; const adhocMetricA = { expressionType: EXPRESSION_TYPES.SIMPLE, column: defaultProps.columns[0], aggregate: AGGREGATES.SUM, optionName: 'abc', }; const adhocMetricB = { expressionType: EXPRESSION_TYPES.SIMPLE, column: defaultProps.columns[1], aggregate: AGGREGATES.SUM, optionName: 'def', }; beforeAll(() => { window.featureFlags = { [FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP]: true }; }); afterAll(() => { window.featureFlags = {}; }); test('renders with default props', () => { render(<DndMetricSelect {...defaultProps} />, { useDnd: true }); expect( screen.getByText('Drop a column/metric here or click'), ).toBeInTheDocument(); }); test('renders with default props and multi = true', () => { render(<DndMetricSelect {...defaultProps} multi />, { useDnd: true }); expect( screen.getByText('Drop columns/metrics here or click'), ).toBeInTheDocument(); }); test('render selected metrics correctly', () => { const metricValues = ['metric_a', 'metric_b', adhocMetricB]; render(<DndMetricSelect {...defaultProps} value={metricValues} multi />, { useDnd: true, }); expect(screen.getByText('metric_a')).toBeVisible(); expect(screen.getByText('Metric B')).toBeVisible(); expect(screen.getByText('SUM(Column B)')).toBeVisible(); }); test('remove selected custom metric when metric gets removed from dataset', () => { let metricValues = ['metric_a', 'metric_b', adhocMetricA, adhocMetricB]; const onChange = (val: any[]) => { metricValues = val; }; const { rerender } = render( <DndMetricSelect {...defaultProps} value={metricValues} onChange={onChange} multi />, { useDnd: true, }, ); const newPropsWithRemovedMetric = { ...defaultProps, savedMetrics: [ { metric_name: 'metric_a', expression: 'expression_a', }, ], }; rerender( <DndMetricSelect {...newPropsWithRemovedMetric} value={metricValues} onChange={onChange} multi />, ); expect(screen.getByText('metric_a')).toBeVisible(); expect(screen.queryByText('Metric B')).not.toBeInTheDocument(); expect(screen.queryByText('metric_b')).not.toBeInTheDocument(); expect(screen.getByText('SUM(column_a)')).toBeVisible(); expect(screen.getByText('SUM(Column B)')).toBeVisible(); }); test('remove selected custom metric when metric gets removed from dataset for single-select metric control', () => { let metricValue = 'metric_b'; const onChange = (val: any) => { metricValue = val; }; const { rerender } = render( <DndMetricSelect {...defaultProps} value={metricValue} onChange={onChange} multi={false} />, { useDnd: true, }, ); expect(screen.getByText('Metric B')).toBeVisible(); expect( screen.queryByText('Drop a column/metric here or click'), ).not.toBeInTheDocument(); const newPropsWithRemovedMetric = { ...defaultProps, savedMetrics: [ { metric_name: 'metric_a', expression: 'expression_a', }, ], }; rerender( <DndMetricSelect {...newPropsWithRemovedMetric} value={metricValue} onChange={onChange} multi={false} />, ); expect(screen.queryByText('Metric B')).not.toBeInTheDocument(); expect(screen.getByText('Drop a column/metric here or click')).toBeVisible(); }); test('remove selected adhoc metric when column gets removed from dataset', async () => { let metricValues = ['metric_a', 'metric_b', adhocMetricA, adhocMetricB]; const onChange = (val: any[]) => { metricValues = val; }; const { rerender } = render( <DndMetricSelect {...defaultProps} value={metricValues} onChange={onChange} multi />, { useDnd: true, }, ); const newPropsWithRemovedColumn = { ...defaultProps, columns: [ { column_name: 'column_a', }, ], }; rerender( <DndMetricSelect {...newPropsWithRemovedColumn} value={metricValues} onChange={onChange} multi />, ); expect(screen.getByText('metric_a')).toBeVisible(); expect(screen.getByText('Metric B')).toBeVisible(); expect(screen.getByText('SUM(column_a)')).toBeVisible(); expect(screen.queryByText('SUM(Column B)')).not.toBeInTheDocument(); }); test('update adhoc metric name when column label in dataset changes', () => { let metricValues = ['metric_a', 'metric_b', adhocMetricA, adhocMetricB]; const onChange = (val: any[]) => { metricValues = val; }; const { rerender } = render( <DndMetricSelect {...defaultProps} value={metricValues} onChange={onChange} multi />, { useDnd: true, }, ); const newPropsWithUpdatedColNames = { ...defaultProps, columns: [ { column_name: 'column_a', verbose_name: 'new col A name', }, { column_name: 'column_b', verbose_name: 'new col B name', }, ], }; // rerender twice - first to update columns, second to update value rerender( <DndMetricSelect {...newPropsWithUpdatedColNames} value={metricValues} onChange={onChange} multi />, ); rerender( <DndMetricSelect {...newPropsWithUpdatedColNames} value={metricValues} onChange={onChange} multi />, ); expect(screen.getByText('metric_a')).toBeVisible(); expect(screen.getByText('Metric B')).toBeVisible(); expect(screen.getByText('SUM(new col A name)')).toBeVisible(); expect(screen.getByText('SUM(new col B name)')).toBeVisible(); }); test('can drag metrics', async () => { const metricValues = ['metric_a', 'metric_b', adhocMetricB]; render(<DndMetricSelect {...defaultProps} value={metricValues} multi />, { useDnd: true, }); expect(screen.getByText('metric_a')).toBeVisible(); expect(screen.getByText('Metric B')).toBeVisible(); const container = screen.getByTestId('dnd-labels-container'); expect(container.childElementCount).toBe(4); const firstMetric = container.children[0] as HTMLElement; const lastMetric = container.children[2] as HTMLElement; expect(within(firstMetric).getByText('metric_a')).toBeVisible(); expect(within(lastMetric).getByText('SUM(Column B)')).toBeVisible(); fireEvent.mouseOver(within(firstMetric).getByText('metric_a')); expect(await screen.findByText('Metric name')).toBeInTheDocument(); fireEvent.dragStart(firstMetric); fireEvent.dragEnter(lastMetric); fireEvent.dragOver(lastMetric); fireEvent.drop(lastMetric); expect(within(firstMetric).getByText('SUM(Column B)')).toBeVisible(); expect(within(lastMetric).getByText('metric_a')).toBeVisible(); }); test('title changes on custom SQL text change', async () => { let metricValues = [adhocMetricA, 'metric_b']; const onChange = (val: any[]) => { metricValues = [...val]; }; const { rerender } = render( <DndMetricSelect {...defaultProps} value={metricValues} onChange={onChange} multi />, { useDnd: true, }, ); expect(screen.getByText('SUM(column_a)')).toBeVisible(); metricValues = [adhocMetricA, 'metric_b', 'metric_a']; rerender( <DndMetricSelect {...defaultProps} value={metricValues} onChange={onChange} multi />, ); expect(screen.getByText('SUM(column_a)')).toBeVisible(); expect(screen.getByText('metric_a')).toBeVisible(); fireEvent.click(screen.getByText('metric_a')); expect(await screen.findByText('Custom SQL')).toBeInTheDocument(); fireEvent.click(screen.getByText('Custom SQL')); expect(screen.getByText('Custom SQL').parentElement).toHaveClass( 'ant-tabs-tab-active', ); const container = screen.getByTestId('adhoc-metric-edit-tabs'); await waitFor(() => { const textArea = container.getElementsByClassName( 'ace_text-input', ) as HTMLCollectionOf<HTMLTextAreaElement>; expect(textArea.length).toBe(1); expect(textArea[0].value).toBe(''); }); expect(screen.getByTestId('AdhocMetricEditTitle#trigger')).toHaveTextContent( 'metric_a', ); const textArea = container.getElementsByClassName( 'ace_text-input', )[0] as HTMLTextAreaElement; // Changing the ACE editor via pasting, since the component // handles the textarea value internally, and changing it doesn't // trigger the onChange await userEvent.paste(textArea, 'New metric'); await waitFor(() => { expect( screen.getByTestId('AdhocMetricEditTitle#trigger'), ).toHaveTextContent('New metric'); }); // Ensure the title does not reset on mouse over fireEvent.mouseEnter(screen.getByTestId('AdhocMetricEditTitle#trigger')); fireEvent.mouseOut(screen.getByTestId('AdhocMetricEditTitle#trigger')); expect(screen.getByTestId('AdhocMetricEditTitle#trigger')).toHaveTextContent( 'New metric', ); });
7,641
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndSelectLabel.test.tsx
/** * 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 React from 'react'; import userEvent from '@testing-library/user-event'; import { render, screen } from 'spec/helpers/testing-library'; import { DndItemType } from 'src/explore/components/DndItemType'; import DndSelectLabel, { DndSelectLabelProps, } from 'src/explore/components/controls/DndColumnSelectControl/DndSelectLabel'; const defaultProps: DndSelectLabelProps = { name: 'Column', accept: 'Column' as DndItemType, onDrop: jest.fn(), canDrop: () => false, valuesRenderer: () => <span />, ghostButtonText: 'Drop columns here or click', onClickGhostButton: jest.fn(), }; test('renders with default props', () => { render(<DndSelectLabel {...defaultProps} />, { useDnd: true }); expect(screen.getByText('Drop columns here or click')).toBeInTheDocument(); }); test('renders ghost button when empty', () => { const ghostButtonText = 'Ghost button text'; render( <DndSelectLabel {...defaultProps} ghostButtonText={ghostButtonText} />, { useDnd: true }, ); expect(screen.getByText(ghostButtonText)).toBeInTheDocument(); }); test('renders values', () => { const values = 'Values'; const valuesRenderer = () => <span>{values}</span>; render(<DndSelectLabel {...defaultProps} valuesRenderer={valuesRenderer} />, { useDnd: true, }); expect(screen.getByText(values)).toBeInTheDocument(); }); test('Handles ghost button click', () => { render(<DndSelectLabel {...defaultProps} />, { useDnd: true }); userEvent.click(screen.getByText('Drop columns here or click')); expect(defaultProps.onClickGhostButton).toHaveBeenCalled(); });
7,643
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/DndColumnSelectControl/Option.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import Option from 'src/explore/components/controls/DndColumnSelectControl/Option'; test('renders with default props', async () => { const { container } = render( <Option index={1} clickClose={jest.fn()}> Option </Option>, ); expect(container).toBeInTheDocument(); expect( await screen.findByRole('img', { name: 'x-small' }), ).toBeInTheDocument(); expect( screen.queryByRole('img', { name: 'caret-right' }), ).not.toBeInTheDocument(); }); test('renders with caret', async () => { render( <Option index={1} clickClose={jest.fn()} withCaret> Option </Option>, ); expect( await screen.findByRole('img', { name: 'x-small' }), ).toBeInTheDocument(); expect( await screen.findByRole('img', { name: 'caret-right' }), ).toBeInTheDocument(); }); test('renders with extra triangle', async () => { render( <Option index={1} clickClose={jest.fn()} isExtra> Option </Option>, ); expect( await screen.findByRole('button', { name: 'Show info tooltip' }), ).toBeInTheDocument(); }); test('triggers onClose', async () => { const clickClose = jest.fn(); render( <Option index={1} clickClose={clickClose}> Option </Option>, ); userEvent.click(await screen.findByRole('img', { name: 'x-small' })); expect(clickClose).toHaveBeenCalled(); });
7,645
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/DndColumnSelectControl/OptionWrapper.test.tsx
/** * 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 React from 'react'; import { render, screen, fireEvent } from 'spec/helpers/testing-library'; import { DndItemType } from 'src/explore/components/DndItemType'; import OptionWrapper from 'src/explore/components/controls/DndColumnSelectControl/OptionWrapper'; test('renders with default props', async () => { const { container } = render( <OptionWrapper index={1} clickClose={jest.fn()} type={'Column' as DndItemType} onShiftOptions={jest.fn()} label="Option" />, { useDnd: true }, ); expect(container).toBeInTheDocument(); expect( await screen.findByRole('img', { name: 'x-small' }), ).toBeInTheDocument(); }); test('triggers onShiftOptions on drop', async () => { const onShiftOptions = jest.fn(); render( <> <OptionWrapper index={1} clickClose={jest.fn()} type={'Column' as DndItemType} onShiftOptions={onShiftOptions} label="Option 1" /> <OptionWrapper index={2} clickClose={jest.fn()} type={'Column' as DndItemType} onShiftOptions={onShiftOptions} label="Option 2" /> </>, { useDnd: true }, ); fireEvent.dragStart(await screen.findByText('Option 1')); fireEvent.drop(await screen.findByText('Option 2')); expect(onShiftOptions).toHaveBeenCalled(); });
7,653
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/FilterBoxItemControl/FilterBoxItemControl.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import FilterBoxItemControl from '.'; const createProps = () => ({ datasource: { columns: [], metrics: [], }, asc: true, clearable: true, multiple: true, column: 'developer_type', label: 'Developer Type', metric: undefined, searchAllOptions: false, defaultValue: undefined, onChange: jest.fn(), }); test('Should render', () => { const props = createProps(); render(<FilterBoxItemControl {...props} />); expect(screen.getByTestId('FilterBoxItemControl')).toBeInTheDocument(); expect(screen.getByRole('button')).toBeInTheDocument(); }); test('Should open modal', () => { const props = createProps(); render(<FilterBoxItemControl {...props} />); userEvent.click(screen.getByRole('button')); expect(screen.getByText('Filter configuration')).toBeInTheDocument(); expect(screen.getByText('Column')).toBeInTheDocument(); expect(screen.getByText('Label')).toBeInTheDocument(); expect(screen.getByText('Default')).toBeInTheDocument(); expect(screen.getByText('Sort metric')).toBeInTheDocument(); expect(screen.getByText('Sort ascending')).toBeInTheDocument(); expect(screen.getByText('Allow multiple selections')).toBeInTheDocument(); expect(screen.getByText('Search all filter options')).toBeInTheDocument(); expect(screen.getByText('Required')).toBeInTheDocument(); });
7,664
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/FilterControl
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/AdhocFilterEditPopoverSimpleTabContent.test.tsx
/** * 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. */ /* eslint-disable no-unused-expressions */ import React from 'react'; import * as redux from 'react-redux'; import sinon from 'sinon'; import { shallow } from 'enzyme'; import thunk from 'redux-thunk'; import { Provider } from 'react-redux'; import configureStore from 'redux-mock-store'; import AdhocFilter from 'src/explore/components/controls/FilterControl/AdhocFilter'; import { AGGREGATES, Operators, OPERATOR_ENUM_TO_OPERATOR_TYPE, } from 'src/explore/constants'; import AdhocMetric from 'src/explore/components/controls/MetricControl/AdhocMetric'; import { render, screen, act, waitFor } from '@testing-library/react'; import { supersetTheme, FeatureFlag, ThemeProvider } from '@superset-ui/core'; import * as uiCore from '@superset-ui/core'; import userEvent from '@testing-library/user-event'; import fetchMock from 'fetch-mock'; import { TestDataset } from '@superset-ui/chart-controls'; import AdhocFilterEditPopoverSimpleTabContent, { useSimpleTabFilterProps, Props, } from '.'; import { CLAUSES, EXPRESSION_TYPES } from '../types'; const simpleAdhocFilter = new AdhocFilter({ expressionType: EXPRESSION_TYPES.SIMPLE, subject: 'value', operatorId: Operators.GREATER_THAN, operator: OPERATOR_ENUM_TO_OPERATOR_TYPE[Operators.GREATER_THAN].operation, comparator: '10', clause: CLAUSES.WHERE, }); const advancedTypeTestAdhocFilterTest = new AdhocFilter({ expressionType: EXPRESSION_TYPES.SIMPLE, subject: 'advancedDataType', operatorId: null, operator: null, comparator: null, clause: null, }); const simpleMultiAdhocFilter = new AdhocFilter({ expressionType: EXPRESSION_TYPES.SIMPLE, subject: 'value', operatorId: Operators.IN, operator: OPERATOR_ENUM_TO_OPERATOR_TYPE[Operators.IN].operation, comparator: ['10'], clause: CLAUSES.WHERE, }); const sumValueAdhocMetric = new AdhocMetric({ expressionType: EXPRESSION_TYPES.SIMPLE, column: { type: 'VARCHAR(255)', column_name: 'source', id: 5 }, aggregate: AGGREGATES.SUM, label: 'test-AdhocMetric', }); const simpleCustomFilter = new AdhocFilter({ expressionType: EXPRESSION_TYPES.SIMPLE, subject: 'ds', operator: 'LATEST PARTITION', operatorId: Operators.LATEST_PARTITION, }); const options = [ { type: 'VARCHAR(255)', column_name: 'source', id: 1 }, { type: 'VARCHAR(255)', column_name: 'target', id: 2 }, { type: 'DOUBLE', column_name: 'value', id: 3 }, { saved_metric_name: 'my_custom_metric', id: 4 }, sumValueAdhocMetric, ]; const getAdvancedDataTypeTestProps = (overrides?: Record<string, any>) => { const onChange = sinon.spy(); const validHandler = sinon.spy(); const props = { adhocFilter: advancedTypeTestAdhocFilterTest, onChange, options: [{ type: 'DOUBLE', column_name: 'advancedDataType', id: 5 }], datasource: { ...TestDataset, ...{ columns: [], filter_select: false, }, }, partitionColumn: 'test', ...overrides, validHandler, }; return props; }; function setup(overrides?: Record<string, any>) { const onChange = sinon.spy(); const validHandler = sinon.spy(); const spy = jest.spyOn(redux, 'useSelector'); spy.mockReturnValue({}); const props = { adhocFilter: simpleAdhocFilter, onChange, options, datasource: { ...TestDataset, ...{ columns: [], filter_select: false, }, }, partitionColumn: 'test', ...overrides, validHandler, }; const wrapper = shallow( <AdhocFilterEditPopoverSimpleTabContent {...props} />, ); return { wrapper, props }; } describe('AdhocFilterEditPopoverSimpleTabContent', () => { it('renders the simple tab form', () => { const { wrapper } = setup(); expect(wrapper).toExist(); }); it('shows boolean only operators when subject is boolean', () => { const { props } = setup({ adhocFilter: new AdhocFilter({ expressionType: EXPRESSION_TYPES.SIMPLE, subject: 'value', operatorId: null, operator: null, comparator: null, clause: null, }), datasource: { columns: [ { id: 3, column_name: 'value', type: 'BOOL', }, ], }, }); const { isOperatorRelevant } = useSimpleTabFilterProps(props); [ Operators.IS_TRUE, Operators.IS_FALSE, Operators.IS_NULL, Operators.IS_FALSE, ].map(operator => expect(isOperatorRelevant(operator, 'value')).toBe(true)); }); it('shows boolean only operators when subject is number', () => { const { props } = setup({ adhocFilter: new AdhocFilter({ expressionType: EXPRESSION_TYPES.SIMPLE, subject: 'value', operatorId: null, operator: null, comparator: null, clause: null, }), datasource: { columns: [ { id: 3, column_name: 'value', type: 'INT', }, ], }, }); const { isOperatorRelevant } = useSimpleTabFilterProps(props); [ Operators.IS_TRUE, Operators.IS_FALSE, Operators.IS_NULL, Operators.IS_NOT_NULL, ].map(operator => expect(isOperatorRelevant(operator, 'value')).toBe(true)); }); it('will convert from individual comparator to array if the operator changes to multi', () => { const { props } = setup(); const { onOperatorChange } = useSimpleTabFilterProps(props); onOperatorChange(Operators.IN); expect(props.onChange.calledOnce).toBe(true); expect(props.onChange.lastCall.args[0].comparator).toEqual(['10']); expect(props.onChange.lastCall.args[0].operatorId).toEqual(Operators.IN); }); it('will convert from array to individual comparators if the operator changes from multi', () => { const { props } = setup({ adhocFilter: simpleMultiAdhocFilter, }); const { onOperatorChange } = useSimpleTabFilterProps(props); onOperatorChange(Operators.LESS_THAN); expect(props.onChange.calledOnce).toBe(true); expect(props.onChange.lastCall.args[0]).toEqual( simpleMultiAdhocFilter.duplicateWith({ operatorId: Operators.LESS_THAN, operator: '<', comparator: '10', }), ); }); it('passes the new adhocFilter to onChange after onComparatorChange', () => { const { props } = setup(); const { onComparatorChange } = useSimpleTabFilterProps(props); onComparatorChange('20'); expect(props.onChange.calledOnce).toBe(true); expect(props.onChange.lastCall.args[0]).toEqual( simpleAdhocFilter.duplicateWith({ comparator: '20' }), ); }); it('will filter operators for table datasources', () => { const { props } = setup({ datasource: { type: 'table' } }); const { isOperatorRelevant } = useSimpleTabFilterProps(props); expect(isOperatorRelevant(Operators.LIKE, 'value')).toBe(true); }); it('will show LATEST PARTITION operator', () => { const { props } = setup({ datasource: { type: 'table', datasource_name: 'table1', schema: 'schema', }, adhocFilter: simpleCustomFilter, partitionColumn: 'ds', }); const { isOperatorRelevant } = useSimpleTabFilterProps(props); expect(isOperatorRelevant(Operators.LATEST_PARTITION, 'ds')).toBe(true); expect(isOperatorRelevant(Operators.LATEST_PARTITION, 'value')).toBe(false); }); it('will generate custom sqlExpression for LATEST PARTITION operator', () => { const testAdhocFilter = new AdhocFilter({ expressionType: EXPRESSION_TYPES.SIMPLE, subject: 'ds', }); const { props } = setup({ datasource: { type: 'table', datasource_name: 'table1', schema: 'schema', }, adhocFilter: testAdhocFilter, partitionColumn: 'ds', }); const { onOperatorChange } = useSimpleTabFilterProps(props); onOperatorChange(Operators.LATEST_PARTITION); expect(props.onChange.calledOnce).toBe(true); expect(props.onChange.lastCall.args[0]).toEqual( testAdhocFilter.duplicateWith({ subject: 'ds', operator: 'LATEST PARTITION', operatorId: Operators.LATEST_PARTITION, comparator: null, clause: 'WHERE', expressionType: 'SQL', sqlExpression: "ds = '{{ presto.latest_partition('schema.table1') }}'", }), ); }); it('will not display boolean operators when column type is string', () => { const { props } = setup({ datasource: { type: 'table', datasource_name: 'table1', schema: 'schema', columns: [{ column_name: 'value', type: 'STRING' }], }, adhocFilter: simpleAdhocFilter, }); const { isOperatorRelevant } = useSimpleTabFilterProps(props); const booleanOnlyOperators = [Operators.IS_TRUE, Operators.IS_FALSE]; booleanOnlyOperators.forEach(operator => { expect(isOperatorRelevant(operator, 'value')).toBe(false); }); }); it('will display boolean operators when column is an expression', () => { const { props } = setup({ datasource: { type: 'table', datasource_name: 'table1', schema: 'schema', columns: [ { column_name: 'value', expression: 'case when value is 0 then "NO"', }, ], }, adhocFilter: simpleAdhocFilter, }); const { isOperatorRelevant } = useSimpleTabFilterProps(props); const booleanOnlyOperators = [Operators.IS_TRUE, Operators.IS_FALSE]; booleanOnlyOperators.forEach(operator => { expect(isOperatorRelevant(operator, 'value')).toBe(true); }); }); it('sets comparator to true when operator is IS_TRUE', () => { const { props } = setup(); const { onOperatorChange } = useSimpleTabFilterProps(props); onOperatorChange(Operators.IS_TRUE); expect(props.onChange.calledOnce).toBe(true); expect(props.onChange.lastCall.args[0].operatorId).toBe(Operators.IS_TRUE); expect(props.onChange.lastCall.args[0].operator).toBe('=='); expect(props.onChange.lastCall.args[0].comparator).toBe(true); }); it('sets comparator to false when operator is IS_FALSE', () => { const { props } = setup(); const { onOperatorChange } = useSimpleTabFilterProps(props); onOperatorChange(Operators.IS_FALSE); expect(props.onChange.calledOnce).toBe(true); expect(props.onChange.lastCall.args[0].operatorId).toBe(Operators.IS_FALSE); expect(props.onChange.lastCall.args[0].operator).toBe('=='); expect(props.onChange.lastCall.args[0].comparator).toBe(false); }); it('sets comparator to null when operator is IS_NULL or IS_NOT_NULL', () => { const { props } = setup(); const { onOperatorChange } = useSimpleTabFilterProps(props); [Operators.IS_NULL, Operators.IS_NOT_NULL].forEach(op => { onOperatorChange(op); expect(props.onChange.called).toBe(true); expect(props.onChange.lastCall.args[0].operatorId).toBe(op); expect(props.onChange.lastCall.args[0].operator).toBe( OPERATOR_ENUM_TO_OPERATOR_TYPE[op].operation, ); expect(props.onChange.lastCall.args[0].comparator).toBe(null); }); }); }); const ADVANCED_DATA_TYPE_ENDPOINT_VALID = 'glob:*/api/v1/advanced_data_type/convert?q=(type:type,values:!(v))'; const ADVANCED_DATA_TYPE_ENDPOINT_INVALID = 'glob:*/api/v1/advanced_data_type/convert?q=(type:type,values:!(e))'; fetchMock.get(ADVANCED_DATA_TYPE_ENDPOINT_VALID, { result: { display_value: 'VALID', error_message: '', valid_filter_operators: [Operators.EQUALS], values: ['VALID'], }, }); fetchMock.get(ADVANCED_DATA_TYPE_ENDPOINT_INVALID, { result: { display_value: '', error_message: 'error', valid_filter_operators: [], values: [], }, }); const mockStore = configureStore([thunk]); const store = mockStore({}); describe('AdhocFilterEditPopoverSimpleTabContent Advanced data Type Test', () => { const setupFilter = async (props: Props) => { await act(async () => { render( <Provider store={store}> <ThemeProvider theme={supersetTheme}> <AdhocFilterEditPopoverSimpleTabContent {...props} /> </ThemeProvider> , </Provider>, ); }); }; let isFeatureEnabledMock: any; beforeEach(async () => { isFeatureEnabledMock = jest .spyOn(uiCore, 'isFeatureEnabled') .mockImplementation( (featureFlag: FeatureFlag) => featureFlag === FeatureFlag.ENABLE_ADVANCED_DATA_TYPES, ); }); afterAll(() => { isFeatureEnabledMock.restore(); }); it('should not call API when column has no advanced data type', async () => { fetchMock.resetHistory(); const props = getAdvancedDataTypeTestProps(); await setupFilter(props); const filterValueField = screen.getByPlaceholderText( 'Filter value (case sensitive)', ); await act(async () => { userEvent.type(filterValueField, 'v'); }); await act(async () => { userEvent.type(filterValueField, '{enter}'); }); // When the column is not a advanced data type, // the advanced data type endpoint should not be called await waitFor(() => expect(fetchMock.calls(ADVANCED_DATA_TYPE_ENDPOINT_VALID)).toHaveLength( 0, ), ); }); it('should call API when column has advanced data type', async () => { fetchMock.resetHistory(); const props = getAdvancedDataTypeTestProps({ options: [ { type: 'DOUBLE', column_name: 'advancedDataType', id: 5, advanced_data_type: 'type', }, ], }); await setupFilter(props); const filterValueField = screen.getByPlaceholderText( 'Filter value (case sensitive)', ); await act(async () => { userEvent.type(filterValueField, 'v'); }); await act(async () => { userEvent.type(filterValueField, '{enter}'); }); // When the column is a advanced data type, // the advanced data type endpoint should be called await waitFor(() => expect(fetchMock.calls(ADVANCED_DATA_TYPE_ENDPOINT_VALID)).toHaveLength( 1, ), ); expect(props.validHandler.lastCall.args[0]).toBe(true); }); it('save button should be disabled if error message from API is returned', async () => { fetchMock.resetHistory(); const props = getAdvancedDataTypeTestProps({ options: [ { type: 'DOUBLE', column_name: 'advancedDataType', id: 5, advanced_data_type: 'type', }, ], }); await setupFilter(props); const filterValueField = screen.getByPlaceholderText( 'Filter value (case sensitive)', ); await act(async () => { userEvent.type(filterValueField, 'e'); }); await act(async () => { userEvent.type(filterValueField, '{enter}'); }); // When the column is a advanced data type but an error response is given by the endpoint, // the save button should be disabled await waitFor(() => expect(fetchMock.calls(ADVANCED_DATA_TYPE_ENDPOINT_INVALID)).toHaveLength( 1, ), ); expect(props.validHandler.lastCall.args[0]).toBe(false); }); it('advanced data type operator list should update after API response', async () => { fetchMock.resetHistory(); const props = getAdvancedDataTypeTestProps({ options: [ { type: 'DOUBLE', column_name: 'advancedDataType', id: 5, advanced_data_type: 'type', }, ], }); await setupFilter(props); const filterValueField = screen.getByPlaceholderText( 'Filter value (case sensitive)', ); await act(async () => { userEvent.type(filterValueField, 'v'); }); await act(async () => { userEvent.type(filterValueField, '{enter}'); }); // When the column is a advanced data type, // the advanced data type endpoint should be called await waitFor(() => expect(fetchMock.calls(ADVANCED_DATA_TYPE_ENDPOINT_VALID)).toHaveLength( 1, ), ); expect(props.validHandler.lastCall.args[0]).toBe(true); const operatorValueField = screen.getByText('1 operator(s)'); await act(async () => { userEvent.type(operatorValueField, '{enter}'); }); expect(screen.getByText('EQUALS')).toBeTruthy(); }); });
7,669
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/FilterControl
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterOption/AdhocFilterOption.test.tsx
/** * 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 React from 'react'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import AdhocFilter from 'src/explore/components/controls/FilterControl/AdhocFilter'; import AdhocFilterOption, { AdhocFilterOptionProps } from '.'; import { CLAUSES, EXPRESSION_TYPES } from '../types'; const simpleAdhocFilter = new AdhocFilter({ expressionType: EXPRESSION_TYPES.SIMPLE, subject: 'value', operator: '>', comparator: '10', clause: CLAUSES.WHERE, }); const options = [ { type: 'VARCHAR(255)', column_name: 'source', id: 1 }, { type: 'VARCHAR(255)', column_name: 'target', id: 2 }, { type: 'DOUBLE', column_name: 'value', id: 3 }, ]; const mockedProps = { adhocFilter: simpleAdhocFilter, onFilterEdit: jest.fn(), onRemoveFilter: jest.fn(), options, sections: [], operators: [], datasource: {}, partitionColumn: '', onMoveLabel: jest.fn(), onDropLabel: jest.fn(), index: 1, }; const setup = (props: AdhocFilterOptionProps) => ( <AdhocFilterOption {...props} /> ); test('should render', async () => { const { container } = render(setup(mockedProps), { useDnd: true, useRedux: true, }); await waitFor(() => expect(container).toBeInTheDocument()); }); test('should render the control label', async () => { render(setup(mockedProps), { useDnd: true, useRedux: true }); expect(await screen.findByText('value > 10')).toBeInTheDocument(); }); test('should render the remove button', async () => { render(setup(mockedProps), { useDnd: true, useRedux: true }); const removeBtn = await screen.findByRole('button'); expect(removeBtn).toBeInTheDocument(); }); test('should render the right caret', async () => { render(setup(mockedProps), { useDnd: true, useRedux: true }); expect( await screen.findByRole('img', { name: 'caret-right' }), ).toBeInTheDocument(); }); test('should render the Popover on clicking the right caret', async () => { render(setup(mockedProps), { useDnd: true, useRedux: true }); const rightCaret = await screen.findByRole('img', { name: 'caret-right' }); userEvent.click(rightCaret); expect(screen.getByRole('tooltip')).toBeInTheDocument(); });
7,671
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/FilterControl
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterPopoverTrigger/AdhocFilterPopoverTrigger.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import AdhocFilter from 'src/explore/components/controls/FilterControl/AdhocFilter'; import AdhocFilterPopoverTrigger from '.'; import { CLAUSES, EXPRESSION_TYPES } from '../types'; const simpleAdhocFilter = new AdhocFilter({ expressionType: EXPRESSION_TYPES.SIMPLE, subject: 'value', operator: '>', comparator: '10', clause: CLAUSES.WHERE, }); const mockedProps = { adhocFilter: simpleAdhocFilter, options: [], datasource: {}, onFilterEdit: jest.fn(), }; test('should render', () => { const { container } = render( <AdhocFilterPopoverTrigger {...mockedProps}> Click </AdhocFilterPopoverTrigger>, ); expect(container).toBeInTheDocument(); }); test('should render the Popover on click when uncontrolled', () => { render( <AdhocFilterPopoverTrigger {...mockedProps}> Click </AdhocFilterPopoverTrigger>, ); expect(screen.queryByRole('tooltip')).not.toBeInTheDocument(); userEvent.click(screen.getByText('Click')); expect(screen.getByRole('tooltip')).toBeInTheDocument(); }); test('should be visible when controlled', async () => { const controlledProps = { ...mockedProps, isControlledComponent: true, visible: true, togglePopover: jest.fn(), closePopover: jest.fn(), }; render( <AdhocFilterPopoverTrigger {...controlledProps}> Click </AdhocFilterPopoverTrigger>, ); expect(await screen.findByRole('tooltip')).toBeInTheDocument(); }); test('should NOT be visible when controlled', () => { const controlledProps = { ...mockedProps, isControlledComponent: true, visible: false, togglePopover: jest.fn(), closePopover: jest.fn(), }; render( <AdhocFilterPopoverTrigger {...controlledProps}> Click </AdhocFilterPopoverTrigger>, ); expect(screen.queryByRole('tooltip')).not.toBeInTheDocument(); });
7,676
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/FilterControl
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/FilterControl/utils/useDatePickerInAdhocfilter.test.ts
/** * 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 { renderHook } from '@testing-library/react-hooks'; import { TestDataset } from '@superset-ui/chart-controls'; import * as supersetCoreModule from '@superset-ui/core'; import { useDatePickerInAdhocFilter } from './useDatePickerInAdhocFilter'; test('should return undefined if Generic Axis is disabled', () => { Object.defineProperty(supersetCoreModule, 'hasGenericChartAxes', { value: false, }); const { result } = renderHook(() => useDatePickerInAdhocFilter({ columnName: 'ds', datasource: TestDataset, onChange: jest.fn(), }), ); expect(result.current).toBeUndefined(); }); test('should return undefined if column is not temporal', () => { Object.defineProperty(supersetCoreModule, 'hasGenericChartAxes', { value: true, }); const { result } = renderHook(() => useDatePickerInAdhocFilter({ columnName: 'gender', datasource: TestDataset, onChange: jest.fn(), }), ); expect(result.current).toBeUndefined(); }); test('should return JSX', () => { Object.defineProperty(supersetCoreModule, 'hasGenericChartAxes', { value: true, }); const { result } = renderHook(() => useDatePickerInAdhocFilter({ columnName: 'ds', datasource: TestDataset, onChange: jest.fn(), }), ); expect(result.current).not.toBeUndefined(); });
7,677
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/FilterControl
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/FilterControl/utils/useGetTimeRangeLabel.test.ts
/** * 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 { renderHook } from '@testing-library/react-hooks'; import { NO_TIME_RANGE } from '@superset-ui/core'; import { Operators } from 'src/explore/constants'; import * as FetchTimeRangeModule from 'src/explore/components/controls/DateFilterControl'; import { useGetTimeRangeLabel } from './useGetTimeRangeLabel'; import AdhocFilter from '../AdhocFilter'; import { CLAUSES, EXPRESSION_TYPES } from '../types'; test('should return empty object if operator is not TEMPORAL_RANGE', () => { const adhocFilter = new AdhocFilter({ expressionType: EXPRESSION_TYPES.SIMPLE, subject: 'value', operator: '>', comparator: '10', clause: CLAUSES.WHERE, }); const { result } = renderHook(() => useGetTimeRangeLabel(adhocFilter)); expect(result.current).toEqual({}); }); test('should return empty object if expressionType is SQL', () => { const adhocFilter = new AdhocFilter({ expressionType: EXPRESSION_TYPES.SQL, subject: 'temporal column', operator: Operators.TEMPORAL_RANGE, comparator: 'Last week', clause: CLAUSES.WHERE, }); const { result } = renderHook(() => useGetTimeRangeLabel(adhocFilter)); expect(result.current).toEqual({}); }); test('should get "No filter" label', () => { const adhocFilter = new AdhocFilter({ expressionType: EXPRESSION_TYPES.SIMPLE, subject: 'temporal column', operator: Operators.TEMPORAL_RANGE, comparator: NO_TIME_RANGE, clause: CLAUSES.WHERE, }); const { result } = renderHook(() => useGetTimeRangeLabel(adhocFilter)); expect(result.current).toEqual({ actualTimeRange: 'temporal column (No filter)', title: 'No filter', }); }); test('should get actualTimeRange and title', async () => { jest .spyOn(FetchTimeRangeModule, 'fetchTimeRange') .mockResolvedValue({ value: 'MOCK TIME' }); const adhocFilter = new AdhocFilter({ expressionType: EXPRESSION_TYPES.SIMPLE, subject: 'temporal column', operator: Operators.TEMPORAL_RANGE, comparator: 'Last week', clause: CLAUSES.WHERE, }); const { result } = await renderHook(() => useGetTimeRangeLabel(adhocFilter)); expect(result.current).toEqual({ actualTimeRange: 'MOCK TIME', title: 'Last week', }); }); test('should get actualTimeRange and title when gets an error', async () => { jest .spyOn(FetchTimeRangeModule, 'fetchTimeRange') .mockResolvedValue({ error: 'MOCK ERROR' }); const adhocFilter = new AdhocFilter({ expressionType: EXPRESSION_TYPES.SIMPLE, subject: 'temporal column', operator: Operators.TEMPORAL_RANGE, comparator: 'Last week', clause: CLAUSES.WHERE, }); const { result } = await renderHook(() => useGetTimeRangeLabel(adhocFilter)); expect(result.current).toEqual({ actualTimeRange: 'temporal column (Last week)', title: 'MOCK ERROR', }); });
7,679
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/FixedOrMetricControl/FixedOrMetricControl.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import FixedOrMetricControl from '.'; jest.mock( 'src/components/Icons/Icon', () => ({ fileName }: { fileName: string }) => <span role="img" aria-label={fileName.replace('_', '-')} />, ); const createProps = () => ({ datasource: { columns: [{ column_name: 'Column A' }], metrics: [{ metric_name: 'Metric A', expression: 'COUNT(*)' }], }, }); test('renders with minimal props', () => { render(<FixedOrMetricControl {...createProps()} />); expect(screen.getByRole('button')).toBeInTheDocument(); expect(screen.getByText('5')).toBeInTheDocument(); }); test('renders with default value', () => { render( <FixedOrMetricControl {...createProps()} default={{ type: 'fix', value: 10 }} />, ); expect(screen.getByRole('button')).toBeInTheDocument(); expect(screen.getByText('10')).toBeInTheDocument(); }); test('renders with value', () => { render( <FixedOrMetricControl {...createProps()} default={{ type: 'fix', value: 10 }} value={{ type: 'fix', value: 20 }} />, ); expect(screen.getByRole('button')).toBeInTheDocument(); expect(screen.getByText('20')).toBeInTheDocument(); }); test('renders with metric type', () => { render( <FixedOrMetricControl {...createProps()} value={{ type: 'metric', value: { label: 'Metric A', expressionType: 'SQL', sqlExpression: 'COUNT(*)', }, }} />, ); expect(screen.getByRole('button')).toBeInTheDocument(); expect(screen.getByText('Metric A')).toBeInTheDocument(); }); test('triggers onChange', () => { const onChange = jest.fn(); render( <FixedOrMetricControl {...createProps()} value={{ type: 'fix', value: 10 }} onChange={onChange} />, ); userEvent.click(screen.getByText('10')); expect(onChange).not.toHaveBeenCalled(); userEvent.type(screen.getByRole('textbox'), '20'); expect(onChange).toHaveBeenCalled(); }); test('switches control type', () => { render( <FixedOrMetricControl {...createProps()} value={{ type: 'fix', value: 10 }} />, ); userEvent.click(screen.getByText('10')); userEvent.click(screen.getByText('Based on a metric')); expect(screen.getByText('metric:')).toBeInTheDocument(); userEvent.click(screen.getByText('Fixed')); expect(screen.getByText('10')).toBeInTheDocument(); });
7,683
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricEditPopoverTitle.test.tsx
/** * 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 React from 'react'; import userEvent from '@testing-library/user-event'; import { screen, render, fireEvent, waitFor, } from 'spec/helpers/testing-library'; import AdhocMetricEditPopoverTitle, { AdhocMetricEditPopoverTitleProps, } from 'src/explore/components/controls/MetricControl/AdhocMetricEditPopoverTitle'; const titleProps = { label: 'COUNT(*)', hasCustomLabel: false, }; const setup = (props: Partial<AdhocMetricEditPopoverTitleProps> = {}) => { const onChange = jest.fn(); const { container } = render( <AdhocMetricEditPopoverTitle title={titleProps} onChange={onChange} {...props} />, ); return { container, onChange }; }; test('should render', async () => { const { container } = setup(); expect(container).toBeInTheDocument(); expect(screen.queryByTestId('AdhocMetricTitle')).not.toBeInTheDocument(); expect(screen.getByText(titleProps.label)).toBeVisible(); }); test('should render tooltip on hover', async () => { const { container } = setup(); expect(screen.queryByText('Click to edit label')).not.toBeInTheDocument(); fireEvent.mouseOver(screen.getByTestId('AdhocMetricEditTitle#trigger')); expect(await screen.findByText('Click to edit label')).toBeInTheDocument(); expect( container.parentElement?.getElementsByClassName('ant-tooltip-hidden') .length, ).toBe(0); fireEvent.mouseOut(screen.getByTestId('AdhocMetricEditTitle#trigger')); await waitFor(() => { expect( container.parentElement?.getElementsByClassName('ant-tooltip-hidden') .length, ).toBe(1); }); }); test('render non-interactive span with title when edit is disabled', async () => { const { container } = setup({ isEditDisabled: true }); expect(container).toBeInTheDocument(); expect(screen.queryByTestId('AdhocMetricTitle')).toBeInTheDocument(); expect(screen.getByText(titleProps.label)).toBeVisible(); expect( screen.queryByTestId('AdhocMetricEditTitle#trigger'), ).not.toBeInTheDocument(); }); test('render default label if no title is provided', async () => { const { container } = setup({ title: undefined }); expect(container).toBeInTheDocument(); expect(screen.queryByTestId('AdhocMetricTitle')).not.toBeInTheDocument(); expect(screen.getByText('My metric')).toBeVisible(); }); test('start and end the title edit mode', async () => { const { container, onChange } = setup(); expect(container).toBeInTheDocument(); expect(container.getElementsByTagName('i')[0]).toBeVisible(); expect(screen.getByText(titleProps.label)).toBeVisible(); expect( screen.queryByTestId('AdhocMetricEditTitle#input'), ).not.toBeInTheDocument(); fireEvent.click( container.getElementsByClassName('AdhocMetricEditPopoverTitle')[0], ); expect(await screen.findByTestId('AdhocMetricEditTitle#input')).toBeVisible(); userEvent.type(screen.getByTestId('AdhocMetricEditTitle#input'), 'Test'); expect(onChange).toHaveBeenCalledTimes(4); fireEvent.keyPress(screen.getByTestId('AdhocMetricEditTitle#input'), { key: 'Enter', charCode: 13, }); expect( screen.queryByTestId('AdhocMetricEditTitle#input'), ).not.toBeInTheDocument(); fireEvent.click( container.getElementsByClassName('AdhocMetricEditPopoverTitle')[0], ); expect(await screen.findByTestId('AdhocMetricEditTitle#input')).toBeVisible(); userEvent.type( screen.getByTestId('AdhocMetricEditTitle#input'), 'Second test', ); expect(onChange).toHaveBeenCalled(); fireEvent.blur(screen.getByTestId('AdhocMetricEditTitle#input')); expect( screen.queryByTestId('AdhocMetricEditTitle#input'), ).not.toBeInTheDocument(); });
7,689
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/MetricControl/AggregateOption.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import AggregateOption from 'src/explore/components/controls/MetricControl/AggregateOption'; describe('AggregateOption', () => { it('renders the aggregate', () => { render(<AggregateOption aggregate={{ aggregate_name: 'SUM' }} />); const aggregateOption = screen.getByText(/sum/i); expect(aggregateOption).toBeVisible(); }); });
7,704
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/MetricControl
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricEditPopover/AdhocMetricEditPopover.test.tsx
/** * 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 userEvent from '@testing-library/user-event'; import React from 'react'; import { render, screen, waitFor, within } from 'spec/helpers/testing-library'; import AdhocMetric from 'src/explore/components/controls/MetricControl/AdhocMetric'; import AdhocMetricEditPopover from '.'; const createProps = () => ({ onChange: jest.fn(), onClose: jest.fn(), onResize: jest.fn(), getCurrentTab: jest.fn(), getCurrentLabel: jest.fn(), savedMetric: { id: 64, metric_name: 'count', expression: 'COUNT(*)', }, savedMetricsOptions: [ { id: 64, metric_name: 'count', expression: 'COUNT(*)', }, { id: 65, metric_name: 'sum', expression: 'sum(num)', }, ], adhocMetric: new AdhocMetric({}), datasource: { extra: '{}', type: 'table', }, columns: [ { id: 1342, column_name: 'highest_degree_earned', expression: "CASE \n WHEN school_degree = 'no high school (secondary school)' THEN 'A. No high school (secondary school)'\n WHEN school_degree = 'some high school' THEN 'B. Some high school'\n WHEN school_degree = 'high school diploma or equivalent (GED)' THEN 'C. High school diploma or equivalent (GED)'\n WHEN school_degree = 'associate''s degree' THEN 'D. Associate''s degree'\n WHEN school_degree = 'some college credit, no degree' THEN 'E. Some college credit, no degree'\n WHEN school_degree = 'bachelor''s degree' THEN 'F. Bachelor''s degree'\n WHEN school_degree = 'trade, technical, or vocational training' THEN 'G. Trade, technical, or vocational training'\n WHEN school_degree = 'master''s degree (non-professional)' THEN 'H. Master''s degree (non-professional)'\n WHEN school_degree = 'Ph.D.' THEN 'I. Ph.D.'\n WHEN school_degree = 'professional degree (MBA, MD, JD, etc.)' THEN 'J. Professional degree (MBA, MD, JD, etc.)'\nEND", type: 'STRING', }, ], }); test('Should render', () => { const props = createProps(); render(<AdhocMetricEditPopover {...props} />); expect(screen.getByTestId('metrics-edit-popover')).toBeVisible(); }); test('Should render correct elements', () => { const props = createProps(); render(<AdhocMetricEditPopover {...props} />); expect(screen.getByRole('tablist')).toBeVisible(); expect(screen.getByRole('button', { name: 'Resize' })).toBeVisible(); expect(screen.getByRole('button', { name: 'Save' })).toBeVisible(); expect(screen.getByRole('button', { name: 'Close' })).toBeVisible(); }); test('Should render correct elements for SQL', () => { const props = createProps(); render(<AdhocMetricEditPopover {...props} />); expect(screen.getByRole('tab', { name: 'Custom SQL' })).toBeVisible(); expect(screen.getByRole('tab', { name: 'Simple' })).toBeVisible(); expect(screen.getByRole('tab', { name: 'Saved' })).toBeVisible(); expect(screen.getByRole('tabpanel', { name: 'Saved' })).toBeVisible(); }); test('Should render correct elements for allow ad-hoc metrics', () => { const props = { ...createProps(), datasource: { extra: '{"disallow_adhoc_metrics": false}' }, }; render(<AdhocMetricEditPopover {...props} />); expect(screen.getByRole('tab', { name: 'Custom SQL' })).toBeEnabled(); expect(screen.getByRole('tab', { name: 'Simple' })).toBeEnabled(); expect(screen.getByRole('tab', { name: 'Saved' })).toBeEnabled(); expect(screen.getByRole('tabpanel', { name: 'Saved' })).toBeVisible(); }); test('Should render correct elements for disallow ad-hoc metrics', () => { const props = { ...createProps(), datasource: { extra: '{"disallow_adhoc_metrics": true}' }, }; render(<AdhocMetricEditPopover {...props} />); expect(screen.getByRole('tab', { name: 'Custom SQL' })).toHaveAttribute( 'aria-disabled', 'true', ); expect(screen.getByRole('tab', { name: 'Simple' })).toHaveAttribute( 'aria-disabled', 'true', ); expect(screen.getByRole('tab', { name: 'Saved' })).toBeEnabled(); expect(screen.getByRole('tabpanel', { name: 'Saved' })).toBeVisible(); }); test('Clicking on "Close" should call onClose', () => { const props = createProps(); render(<AdhocMetricEditPopover {...props} />); expect(props.onClose).toBeCalledTimes(0); userEvent.click(screen.getByRole('button', { name: 'Close' })); expect(props.onClose).toBeCalledTimes(1); }); test('Clicking on "Save" should call onChange and onClose', async () => { const props = createProps(); render(<AdhocMetricEditPopover {...props} />); expect(props.onChange).toBeCalledTimes(0); expect(props.onClose).toBeCalledTimes(0); userEvent.click( screen.getByRole('combobox', { name: 'Select saved metrics', }), ); const sumOption = await waitFor(() => within(document.querySelector('.rc-virtual-list')!).getByText('sum'), ); userEvent.click(sumOption); userEvent.click(screen.getByRole('button', { name: 'Save' })); expect(props.onChange).toBeCalledTimes(1); expect(props.onClose).toBeCalledTimes(1); }); test('Clicking on "Save" should not call onChange and onClose', () => { const props = createProps(); render(<AdhocMetricEditPopover {...props} />); expect(props.onChange).toBeCalledTimes(0); expect(props.onClose).toBeCalledTimes(0); userEvent.click(screen.getByRole('button', { name: 'Save' })); expect(props.onChange).toBeCalledTimes(0); expect(props.onClose).toBeCalledTimes(0); }); test('Clicking on "Save" should call onChange and onClose for new metric', () => { const props = createProps(); render(<AdhocMetricEditPopover {...props} isNewMetric />); expect(props.onChange).toBeCalledTimes(0); expect(props.onClose).toBeCalledTimes(0); userEvent.click(screen.getByRole('button', { name: 'Save' })); expect(props.onChange).toBeCalledTimes(1); expect(props.onClose).toBeCalledTimes(1); }); test('Clicking on "Save" should call onChange and onClose for new title', () => { const props = createProps(); render(<AdhocMetricEditPopover {...props} isLabelModified />); expect(props.onChange).toBeCalledTimes(0); expect(props.onClose).toBeCalledTimes(0); userEvent.click(screen.getByRole('button', { name: 'Save' })); expect(props.onChange).toBeCalledTimes(1); expect(props.onClose).toBeCalledTimes(1); }); test('Should switch to tab:Simple', () => { const props = createProps(); props.getCurrentTab.mockImplementation(tab => { props.adhocMetric.expressionType = tab; }); render(<AdhocMetricEditPopover {...props} />); expect(screen.getByRole('tabpanel', { name: 'Saved' })).toBeVisible(); expect( screen.queryByRole('tabpanel', { name: 'Simple' }), ).not.toBeInTheDocument(); expect(props.getCurrentTab).toBeCalledTimes(1); const tab = screen.getByRole('tab', { name: 'Simple' }).parentElement!; userEvent.click(tab); expect(props.getCurrentTab).toBeCalledTimes(2); expect( screen.queryByRole('tabpanel', { name: 'Saved' }), ).not.toBeInTheDocument(); expect(screen.getByRole('tabpanel', { name: 'Simple' })).toBeInTheDocument(); }); test('Should render "Simple" tab correctly', () => { const props = createProps(); props.getCurrentTab.mockImplementation(tab => { props.adhocMetric.expressionType = tab; }); render(<AdhocMetricEditPopover {...props} />); const tab = screen.getByRole('tab', { name: 'Simple' }).parentElement!; userEvent.click(tab); expect(screen.getByText('column')).toBeVisible(); expect(screen.getByText('aggregate')).toBeVisible(); }); test('Should switch to tab:Custom SQL', () => { const props = createProps(); props.getCurrentTab.mockImplementation(tab => { props.adhocMetric.expressionType = tab; }); render(<AdhocMetricEditPopover {...props} />); expect(screen.getByRole('tabpanel', { name: 'Saved' })).toBeVisible(); expect( screen.queryByRole('tabpanel', { name: 'Custom SQL' }), ).not.toBeInTheDocument(); expect(props.getCurrentTab).toBeCalledTimes(1); const tab = screen.getByRole('tab', { name: 'Custom SQL' }).parentElement!; userEvent.click(tab); expect(props.getCurrentTab).toBeCalledTimes(2); expect( screen.queryByRole('tabpanel', { name: 'Saved' }), ).not.toBeInTheDocument(); expect( screen.getByRole('tabpanel', { name: 'Custom SQL' }), ).toBeInTheDocument(); }); test('Should render "Custom SQL" tab correctly', async () => { const props = createProps(); props.getCurrentTab.mockImplementation(tab => { props.adhocMetric.expressionType = tab; }); render(<AdhocMetricEditPopover {...props} />); const tab = screen.getByRole('tab', { name: 'Custom SQL' }).parentElement!; userEvent.click(tab); expect(await screen.findByRole('textbox')).toBeInTheDocument(); });
7,706
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/OptionControls/OptionControls.test.tsx
/** * 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 React from 'react'; import { render, screen, fireEvent, waitFor, } from 'spec/helpers/testing-library'; import { DndProvider } from 'react-dnd'; import { HTML5Backend } from 'react-dnd-html5-backend'; import { OptionControlLabel, DragContainer, OptionControlContainer, Label, CaretContainer, CloseContainer, HeaderContainer, LabelsContainer, DndLabelsContainer, AddControlLabel, AddIconButton, } from 'src/explore/components/controls/OptionControls'; const defaultProps = { label: <span>Test label</span>, tooltipTitle: 'This is a tooltip title', onRemove: jest.fn(), onMoveLabel: jest.fn(), onDropLabel: jest.fn(), type: 'test', index: 0, }; const setup = (overrides?: Record<string, any>) => render( <DndProvider backend={HTML5Backend}> <OptionControlLabel {...defaultProps} {...overrides} /> </DndProvider>, ); test('should render', async () => { const { container } = setup(); await waitFor(() => expect(container).toBeVisible()); }); test('should display a label', async () => { setup(); expect(await screen.findByText('Test label')).toBeTruthy(); }); test('should display a certification icon if saved metric is certified', async () => { const { container } = setup({ savedMetric: { metric_name: 'test_metric', is_certified: true, }, }); await waitFor(() => { expect(screen.queryByText('Test label')).toBeFalsy(); expect(container.querySelector('.metric-option > svg')).toBeInTheDocument(); }); }); test('triggers onMoveLabel on drop', async () => { render( <DndProvider backend={HTML5Backend}> <OptionControlLabel {...defaultProps} index={1} label={<span>Label 1</span>} /> <OptionControlLabel {...defaultProps} index={2} label={<span>Label 2</span>} /> </DndProvider>, ); await waitFor(() => { fireEvent.dragStart(screen.getByText('Label 1')); fireEvent.drop(screen.getByText('Label 2')); expect(defaultProps.onMoveLabel).toHaveBeenCalled(); }); }); test('renders DragContainer', () => { const { container } = render(<DragContainer />); expect(container).toBeInTheDocument(); }); test('renders OptionControlContainer', () => { const { container } = render(<OptionControlContainer />); expect(container).toBeInTheDocument(); }); test('renders Label', () => { const { container } = render(<Label />); expect(container).toBeInTheDocument(); }); test('renders CaretContainer', () => { const { container } = render(<CaretContainer />); expect(container).toBeInTheDocument(); }); test('renders CloseContainer', () => { const { container } = render(<CloseContainer />); expect(container).toBeInTheDocument(); }); test('renders HeaderContainer', () => { const { container } = render(<HeaderContainer />); expect(container).toBeInTheDocument(); }); test('renders LabelsContainer', () => { const { container } = render(<LabelsContainer />); expect(container).toBeInTheDocument(); }); test('renders DndLabelsContainer', () => { const { container } = render(<DndLabelsContainer />); expect(container).toBeInTheDocument(); }); test('renders AddControlLabel', () => { const { container } = render(<AddControlLabel />); expect(container).toBeInTheDocument(); }); test('renders AddIconButton', () => { const { container } = render(<AddIconButton />); expect(container).toBeInTheDocument(); });
7,708
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/SelectAsyncControl/SelectAsyncControl.test.tsx
/** * 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 userEvent from '@testing-library/user-event'; import fetchMock from 'fetch-mock'; import React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import SelectAsyncControl from '.'; const datasetsOwnersEndpoint = 'glob:*/api/v1/dataset/related/owners*'; jest.mock('src/components/Select/Select', () => ({ __esModule: true, default: (props: any) => ( <div data-test="select-test" data-value={JSON.stringify(props.value)} data-placeholder={props.placeholder} data-multi={props.mode} > <button type="button" onClick={() => props.onChange(props.multi ? [] : {})} > onChange </button> <button type="button" onClick={() => props.mutator()}> mutator </button> </div> ), propertyComparator: jest.fn(), })); fetchMock.get(datasetsOwnersEndpoint, { result: [], }); const createProps = () => ({ ariaLabel: 'SelectAsyncControl', value: [], dataEndpoint: datasetsOwnersEndpoint, multi: true, placeholder: 'Select ...', onChange: jest.fn(), mutator: jest.fn(), }); beforeEach(() => { jest.resetAllMocks(); }); test('Should render', async () => { const props = createProps(); render(<SelectAsyncControl {...props} />, { useRedux: true }); expect(await screen.findByTestId('select-test')).toBeInTheDocument(); }); test('Should send correct props to Select component - value props', async () => { const props = createProps(); render(<SelectAsyncControl {...props} />, { useRedux: true }); expect(await screen.findByTestId('select-test')).toHaveAttribute( 'data-value', JSON.stringify(props.value), ); expect(screen.getByTestId('select-test')).toHaveAttribute( 'data-placeholder', props.placeholder, ); expect(screen.getByTestId('select-test')).toHaveAttribute( 'data-multi', 'multiple', ); }); test('Should send correct props to Select component - function onChange multi:true', async () => { const props = createProps(); render(<SelectAsyncControl {...props} />, { useRedux: true }); expect(props.onChange).toBeCalledTimes(0); userEvent.click(await screen.findByText('onChange')); expect(props.onChange).toBeCalledTimes(1); }); test('Should send correct props to Select component - function onChange multi:false', async () => { const props = createProps(); render(<SelectAsyncControl {...{ ...props, multi: false }} />, { useRedux: true, }); expect(props.onChange).toBeCalledTimes(0); userEvent.click(await screen.findByText('onChange')); expect(props.onChange).toBeCalledTimes(1); });
7,710
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/TextControl/TextControl.test.tsx
/** * 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 React from 'react'; import { fireEvent, render, screen } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import TextControl from '.'; const mockedProps = { disabled: false, isFloat: false, isInt: false, placeholder: 'Placeholder', value: 'Sample value', }; test('should render', () => { const { container } = render(<TextControl {...mockedProps} />); expect(container).toBeInTheDocument(); }); test('should render a textbox', () => { render(<TextControl {...mockedProps} />); expect(screen.getByRole('textbox')).toBeInTheDocument(); }); test('should render with initial value', () => { render(<TextControl {...mockedProps} />); expect(screen.getByDisplayValue('Sample value')).toBeInTheDocument(); }); test('should render with placeholder', () => { render(<TextControl {...mockedProps} />); expect(screen.getByPlaceholderText('Placeholder')).toBeInTheDocument(); }); test('should render as disabled', () => { const disabledProps = { ...mockedProps, disabled: true, }; render(<TextControl {...disabledProps} />); expect(screen.getByPlaceholderText('Placeholder')).toBeDisabled(); }); test('should focus', () => { const focusProps = { ...mockedProps, onFocus: jest.fn(), }; render(<TextControl {...focusProps} />); const input = screen.getByPlaceholderText('Placeholder'); fireEvent.focus(input); expect(focusProps.onFocus).toHaveBeenCalledTimes(1); }); test('should return errors when not a float', async () => { const changeProps = { ...mockedProps, isFloat: true, value: null, onChange: jest.fn(), }; render(<TextControl {...changeProps} />); const input = screen.getByPlaceholderText('Placeholder'); await userEvent.type(input, '!num', { delay: 500 }); expect(changeProps.onChange).toHaveBeenCalled(); expect(changeProps.onChange).toHaveBeenCalledWith('!', [ 'is expected to be a number', ]); }); test('should return errors when not an int', async () => { const changeProps = { ...mockedProps, isInt: true, value: null, onChange: jest.fn(), }; render(<TextControl {...changeProps} />); const input = screen.getByPlaceholderText('Placeholder'); await userEvent.type(input, '!int', { delay: 500 }); expect(changeProps.onChange).toHaveBeenCalled(); expect(changeProps.onChange).toHaveBeenCalledWith('!', [ 'is expected to be an integer', ]); });
7,712
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/TimeSeriesColumnControl/TimeSeriesColumnControl.test.tsx
/** * 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 React from 'react'; import { render, screen } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import TimeSeriesColumnControl from '.'; jest.mock('lodash/debounce', () => (fn: Function & { cancel: Function }) => { // eslint-disable-next-line no-param-reassign fn.cancel = jest.fn(); return fn; }); test('renders with default props', () => { render(<TimeSeriesColumnControl />); expect(screen.getByText('Time series columns')).toBeInTheDocument(); expect(screen.getByRole('button')).toBeInTheDocument(); }); test('renders popover on edit', () => { render(<TimeSeriesColumnControl />); userEvent.click(screen.getByRole('button')); expect(screen.getByRole('tooltip')).toBeInTheDocument(); expect(screen.getByText('Label')).toBeInTheDocument(); expect(screen.getByText('Tooltip')).toBeInTheDocument(); expect(screen.getByText('Type')).toBeInTheDocument(); }); test('renders time comparison', () => { render(<TimeSeriesColumnControl colType="time" />); userEvent.click(screen.getByRole('button')); expect(screen.getByText('Time lag')).toBeInTheDocument(); expect(screen.getAllByText('Type')[1]).toBeInTheDocument(); expect(screen.getByText('Color bounds')).toBeInTheDocument(); expect(screen.getByText('Number format')).toBeInTheDocument(); }); test('renders contribution', () => { render(<TimeSeriesColumnControl colType="contrib" />); userEvent.click(screen.getByRole('button')); expect(screen.getByText('Color bounds')).toBeInTheDocument(); expect(screen.getByText('Number format')).toBeInTheDocument(); }); test('renders sparkline', () => { render(<TimeSeriesColumnControl colType="spark" />); userEvent.click(screen.getByRole('button')); expect(screen.getByText('Width')).toBeInTheDocument(); expect(screen.getByText('Height')).toBeInTheDocument(); expect(screen.getByText('Time ratio')).toBeInTheDocument(); expect(screen.getByText('Show Y-axis')).toBeInTheDocument(); expect(screen.getByText('Y-axis bounds')).toBeInTheDocument(); expect(screen.getByText('Number format')).toBeInTheDocument(); expect(screen.getByText('Date format')).toBeInTheDocument(); }); test('renders period average', () => { render(<TimeSeriesColumnControl colType="avg" />); userEvent.click(screen.getByRole('button')); expect(screen.getByText('Time lag')).toBeInTheDocument(); expect(screen.getByText('Color bounds')).toBeInTheDocument(); expect(screen.getByText('Number format')).toBeInTheDocument(); }); test('triggers onChange when type changes', () => { const onChange = jest.fn(); render(<TimeSeriesColumnControl onChange={onChange} />); userEvent.click(screen.getByRole('button')); userEvent.click(screen.getByText('Select ...')); userEvent.click(screen.getByText('Time comparison')); expect(onChange).not.toHaveBeenCalled(); userEvent.click(screen.getByRole('button', { name: 'Save' })); expect(onChange).toHaveBeenCalledWith( expect.objectContaining({ colType: 'time' }), ); }); test('triggers onChange when time lag changes', () => { const timeLag = '1'; const onChange = jest.fn(); render(<TimeSeriesColumnControl colType="time" onChange={onChange} />); userEvent.click(screen.getByRole('button')); const timeLagInput = screen.getByPlaceholderText('Time Lag'); userEvent.clear(timeLagInput); userEvent.type(timeLagInput, timeLag); expect(onChange).not.toHaveBeenCalled(); userEvent.click(screen.getByRole('button', { name: 'Save' })); expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ timeLag })); }); test('triggers onChange when color bounds changes', () => { const min = 1; const max = 5; const onChange = jest.fn(); render(<TimeSeriesColumnControl colType="time" onChange={onChange} />); userEvent.click(screen.getByRole('button')); const minInput = screen.getByPlaceholderText('Min'); const maxInput = screen.getByPlaceholderText('Max'); userEvent.type(minInput, min.toString()); userEvent.type(maxInput, max.toString()); expect(onChange).not.toHaveBeenCalled(); userEvent.click(screen.getByRole('button', { name: 'Save' })); expect(onChange).toHaveBeenLastCalledWith( expect.objectContaining({ bounds: [min, max] }), ); }); test('triggers onChange when time type changes', () => { const onChange = jest.fn(); render(<TimeSeriesColumnControl colType="time" onChange={onChange} />); userEvent.click(screen.getByRole('button')); userEvent.click(screen.getByText('Select ...')); userEvent.click(screen.getByText('Difference')); expect(onChange).not.toHaveBeenCalled(); userEvent.click(screen.getByRole('button', { name: 'Save' })); expect(onChange).toHaveBeenCalledWith( expect.objectContaining({ comparisonType: 'diff' }), ); }); test('triggers onChange when number format changes', () => { const numberFormatString = 'Test format'; const onChange = jest.fn(); render(<TimeSeriesColumnControl colType="time" onChange={onChange} />); userEvent.click(screen.getByRole('button')); userEvent.type( screen.getByPlaceholderText('Number format string'), numberFormatString, ); expect(onChange).not.toHaveBeenCalled(); userEvent.click(screen.getByRole('button', { name: 'Save' })); expect(onChange).toHaveBeenCalledWith( expect.objectContaining({ d3format: numberFormatString }), ); }); test('triggers onChange when width changes', () => { const width = '10'; const onChange = jest.fn(); render(<TimeSeriesColumnControl colType="spark" onChange={onChange} />); userEvent.click(screen.getByRole('button')); userEvent.type(screen.getByPlaceholderText('Width'), width); expect(onChange).not.toHaveBeenCalled(); userEvent.click(screen.getByRole('button', { name: 'Save' })); expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ width })); }); test('triggers onChange when height changes', () => { const height = '10'; const onChange = jest.fn(); render(<TimeSeriesColumnControl colType="spark" onChange={onChange} />); userEvent.click(screen.getByRole('button')); userEvent.type(screen.getByPlaceholderText('Height'), height); expect(onChange).not.toHaveBeenCalled(); userEvent.click(screen.getByRole('button', { name: 'Save' })); expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ height })); }); test('triggers onChange when time ratio changes', () => { const timeRatio = '10'; const onChange = jest.fn(); render(<TimeSeriesColumnControl colType="spark" onChange={onChange} />); userEvent.click(screen.getByRole('button')); userEvent.type(screen.getByPlaceholderText('Time Ratio'), timeRatio); expect(onChange).not.toHaveBeenCalled(); userEvent.click(screen.getByRole('button', { name: 'Save' })); expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ timeRatio })); }); test('triggers onChange when show Y-axis changes', () => { const onChange = jest.fn(); render(<TimeSeriesColumnControl colType="spark" onChange={onChange} />); userEvent.click(screen.getByRole('button')); userEvent.click(screen.getByRole('checkbox')); expect(onChange).not.toHaveBeenCalled(); userEvent.click(screen.getByRole('button', { name: 'Save' })); expect(onChange).toHaveBeenCalledWith( expect.objectContaining({ showYAxis: true }), ); }); test('triggers onChange when Y-axis bounds changes', () => { const min = 1; const max = 5; const onChange = jest.fn(); render(<TimeSeriesColumnControl colType="spark" onChange={onChange} />); userEvent.click(screen.getByRole('button')); const minInput = screen.getByPlaceholderText('Min'); const maxInput = screen.getByPlaceholderText('Max'); userEvent.type(minInput, min.toString()); userEvent.clear(maxInput); userEvent.type(maxInput, max.toString()); expect(onChange).not.toHaveBeenCalled(); userEvent.click(screen.getByRole('button', { name: 'Save' })); expect(onChange).toHaveBeenCalledWith( expect.objectContaining({ yAxisBounds: [min, max] }), ); }); test('triggers onChange when date format changes', () => { const dateFormat = 'yy/MM/dd'; const onChange = jest.fn(); render(<TimeSeriesColumnControl colType="spark" onChange={onChange} />); userEvent.click(screen.getByRole('button')); userEvent.type(screen.getByPlaceholderText('Date format string'), dateFormat); expect(onChange).not.toHaveBeenCalled(); userEvent.click(screen.getByRole('button', { name: 'Save' })); expect(onChange).toHaveBeenCalledWith( expect.objectContaining({ dateFormat }), ); });
7,716
0
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls
petrpan-code/apache/superset/superset-frontend/src/explore/components/controls/VizTypeControl/VizTypeControl.test.tsx
/** * 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 { Preset } from '@superset-ui/core'; import { render, cleanup, screen, within, waitFor, } from 'spec/helpers/testing-library'; import { stateWithoutNativeFilters } from 'spec/fixtures/mockStore'; import React from 'react'; import userEvent from '@testing-library/user-event'; import { DynamicPluginProvider } from 'src/components/DynamicPlugins'; import { testWithId } from 'src/utils/testUtils'; import { BigNumberTotalChartPlugin, EchartsAreaChartPlugin, EchartsMixedTimeseriesChartPlugin, EchartsPieChartPlugin, EchartsTimeseriesBarChartPlugin, EchartsTimeseriesChartPlugin, EchartsTimeseriesLineChartPlugin, } from '@superset-ui/plugin-chart-echarts'; import TableChartPlugin from '@superset-ui/plugin-chart-table'; import TimeTableChartPlugin from 'src/visualizations/TimeTable'; import VizTypeControl, { VIZ_TYPE_CONTROL_TEST_ID } from './index'; jest.useFakeTimers(); class MainPreset extends Preset { constructor() { super({ name: 'Legacy charts', plugins: [ new TableChartPlugin().configure({ key: 'table' }), new BigNumberTotalChartPlugin().configure({ key: 'big_number_total' }), new EchartsTimeseriesLineChartPlugin().configure({ key: 'echarts_timeseries_line', }), new EchartsAreaChartPlugin().configure({ key: 'echarts_area', }), new EchartsTimeseriesBarChartPlugin().configure({ key: 'echarts_timeseries_bar', }), new EchartsPieChartPlugin().configure({ key: 'pie' }), new EchartsTimeseriesChartPlugin().configure({ key: 'echarts_timeseries', }), new TimeTableChartPlugin().configure({ key: 'time_table' }), new EchartsMixedTimeseriesChartPlugin().configure({ key: 'mixed_timeseries', }), ], }); } } const getTestId = testWithId<string>(VIZ_TYPE_CONTROL_TEST_ID, true); /** * AntD and/or the Icon component seems to be doing some kind of async changes, * so even though the test passes, there is a warning an update to Icon was not * wrapped in act(). This sufficiently act-ifies whatever side effects are going * on and prevents those warnings. */ describe('VizTypeControl', () => { new MainPreset().register(); const defaultProps = { description: '', label: '', name: '', value: '', labelType: 'primary', onChange: jest.fn(), isModalOpenInit: true, }; const waitForRenderWrapper = ( props: typeof defaultProps = defaultProps, state: object = stateWithoutNativeFilters, ) => waitFor(() => { render( <DynamicPluginProvider> <VizTypeControl {...props} /> </DynamicPluginProvider>, { useRedux: true, initialState: state }, ); }); afterEach(() => { cleanup(); jest.clearAllMocks(); }); it('Fast viz switcher tiles render', async () => { const props = { ...defaultProps, value: 'echarts_timeseries_line', isModalOpenInit: false, }; await waitForRenderWrapper(props); expect(screen.getByLabelText('table-chart-tile')).toBeVisible(); expect(screen.getByLabelText('big-number-chart-tile')).toBeVisible(); expect(screen.getByLabelText('pie-chart-tile')).toBeVisible(); expect(screen.getByLabelText('bar-chart-tile')).toBeVisible(); expect(screen.getByLabelText('area-chart-tile')).toBeVisible(); expect(screen.queryByLabelText('monitor')).not.toBeInTheDocument(); expect(screen.queryByLabelText('check-square')).not.toBeInTheDocument(); expect( within(screen.getByTestId('fast-viz-switcher')).getByText( 'Time-series Line Chart', ), ).toBeInTheDocument(); expect( within(screen.getByTestId('fast-viz-switcher')).getByText('Table'), ).toBeInTheDocument(); expect( within(screen.getByTestId('fast-viz-switcher')).getByText('Big Number'), ).toBeInTheDocument(); expect( within(screen.getByTestId('fast-viz-switcher')).getByText('Pie Chart'), ).toBeInTheDocument(); expect( within(screen.getByTestId('fast-viz-switcher')).getByText( 'Time-series Bar Chart', ), ).toBeInTheDocument(); expect( within(screen.getByTestId('fast-viz-switcher')).getByText( 'Time-series Area Chart', ), ).toBeInTheDocument(); }); it('Render viz tiles when non-featured chart is selected', async () => { const props = { ...defaultProps, value: 'line', isModalOpenInit: false, }; await waitForRenderWrapper(props); expect(screen.getByLabelText('monitor')).toBeVisible(); expect( within(screen.getByTestId('fast-viz-switcher')).getByText( 'Time-series Line Chart', ), ).toBeVisible(); }); it('Render viz tiles when non-featured is rendered', async () => { const props = { ...defaultProps, value: 'line', isModalOpenInit: false, }; const state = { charts: { 1: { latestQueryFormData: { viz_type: 'line', }, }, }, explore: { slice: { slice_id: 1, }, }, }; await waitForRenderWrapper(props, state); expect(screen.getByLabelText('check-square')).toBeVisible(); expect( within(screen.getByTestId('fast-viz-switcher')).getByText( 'Time-series Line Chart', ), ).toBeVisible(); }); it('Change viz type on click', async () => { const props = { ...defaultProps, value: 'echarts_timeseries_line', isModalOpenInit: false, }; await waitForRenderWrapper(props); userEvent.click( within(screen.getByTestId('fast-viz-switcher')).getByText( 'Time-series Line Chart', ), ); expect(props.onChange).not.toHaveBeenCalled(); userEvent.click( within(screen.getByTestId('fast-viz-switcher')).getByText('Table'), ); expect(props.onChange).toHaveBeenCalledWith('table'); }); it('Open viz gallery modal on "View all charts" click', async () => { await waitForRenderWrapper({ ...defaultProps, isModalOpenInit: false }); expect( screen.queryByText('Select a visualization type'), ).not.toBeInTheDocument(); userEvent.click(screen.getByText('View all charts')); expect( await screen.findByText('Select a visualization type'), ).toBeVisible(); }); it('Search visualization type', async () => { await waitForRenderWrapper(); const visualizations = screen.getByTestId(getTestId('viz-row')); userEvent.click(screen.getByRole('button', { name: 'ballot All charts' })); expect( await within(visualizations).findByText('Time-series Line Chart'), ).toBeVisible(); // search userEvent.type( screen.getByTestId(getTestId('search-input')), 'time series', ); expect( await within(visualizations).findByText('Time-series Table'), ).toBeVisible(); expect(within(visualizations).getByText('Time-series Chart')).toBeVisible(); expect(within(visualizations).getByText('Mixed Time-Series')).toBeVisible(); expect( within(visualizations).getByText('Time-series Area Chart'), ).toBeVisible(); expect( within(visualizations).getByText('Time-series Line Chart'), ).toBeVisible(); expect( within(visualizations).getByText('Time-series Bar Chart'), ).toBeVisible(); expect(within(visualizations).queryByText('Table')).not.toBeInTheDocument(); expect( within(visualizations).queryByText('Big Number'), ).not.toBeInTheDocument(); expect( within(visualizations).queryByText('Pie Chart'), ).not.toBeInTheDocument(); }); it('Submit on viz type double-click', async () => { await waitForRenderWrapper(); userEvent.click(screen.getByRole('button', { name: 'ballot All charts' })); const visualizations = screen.getByTestId(getTestId('viz-row')); userEvent.click(within(visualizations).getByText('Time-series Bar Chart')); expect(defaultProps.onChange).not.toBeCalled(); userEvent.dblClick( within(visualizations).getByText('Time-series Line Chart'), ); expect(defaultProps.onChange).toHaveBeenCalledWith( 'echarts_timeseries_line', ); }); });
7,719
0
petrpan-code/apache/superset/superset-frontend/src/explore/components
petrpan-code/apache/superset/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/DashboardsSubMenu.test.tsx
/** * 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 React from 'react'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import { Menu } from 'src/components/Menu'; import DashboardItems from './DashboardsSubMenu'; const asyncRender = (numberOfItems: number) => waitFor(() => { const dashboards = []; for (let i = 1; i <= numberOfItems; i += 1) { dashboards.push({ id: i, dashboard_title: `Dashboard ${i}` }); } render( <Menu openKeys={['menu']}> <Menu.SubMenu title="Dashboards added to" key="menu"> <DashboardItems key="menu" dashboards={dashboards} /> </Menu.SubMenu> </Menu>, { useRouter: true, }, ); }); test('renders a submenu', async () => { await asyncRender(3); expect(screen.getByText('Dashboard 1')).toBeInTheDocument(); expect(screen.getByText('Dashboard 2')).toBeInTheDocument(); expect(screen.getByText('Dashboard 3')).toBeInTheDocument(); }); test('renders a submenu with search', async () => { await asyncRender(20); expect(screen.getByPlaceholderText('Search')).toBeInTheDocument(); }); test('displays a searched value', async () => { await asyncRender(20); userEvent.type(screen.getByPlaceholderText('Search'), '2'); expect(screen.getByText('Dashboard 2')).toBeInTheDocument(); expect(screen.getByText('Dashboard 20')).toBeInTheDocument(); }); test('renders a "No results found" message when searching', async () => { await asyncRender(20); userEvent.type(screen.getByPlaceholderText('Search'), 'unknown'); expect(screen.getByText('No results found')).toBeInTheDocument(); }); test('renders a submenu with no dashboards', async () => { await asyncRender(0); expect(screen.getByText('None')).toBeInTheDocument(); }); test('shows link icon when hovering', async () => { await asyncRender(3); expect(screen.queryByRole('img', { name: 'full' })).not.toBeInTheDocument(); userEvent.hover(screen.getByText('Dashboard 1')); expect(screen.getByRole('img', { name: 'full' })).toBeInTheDocument(); });
7,725
0
petrpan-code/apache/superset/superset-frontend/src/explore
petrpan-code/apache/superset/superset-frontend/src/explore/controlUtils/controlUtils.test.tsx
/** * 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 { DatasourceType, getChartControlPanelRegistry, t, } from '@superset-ui/core'; import { ControlConfig, ControlPanelState, CustomControlItem, } from '@superset-ui/chart-controls'; import { getControlConfig, getControlState, applyMapStateToPropsToControl, findControlItem, } from 'src/explore/controlUtils'; import { controlPanelSectionsChartOptions, controlPanelSectionsChartOptionsOnlyColorScheme, controlPanelSectionsChartOptionsTable, } from 'src/explore/fixtures'; const getKnownControlConfig = (controlKey: string, vizType: string) => getControlConfig(controlKey, vizType) as ControlConfig; const getKnownControlState = (...args: Parameters<typeof getControlState>) => getControlState(...args) as Exclude<ReturnType<typeof getControlState>, null>; describe('controlUtils', () => { const state: ControlPanelState = { datasource: { id: 1, type: DatasourceType.Table, columns: [{ column_name: 'a' }], metrics: [{ metric_name: 'first' }, { metric_name: 'second' }], column_formats: {}, currency_formats: {}, verbose_map: {}, main_dttm_col: '', datasource_name: '1__table', description: null, }, controls: {}, form_data: { datasource: '1__table', viz_type: 'table' }, common: {}, }; beforeAll(() => { getChartControlPanelRegistry() .registerValue('test-chart', { controlPanelSections: controlPanelSectionsChartOptions, }) .registerValue('test-chart-override', { controlPanelSections: controlPanelSectionsChartOptionsOnlyColorScheme, controlOverrides: { color_scheme: { label: t('My beautiful colors'), }, }, }) .registerValue('table', { controlPanelSections: controlPanelSectionsChartOptionsTable, }); }); afterAll(() => { getChartControlPanelRegistry() .remove('test-chart') .remove('test-chart-override'); }); describe('getControlConfig', () => { it('returns a valid spatial controlConfig', () => { const spatialControl = getControlConfig('color_scheme', 'test-chart'); expect(spatialControl?.type).toEqual('ColorSchemeControl'); }); it('overrides according to vizType', () => { let control = getKnownControlConfig('color_scheme', 'test-chart'); expect(control.label).toEqual('Color Scheme'); control = getKnownControlConfig('color_scheme', 'test-chart-override'); expect(control.label).toEqual('My beautiful colors'); }); it( 'returns correct control config when control config is defined ' + 'in the control panel definition', () => { const roseAreaProportionControlConfig = getControlConfig( 'rose_area_proportion', 'test-chart', ); expect(roseAreaProportionControlConfig).toEqual({ type: 'CheckboxControl', label: t('Use Area Proportions'), description: t( 'Check if the Rose Chart should use segment area instead of ' + 'segment radius for proportioning', ), default: false, renderTrigger: true, }); }, ); }); describe('applyMapStateToPropsToControl,', () => { it('applies state to props as expected', () => { let control = getKnownControlConfig('all_columns', 'table'); control = applyMapStateToPropsToControl(control, state); expect(control.options).toEqual([{ column_name: 'a' }]); }); }); describe('getControlState', () => { it('to still have the functions', () => { const control = getKnownControlState('metrics', 'table', state, 'a'); expect(typeof control.mapStateToProps).toBe('function'); expect(typeof control.validators?.[0]).toBe('function'); }); it('to make sure value is array', () => { const control = getKnownControlState('all_columns', 'table', state, 'a'); expect(control.value).toEqual(['a']); }); it('removes missing/invalid choice', () => { let control = getControlState( 'stacked_style', 'test-chart', state, 'stack', ); expect(control?.value).toBe('stack'); control = getControlState('stacked_style', 'test-chart', state, 'FOO'); expect(control?.value).toBeNull(); }); it('returns null for non-existent field', () => { const control = getControlState('NON_EXISTENT', 'table', state); expect(control).toBeNull(); }); it('metrics control should be empty by default', () => { const control = getControlState('metrics', 'table', state); expect(control?.default).toBeUndefined(); }); it('metric control should be empty by default', () => { const control = getControlState('metric', 'table', state); expect(control?.default).toBeUndefined(); }); it('should not apply mapStateToProps when initializing', () => { const control = getControlState('metrics', 'table', { ...state, controls: undefined, }); expect(control?.value).toBe(undefined); }); }); describe('validateControl', () => { it('validates the control, returns an error if empty', () => { const control = getControlState('metric', 'table', state, null); expect(control?.validationErrors).toEqual(['cannot be empty']); }); it('should not validate if control panel is initializing', () => { const control = getControlState( 'metric', 'table', { ...state, controls: undefined }, undefined, ); expect(control?.validationErrors).toBeUndefined(); }); }); describe('findControlItem', () => { it('find control as a string', () => { const controlItem = findControlItem( controlPanelSectionsChartOptions, 'color_scheme', ); expect(controlItem).toEqual('color_scheme'); }); it('find control as a control object', () => { let controlItem = findControlItem( controlPanelSectionsChartOptions, 'rose_area_proportion', ) as CustomControlItem; expect(controlItem.name).toEqual('rose_area_proportion'); expect(controlItem).toHaveProperty('config'); controlItem = findControlItem( controlPanelSectionsChartOptions, 'stacked_style', ) as CustomControlItem; expect(controlItem.name).toEqual('stacked_style'); expect(controlItem).toHaveProperty('config'); }); it('returns null when key is not found', () => { const controlItem = findControlItem( controlPanelSectionsChartOptions, 'non_existing_key', ); expect(controlItem).toBeNull(); }); }); });
7,728
0
petrpan-code/apache/superset/superset-frontend/src/explore
petrpan-code/apache/superset/superset-frontend/src/explore/controlUtils/getControlValuesCompatibleWithDatasource.test.ts
/** * 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 { ControlState, Dataset, sharedControls, } from '@superset-ui/chart-controls'; import { DatasourceType, JsonValue } from '@superset-ui/core'; import { getControlValuesCompatibleWithDatasource } from './getControlValuesCompatibleWithDatasource'; const sampleDatasource: Dataset = { id: 1, type: DatasourceType.Table, columns: [ { column_name: 'sample_column_1' }, { column_name: 'sample_column_3' }, { column_name: 'sample_column_4' }, ], metrics: [{ metric_name: 'saved_metric_2' }], column_formats: {}, currency_formats: {}, verbose_map: {}, main_dttm_col: '', datasource_name: 'Sample Dataset', description: 'A sample dataset', }; const getValues = (controlState: ControlState) => { const { value } = controlState; return getControlValuesCompatibleWithDatasource( sampleDatasource, controlState, value as JsonValue, ); }; test('empty values', () => { const controlState = sharedControls.groupby; expect( getValues({ ...controlState, value: undefined, }), ).toEqual(undefined); expect( getValues({ ...controlState, value: null, }), ).toEqual(undefined); expect( getValues({ ...controlState, value: [], }), ).toEqual(controlState.default); }); test('column values', () => { const controlState = { ...sharedControls.columns, options: [ { column_name: 'sample_column_1' }, { column_name: 'sample_column_2' }, { column_name: 'sample_column_3' }, ], }; expect( getValues({ ...controlState, value: 'sample_column_1', }), ).toEqual('sample_column_1'); expect( getValues({ ...controlState, value: 'sample_column_2', }), ).toEqual(controlState.default); expect( getValues({ ...controlState, value: 'sample_column_3', }), ).toEqual('sample_column_3'); expect( getValues({ ...controlState, value: ['sample_column_1', 'sample_column_2', 'sample_column_3'], }), ).toEqual(['sample_column_1', 'sample_column_3']); }); test('saved metric values', () => { const controlState = { ...sharedControls.metrics, savedMetrics: [ { metric_name: 'saved_metric_1' }, { metric_name: 'saved_metric_2' }, ], }; expect( getValues({ ...controlState, value: 'saved_metric_1', }), ).toEqual(controlState.default); expect( getValues({ ...controlState, value: 'saved_metric_2', }), ).toEqual('saved_metric_2'); expect( getValues({ ...controlState, value: ['saved_metric_1', 'saved_metric_2'], }), ).toEqual(['saved_metric_2']); }); test('simple ad-hoc metric values', () => { const controlState = { ...sharedControls.metrics, columns: [ { column_name: 'sample_column_1' }, { column_name: 'sample_column_2' }, { column_name: 'sample_column_3' }, ], }; expect( getValues({ ...controlState, value: { expressionType: 'SIMPLE', column: { column_name: 'sample_column_1' }, }, }), ).toEqual({ expressionType: 'SIMPLE', column: { column_name: 'sample_column_1' }, }); expect( getValues({ ...controlState, value: { expressionType: 'SIMPLE', column: { column_name: 'sample_column_2' }, }, }), ).toEqual(controlState.default); expect( getValues({ ...controlState, value: [ { expressionType: 'SIMPLE', column: { column_name: 'sample_column_1' }, }, { expressionType: 'SIMPLE', column: { column_name: 'sample_column_2' }, }, ], }), ).toEqual([ { expressionType: 'SIMPLE', column: { column_name: 'sample_column_1' } }, ]); }); test('SQL ad-hoc metric values', () => { const controlState = { ...sharedControls.metrics, }; expect( getValues({ ...controlState, value: { expressionType: 'SQL', sqlExpression: 'select * from sample_column_1;', }, }), ).toEqual({ datasourceWarning: true, expressionType: 'SQL', sqlExpression: 'select * from sample_column_1;', }); }); test('simple ad-hoc filter values', () => { const controlState = { ...sharedControls.adhoc_filters, columns: [ { column_name: 'sample_column_1' }, { column_name: 'sample_column_2' }, { column_name: 'sample_column_3' }, ], }; expect( getValues({ ...controlState, value: { expressionType: 'SIMPLE', subject: 'sample_column_1', }, }), ).toEqual({ expressionType: 'SIMPLE', subject: 'sample_column_1', }); expect( getValues({ ...controlState, value: { expressionType: 'SIMPLE', subject: 'sample_column_2', }, }), ).toEqual(controlState.default); expect( getValues({ ...controlState, value: [ { expressionType: 'SIMPLE', subject: 'sample_column_1', }, { expressionType: 'SIMPLE', subject: 'sample_column_2', }, ], }), ).toEqual([{ expressionType: 'SIMPLE', subject: 'sample_column_1' }]); }); test('SQL ad-hoc filter values', () => { const controlState = { ...sharedControls.adhoc_filters, }; expect( getValues({ ...controlState, value: { expressionType: 'SQL', sqlExpression: 'select * from sample_column_1;', }, }), ).toEqual({ datasourceWarning: true, expressionType: 'SQL', sqlExpression: 'select * from sample_column_1;', }); });
7,731
0
petrpan-code/apache/superset/superset-frontend/src/explore
petrpan-code/apache/superset/superset-frontend/src/explore/controlUtils/getFormDataFromDashboardContext.test.ts
/** * 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 { JsonObject } from '@superset-ui/core'; import { getExploreFormData } from 'spec/fixtures/mockExploreFormData'; import { getDashboardFormData } from 'spec/fixtures/mockDashboardFormData'; import { getFormDataWithDashboardContext } from './getFormDataWithDashboardContext'; const getExpectedResultFormData = (overrides: JsonObject = {}) => ({ adhoc_filters: [ { clause: 'WHERE', expressionType: 'SIMPLE', operator: 'IN', subject: 'gender', comparator: ['boys'], filterOptionName: '123', }, { clause: 'WHERE' as const, expressionType: 'SQL' as const, operator: null, subject: null, comparator: null, sqlExpression: "name = 'John'", filterOptionName: '456', }, { clause: 'WHERE' as const, expressionType: 'SQL' as const, operator: null, subject: null, comparator: null, sqlExpression: "city = 'Warsaw'", filterOptionName: '567', }, { clause: 'WHERE', expressionType: 'SIMPLE', operator: 'TEMPORAL_RANGE', subject: 'ds', comparator: 'Last month', filterOptionName: expect.any(String), isExtra: true, }, { clause: 'WHERE', expressionType: 'SIMPLE', operator: 'IN', operatorId: 'IN', subject: 'name', comparator: ['Aaron'], isExtra: true, filterOptionName: expect.any(String), }, { clause: 'WHERE', expressionType: 'SIMPLE', operator: '<=', operatorId: 'LESS_THAN_OR_EQUAL', subject: 'num_boys', comparator: 10000, isExtra: true, filterOptionName: expect.any(String), }, { clause: 'WHERE', expressionType: 'SQL', sqlExpression: `(totally viable sql expression) IN ('Value1', 'Value2')`, filterOptionName: expect.any(String), isExtra: true, }, ], adhoc_filters_b: [ { clause: 'WHERE' as const, expressionType: 'SQL' as const, operator: null, subject: null, comparator: null, sqlExpression: "country = 'Poland'", filterOptionName: expect.any(String), }, { clause: 'WHERE', expressionType: 'SIMPLE', operator: 'IN', operatorId: 'IN', subject: 'name', comparator: ['Aaron'], isExtra: true, filterOptionName: expect.any(String), }, { clause: 'WHERE', expressionType: 'SIMPLE', operator: '<=', operatorId: 'LESS_THAN_OR_EQUAL', subject: 'num_boys', comparator: 10000, isExtra: true, filterOptionName: expect.any(String), }, { clause: 'WHERE', expressionType: 'SQL', sqlExpression: `(totally viable sql expression) IN ('Value1', 'Value2')`, filterOptionName: expect.any(String), isExtra: true, }, ], applied_time_extras: { __time_grain: 'P1D', __time_col: 'ds', }, color_scheme: 'd3Category20b', datasource: '2__table', granularity_sqla: 'ds', groupby: ['gender'], metric: { aggregate: 'SUM', column: { column_name: 'num', type: 'BIGINT', }, expressionType: 'SIMPLE', label: 'Births', }, slice_id: 46, time_range: 'Last month', viz_type: 'pie', label_colors: { Girls: '#FF69B4', Boys: '#ADD8E6', girl: '#FF69B4', boy: '#ADD8E6', }, shared_label_colors: { boy: '#ADD8E6', girl: '#FF69B4', }, extra_filters: [ { col: '__time_range', op: '==', val: 'No filter', }, { col: '__time_grain', op: '==', val: 'P1D', }, { col: '__time_col', op: '==', val: 'ds', }, ], extra_form_data: { filters: [ { col: 'name', op: 'IN', val: ['Aaron'], }, { col: 'num_boys', op: '<=', val: 10000, }, { col: { expressionType: 'SQL', label: 'My column', sqlExpression: 'totally viable sql expression', }, op: 'IN', val: ['Value1', 'Value2'], }, ], granularity_sqla: 'ds', time_range: 'Last month', time_grain_sqla: 'PT1S', }, dashboardId: 2, time_grain_sqla: 'PT1S', granularity: 'ds', extras: { time_grain_sqla: 'PT1S', }, ...overrides, }); test('merges dashboard context form data with explore form data', () => { const fullFormData = getFormDataWithDashboardContext( getExploreFormData(), getDashboardFormData(), ); expect(fullFormData).toEqual(getExpectedResultFormData()); });
7,735
0
petrpan-code/apache/superset/superset-frontend/src/explore
petrpan-code/apache/superset/superset-frontend/src/explore/controlUtils/standardizedFormData.test.ts
/** * 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 { AdhocColumn, AdhocMetricSimple, AdhocMetricSQL, getChartControlPanelRegistry, QueryFormData, TimeGranularity, } from '@superset-ui/core'; import TableChartPlugin from '@superset-ui/plugin-chart-table'; import { BigNumberTotalChartPlugin } from '@superset-ui/plugin-chart-echarts'; import { sections } from '@superset-ui/chart-controls'; import { StandardizedFormData, sharedMetricsKey, sharedColumnsKey, publicControls, } from './standardizedFormData'; const adhocColumn: AdhocColumn = { expressionType: 'SQL', label: 'country', optionName: 'country', sqlExpression: 'country', }; const adhocMetricSQL: AdhocMetricSQL = { expressionType: 'SQL', label: 'count', optionName: 'count', sqlExpression: 'count(*)', }; const adhocMetricSimple: AdhocMetricSimple = { expressionType: 'SIMPLE', column: { id: 1, column_name: 'sales', columnName: 'sales', verbose_name: 'sales', }, aggregate: 'SUM', label: 'count', optionName: 'count', }; const tableVizFormData = { datasource: '30__table', viz_type: 'table', granularity_sqla: 'ds', time_grain_sqla: TimeGranularity.DAY, time_range: 'No filter', query_mode: 'aggregate', groupby: ['name', 'gender', adhocColumn], metrics: ['count', 'avg(sales)', adhocMetricSimple, adhocMetricSQL], all_columns: [], percent_metrics: [], adhoc_filters: [], order_by_cols: [], row_limit: 10000, server_page_length: 10, order_desc: true, table_timestamp_format: 'smart_date', show_cell_bars: true, color_pn: true, url_params: { form_data_key: 'p3No_sqDW7k-kMTzlBPAPd9vwp1IXTf6stbyzjlrPPa0ninvdYUUiMC6F1iKit3Y', dataset_id: '30', }, }; const tableVizStore = { form_data: tableVizFormData, controls: { datasource: { value: '30__table', }, viz_type: { value: 'table', }, slice_id: {}, cache_timeout: {}, url_params: { value: { form_data_key: 'p3No_sqDW7k-kMTzlBPAPd9vwp1IXTf6stbyzjlrPPa0ninvdYUUiMC6F1iKit3Y', dataset_id: '30', }, }, granularity_sqla: { value: 'ds', }, time_grain_sqla: { value: 'P1D', }, time_range: { value: 'No filter', }, query_mode: { value: 'aggregate', }, groupby: { value: ['name', 'gender', adhocColumn], }, metrics: { value: ['count', 'avg(sales)', adhocMetricSimple, adhocMetricSQL], }, all_columns: { value: [], }, percent_metrics: { value: [], }, adhoc_filters: { value: [], }, timeseries_limit_metric: {}, order_by_cols: { value: [], }, server_pagination: {}, row_limit: { value: 10000, }, server_page_length: { value: 10, }, include_time: {}, order_desc: { value: true, }, show_totals: {}, table_timestamp_format: { value: 'smart_date', }, page_length: {}, include_search: {}, show_cell_bars: { value: true, }, align_pn: {}, color_pn: { value: true, }, column_config: {}, conditional_formatting: {}, }, datasource: { type: 'table', columns: [], }, }; describe('should collect control values and create SFD', () => { const sharedKey = [...sharedMetricsKey, ...sharedColumnsKey]; const sharedControlsFormData = { // metrics metric: 'm1', metrics: ['m2'], metric_2: 'm3', size: 'm4', x: 'm5', y: 'm6', secondary_metric: 'm7', // columns groupby: ['c1'], columns: ['c2'], groupbyColumns: ['c3'], groupbyRows: ['c4'], series: 'c5', entity: 'c6', series_columns: ['c7'], }; const publicControlsFormData = { // time section granularity_sqla: 'time_column', time_grain_sqla: TimeGranularity.DAY, time_range: '2000 : today', // filters adhoc_filters: [], // subquery limit(series limit) limit: 5, // order by clause timeseries_limit_metric: 'orderby_metric', series_limit_metric: 'orderby_metric', // desc or asc in order by clause order_desc: true, // outer query limit row_limit: 100, // x asxs column x_axis: 'x_axis_column', // advanced analytics - rolling window rolling_type: 'sum', rolling_periods: 1, min_periods: 0, // advanced analytics - time comparison time_compare: '1 year ago', comparison_type: 'values', // advanced analytics - resample resample_rule: '1D', resample_method: 'zerofill', }; const sourceMockFormData: QueryFormData = { ...sharedControlsFormData, ...publicControlsFormData, datasource: '100__table', viz_type: 'source_viz', }; const sourceMockStore = { form_data: sourceMockFormData, controls: Object.fromEntries( Object.entries(sourceMockFormData).map(([key, value]) => [ key, { value }, ]), ), datasource: { type: 'table', columns: [], }, }; beforeAll(() => { getChartControlPanelRegistry().registerValue('source_viz', { controlPanelSections: [ sections.advancedAnalyticsControls, { label: 'transform controls', controlSetRows: publicControls.map(control => [control]), }, { label: 'axis column', controlSetRows: [['x_axis']], }, ], }); getChartControlPanelRegistry().registerValue('target_viz', { controlPanelSections: [ sections.advancedAnalyticsControls, { label: 'transform controls', controlSetRows: publicControls.map(control => [control]), }, { label: 'axis column', controlSetRows: [['x_axis']], }, ], formDataOverrides: (formData: QueryFormData) => ({ ...formData, columns: formData.standardizedFormData.controls.columns, metrics: formData.standardizedFormData.controls.metrics, }), }); }); test('should avoid to overlap', () => { const sharedControlsSet = new Set(Object.keys(sharedKey)); const publicControlsSet = new Set(publicControls); expect( [...sharedControlsSet].filter((x: string) => publicControlsSet.has(x)), ).toEqual([]); }); test('should collect all sharedControls', () => { expect(Object.entries(sharedControlsFormData).length).toBe( Object.entries(sharedKey).length, ); const sfd = new StandardizedFormData(sourceMockFormData); expect(sfd.serialize().controls.metrics).toEqual([ 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', ]); expect(sfd.serialize().controls.columns).toEqual([ 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', ]); }); test('should transform all publicControls and sharedControls', () => { expect(Object.entries(publicControlsFormData).length).toBe( publicControls.length, ); const sfd = new StandardizedFormData(sourceMockFormData); const { formData } = sfd.transform('target_viz', sourceMockStore); Object.entries(publicControlsFormData).forEach(([key, value]) => { expect(formData).toHaveProperty(key); expect(value).toEqual(publicControlsFormData[key]); }); expect(formData.columns).toEqual([ 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', ]); expect(formData.metrics).toEqual([ 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', ]); }); test('should inherit standardizedFormData and memorizedFormData is LIFO', () => { // from source_viz to target_viz const sfd = new StandardizedFormData(sourceMockFormData); const { formData, controlsState } = sfd.transform( 'target_viz', sourceMockStore, ); expect( formData.standardizedFormData.memorizedFormData.map( (fd: [string, QueryFormData]) => fd[0], ), ).toEqual(['source_viz']); // from target_viz to source_viz const sfd2 = new StandardizedFormData(formData); const { formData: fd2, controlsState: cs2 } = sfd2.transform('source_viz', { ...sourceMockStore, form_data: formData, controls: controlsState, }); expect( fd2.standardizedFormData.memorizedFormData.map( (fd: [string, QueryFormData]) => fd[0], ), ).toEqual(['source_viz', 'target_viz']); // from source_viz to target_viz const sfd3 = new StandardizedFormData(fd2); const { formData: fd3 } = sfd3.transform('target_viz', { ...sourceMockStore, form_data: fd2, controls: cs2, }); expect( fd3.standardizedFormData.memorizedFormData.map( (fd: [string, QueryFormData]) => fd[0], ), ).toEqual(['target_viz', 'source_viz']); }); }); describe('should transform form_data between table and bigNumberTotal', () => { beforeAll(() => { getChartControlPanelRegistry().registerValue( 'big_number_total', new BigNumberTotalChartPlugin().controlPanel, ); getChartControlPanelRegistry().registerValue( 'table', new TableChartPlugin().controlPanel, ); }); test('get and has', () => { // table -> bigNumberTotal const sfd = new StandardizedFormData(tableVizFormData); const { formData: bntFormData } = sfd.transform( 'big_number_total', tableVizStore, ); // bigNumberTotal -> table const sfd2 = new StandardizedFormData(bntFormData); expect(sfd2.has('big_number_total')).toBeTruthy(); expect(sfd2.has('table')).toBeTruthy(); expect(sfd2.get('big_number_total').viz_type).toBe('big_number_total'); expect(sfd2.get('table').viz_type).toBe('table'); }); test('transform', () => { // table -> bigNumberTotal const sfd = new StandardizedFormData(tableVizFormData); const { formData: bntFormData, controlsState: bntControlsState } = sfd.transform('big_number_total', tableVizStore); expect(Object.keys(bntFormData).sort()).toEqual( [...Object.keys(bntControlsState), 'standardizedFormData'].sort(), ); expect(bntFormData.viz_type).toBe('big_number_total'); expect(bntFormData.metric).toBe('count'); // change control values on bigNumber bntFormData.metric = 'sum(sales)'; bntFormData.time_range = '2021 : 2022'; bntControlsState.metric.value = 'sum(sales)'; bntControlsState.time_range.value = '2021 : 2022'; // bigNumberTotal -> table const sfd2 = new StandardizedFormData(bntFormData); const { formData: tblFormData, controlsState: tblControlsState } = sfd2.transform('table', { ...tableVizStore, form_data: bntFormData, controls: bntControlsState, }); expect(Object.keys(tblFormData).sort()).toEqual( [...Object.keys(tblControlsState), 'standardizedFormData'].sort(), ); expect(tblFormData.viz_type).toBe('table'); expect(tblFormData.metrics).toEqual([ 'sum(sales)', 'avg(sales)', adhocMetricSimple, adhocMetricSQL, ]); expect(tblFormData.groupby).toEqual(['name', 'gender', adhocColumn]); expect(tblFormData.time_range).toBe('2021 : 2022'); }); }); describe('initial SFD between different datasource', () => { beforeAll(() => { getChartControlPanelRegistry().registerValue( 'big_number_total', new BigNumberTotalChartPlugin().controlPanel, ); getChartControlPanelRegistry().registerValue( 'table', new TableChartPlugin().controlPanel, ); }); test('initial SFD between different datasource', () => { const sfd = new StandardizedFormData(tableVizFormData); // table -> big number const { formData: bntFormData, controlsState: bntControlsState } = sfd.transform('big_number_total', tableVizStore); const sfd2 = new StandardizedFormData(bntFormData); // big number -> table const { formData: tblFormData } = sfd2.transform('table', { ...tableVizStore, form_data: bntFormData, controls: bntControlsState, }); expect( tblFormData.standardizedFormData.memorizedFormData.map( (mfd: [string, QueryFormData][]) => mfd[0], ), ).toEqual(['table', 'big_number_total']); const newDatasourceFormData = { ...tblFormData, datasource: '20__table' }; const newDatasourceSFD = new StandardizedFormData(newDatasourceFormData); expect( newDatasourceSFD .serialize() .memorizedFormData.map(([vizType]) => vizType), ).toEqual(['table']); expect(newDatasourceSFD.get('table')).not.toHaveProperty( 'standardizedFormData', ); }); });
7,738
0
petrpan-code/apache/superset/superset-frontend/src/explore
petrpan-code/apache/superset/superset-frontend/src/explore/exploreUtils/formData.test.ts
/** * 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 { sanitizeFormData } from './formData'; test('sanitizeFormData removes temporary control values', () => { expect( sanitizeFormData({ url_params: { foo: 'bar' }, metrics: ['foo', 'bar'], }), ).toEqual({ metrics: ['foo', 'bar'] }); });
7,740
0
petrpan-code/apache/superset/superset-frontend/src/explore
petrpan-code/apache/superset/superset-frontend/src/explore/exploreUtils/getChartDataUri.test.ts
/** * 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 { getChartDataUri } from '.'; test('Get ChartUri when allowDomainSharding:false', () => { expect( getChartDataUri({ path: '/path', qs: 'same-string', allowDomainSharding: false, }), ).toEqual({ _deferred_build: true, _parts: { duplicateQueryParameters: false, escapeQuerySpace: true, fragment: null, hostname: 'localhost', password: null, path: '/path', port: '', preventInvalidHostname: false, protocol: 'http', query: 'same-string', urn: null, username: null, }, _string: '', }); }); test('Get ChartUri when allowDomainSharding:true', () => { expect( getChartDataUri({ path: '/path-allowDomainSharding-true', qs: 'same-string-allowDomainSharding-true', allowDomainSharding: true, }), ).toEqual({ _deferred_build: true, _parts: { duplicateQueryParameters: false, escapeQuerySpace: true, fragment: null, hostname: undefined, password: null, path: '/path-allowDomainSharding-true', port: '', preventInvalidHostname: false, protocol: 'http', query: 'same-string-allowDomainSharding-true', urn: null, username: null, }, _string: '', }); });
7,741
0
petrpan-code/apache/superset/superset-frontend/src/explore
petrpan-code/apache/superset/superset-frontend/src/explore/exploreUtils/getChartKey.test.ts
/** * 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 { getChartKey } from '.'; test('should return "slice_id" when called with an object that has "slice.slice_id"', () => { expect(getChartKey({ slice: { slice_id: 100 } })).toBe(100); });
7,742
0
petrpan-code/apache/superset/superset-frontend/src/explore
petrpan-code/apache/superset/superset-frontend/src/explore/exploreUtils/getExploreUrl.test.ts
/** * 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 { getExploreUrl } from '.'; const createParams = () => ({ formData: { datasource: 'datasource', viz_type: 'viz_type', }, endpointType: 'base', force: false, curUrl: null, requestParams: {}, allowDomainSharding: false, method: 'POST', }); test('Get ExploreUrl with default params', () => { const params = createParams(); expect(getExploreUrl(params)).toBe('http://localhost/explore/'); }); test('Get ExploreUrl with endpointType:full', () => { const params = createParams(); expect(getExploreUrl({ ...params, endpointType: 'full' })).toBe( 'http://localhost/superset/explore_json/', ); }); test('Get ExploreUrl with endpointType:full and method:GET', () => { const params = createParams(); expect( getExploreUrl({ ...params, endpointType: 'full', method: 'GET' }), ).toBe('http://localhost/superset/explore_json/'); });