feat: dashboard page xlsx export (#24005)

Co-authored-by: Vitali Logvin <vitali.logvin@noogadev.com>
This commit is contained in:
Vitali Logvin
2023-05-19 13:18:16 +03:00
committed by GitHub
parent d583ca9ef5
commit d0687d04eb
6 changed files with 67 additions and 6 deletions

View File

@@ -44,6 +44,7 @@ const createProps = (viz_type = 'sunburst') =>
exploreChart: jest.fn(),
exportCSV: jest.fn(),
exportFullCSV: jest.fn(),
exportXLSX: jest.fn(),
forceRefresh: jest.fn(),
handleToggleFullSize: jest.fn(),
toggleExpandSlice: jest.fn(),
@@ -126,6 +127,8 @@ test('Should render default props', () => {
// @ts-ignore
delete props.exportCSV;
// @ts-ignore
delete props.exportXLSX;
// @ts-ignore
delete props.cachedDttm;
// @ts-ignore
delete props.updatedDttm;
@@ -170,6 +173,16 @@ test('Should "export to CSV"', async () => {
expect(props.exportCSV).toBeCalledWith(371);
});
test('Should "export to Excel"', async () => {
const props = createProps();
renderWrapper(props);
expect(props.exportXLSX).toBeCalledTimes(0);
userEvent.hover(screen.getByText('Download'));
userEvent.click(await screen.findByText('Export to Excel'));
expect(props.exportXLSX).toBeCalledTimes(1);
expect(props.exportXLSX).toBeCalledWith(371);
});
test('Should not show "Download" if slice is filter box', () => {
const props = createProps('filter_box');
renderWrapper(props);