Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Chart Filter Bugs, Issue #971 #992

Merged
merged 20 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7651d02
fix(filter): validate filter on filter configuration, issue #971
Cuiyansong Mar 11, 2022
5697d56
refactor(filter): set manual added list item visibility to true
Cuiyansong Mar 11, 2022
3a04c88
fix(filter): fix filter operation is null or not null issue
Cuiyansong Mar 11, 2022
53615c7
fix(filter): should clear filter option when aggregate change, but sk…
Cuiyansong Mar 11, 2022
5b286be
fix(filter): fix customize list has no default values error
Cuiyansong Mar 11, 2022
2b056b2
fix(filter): fetch dataset with column name
Cuiyansong Mar 11, 2022
aa5764a
Merge pull request #76 from running-elephant/dev
Cuiyansong Mar 11, 2022
0330e1a
fix(filter): add paging with transfer and tables
Cuiyansong Mar 11, 2022
7259d57
Merge pull request #77 from running-elephant/dev
Cuiyansong Mar 14, 2022
50d5826
test(test): add husky hooks before push
Cuiyansong Mar 14, 2022
f4688f6
test(husky): upgrade husky to v7 and auto run commit before push
Cuiyansong Mar 14, 2022
b74eae9
refactor(filter): pass by form instance into child form component and…
Cuiyansong Mar 14, 2022
6d2f365
test(chart): add component tests for chart iframe container
Cuiyansong Mar 14, 2022
bec5914
test(chart): add form utils tests
Cuiyansong Mar 14, 2022
049d846
refactor(test): make ci test silent
Cuiyansong Mar 15, 2022
89f0db7
refactor(chart): move form collaspse header to child folder
Cuiyansong Mar 15, 2022
237d8c1
test(chart): form generator basic checkbox component tests
Cuiyansong Mar 15, 2022
31412e5
test(chart): form generator basic color selector component tests
Cuiyansong Mar 15, 2022
db201cd
test(chart): form generator basic font component tests
Cuiyansong Mar 15, 2022
5773821
test(chart): add more tests
Cuiyansong Mar 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frontend/.husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

cd frontend
npm run test:ci
5 changes: 3 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"build:analyze": "craco build && source-map-explorer 'build/static/js/*.js'",
"test": "craco test",
"test:coverage": "npm run test -- --watchAll=false --coverage",
"test:ci": "npm run test -- --watchAll=false --runInBand --silent",
"checkTs": "tsc --noEmit",
"eslint": "eslint --ext js,ts,tsx",
"lint": "npm run eslint src",
Expand Down Expand Up @@ -184,7 +185,7 @@
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react-hooks": "^4.2.0",
"html2canvas": "^1.3.2",
"husky": "^6.0.0",
"husky": "^7.0.4",
"jest-canvas-mock": "^2.3.1",
"jest-styled-components": "7.0.8",
"jsdoc": "^3.6.10",
Expand Down Expand Up @@ -217,4 +218,4 @@
"path": "cz-conventional-changelog"
}
}
}
}
28 changes: 28 additions & 0 deletions frontend/src/__tests__/MockMatchMedia.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Datart
*
* Copyright 2021
*
* Licensed 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.
*/

global.matchMedia =
global.matchMedia ||
function () {
return {
addListener: jest.fn(),
removeListener: jest.fn(),
};
};

export {};
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ChartIFrameEventBroker {

register(c: IChart) {
this._chart = c;
this.registeListener(c);
this.registerListener(c);
}

subscribe(event: HooksEvent, callback?: Function) {
Expand Down Expand Up @@ -102,7 +102,7 @@ class ChartIFrameEventBroker {
}
}

private registeListener(c: IChart): void {
private registerListener(c: IChart): void {
this.subscribe(ChartLifecycle.MOUNTED, c?.onMount);
this.subscribe(ChartLifecycle.UPDATED, c?.onUpdated);
this.subscribe(ChartLifecycle.RESIZE, c?.onResize);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Datart
*
* Copyright 2021
*
* Licensed 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 '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import { ChartIFrameContainer } from '../index';

jest.mock('uuid/dist/umd/uuidv4.min');

describe('ChartIFrameContainer Test', () => {
test('should render within iframe when enable use iframe', async () => {
const { container } = render(
<ChartIFrameContainer
dataset={[]}
chart={{ useIFrame: true }}
config={{}}
/>,
);
expect(container.querySelector('iframe')).not.toBeNull();
});

test('should not render iframe when disable use iframe', async () => {
const { container } = render(
<ChartIFrameContainer
dataset={[]}
chart={{ useIFrame: false }}
config={{}}
/>,
);
expect(container.querySelector('iframe')).toBeNull();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import { ChartStyleConfig } from 'app/types/ChartConfig';
import { FC, memo, useState } from 'react';
import styled from 'styled-components/macro';
import { SPACE_MD } from 'styles/StyleConstants';
import CollapseHeader from '../CollapseHeader';
import {
FormGeneratorLayoutProps,
GroupLayoutMode,
ItemComponentType,
} from '../types';
import { groupLayoutComparer } from '../utils';
import CollapseHeader from './CollapseHeader';
import CollectionLayout from './CollectionLayout';

const { Panel } = Collapse;
Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/components/FormGenerator/Layout/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* limitations under the License.
*/

export { default as CollapseHeader } from './CollapseHeader';
export { default as CollectionLayout } from './CollectionLayout';
export { default as GroupLayout } from './GroupLayout';
export { default as ItemLayout } from './ItemLayout';
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* Datart
*
* Copyright 2021
*
* Licensed 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 '@testing-library/jest-dom';
import { fireEvent, render } from '@testing-library/react';
import BasicCheckbox from '../Basic/BasicCheckbox';

describe('<BasicCheckbox />', () => {
let translator;
beforeAll(() => {
translator = label => `This is a ${label}`;
});

test('should render component correct', () => {
const { getByText, getByRole } = render(
<BasicCheckbox
translate={translator}
data={{ label: 'Component Label', value: true }}
/>,
);
expect(getByText('This is a Component Label')).toBeInTheDocument();
expect(getByRole('checkbox')).toBeInTheDocument();
expect(getByRole('checkbox')).toBeChecked();
});

test('should fire onChange event', async () => {
const handleOnChangeEvent = jest.fn();
const ancestors = [];
const needRefresh = true;

const { getByRole } = render(
<BasicCheckbox
ancestors={ancestors}
onChange={handleOnChangeEvent}
data={{
label: 'Component Label',
value: true,
options: { needRefresh },
}}
/>,
);
fireEvent.click(getByRole('checkbox'));
expect(handleOnChangeEvent).toHaveBeenCalledWith(
ancestors,
false,
needRefresh,
);
});

test('should hide label when options hide label', () => {
const { container } = render(
<BasicCheckbox
translate={translator}
data={{
label: 'Component Label',
options: { hideLabel: true },
}}
/>,
);
expect(container.querySelector('.ant-form-item-label label')).toBeNull();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Datart
*
* Copyright 2021
*
* Licensed 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 '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import BasicColorSelector from '../Basic/BasicColorSelector';

describe('<BasicColorSelector />', () => {
let translator;
beforeAll(() => {
translator = label => `This is a ${label}`;
});

test('should render component correct', () => {
const { container, getByText } = render(
<BasicColorSelector
translate={translator}
data={{ label: 'Component Label', value: '#fafafa' }}
/>,
);
expect(getByText('This is a Component Label')).toBeInTheDocument();
expect(container.querySelector('[class*="ColorPicker"]')).not.toBeNull();
});

test('should hide label when options hide label', () => {
const { container } = render(
<BasicColorSelector
data={{
label: 'Component Label',
options: { hideLabel: true },
}}
/>,
);
expect(container.querySelector('.ant-form-item-label label')).toBeNull();
});
});
Loading