Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
georgecwan committed Dec 19, 2023
1 parent e01581a commit e86692c
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 82 deletions.
10 changes: 0 additions & 10 deletions packages/dashboard-core-plugins/src/panels/IrisGridPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ import {
IrisGridContextMenuData,
IrisGridTableModel,
PartitionConfig,
isPartitionedGridModel,
PartitionedGridModel,
} from '@deephaven/iris-grid';
import {
AdvancedFilterOptions,
Expand Down Expand Up @@ -583,7 +581,6 @@ export class IrisGridPanel extends PureComponent<
customColumns,
selectDistinctColumns = [],
rollupConfig,
partitionConfig,
} = { ...irisGridState, ...irisGridStateOverrides };

if (customColumns.length > 0) {
Expand Down Expand Up @@ -613,13 +610,6 @@ export class IrisGridPanel extends PureComponent<
m.selectDistinctColumns = selectDistinctColumns;
});
}

if (partitionConfig != null && isPartitionedGridModel(model)) {
modelQueue.push(m => {
// eslint-disable-next-line no-param-reassign
(m as PartitionedGridModel).partitionConfig = partitionConfig;
});
}
}

this.setState({ model, modelQueue });
Expand Down
7 changes: 2 additions & 5 deletions packages/iris-grid/src/IrisGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -841,13 +841,10 @@ export class IrisGrid extends Component<IrisGridProps, IrisGridState> {
}

componentDidMount(): void {
const { model, partitions, partitionConfig } = this.props;
const { model, partitions } = this.props;
try {
if (isPartitionedGridModel(model) && model.isPartitionRequired) {
log.log('Partition mounting', partitions, partitionConfig);
if (partitionConfig) {
model.partitionConfig = partitionConfig;
} else if (partitions.length) {
if (partitions.length) {
model.partitionConfig = { partitions, mode: 'partition' };
}
this.setState({ isSelectingPartition: true }, () => {
Expand Down
5 changes: 4 additions & 1 deletion packages/iris-grid/src/IrisGridPartitionSelector.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import { render, fireEvent } from '@testing-library/react';
import dh from '@deephaven/jsapi-shim';
import IrisGridPartitionSelector from './IrisGridPartitionSelector';
import IrisGridTestUtils from './IrisGridTestUtils';
import { PartitionConfig } from './PartitionedGridModel';

function makeIrisGridPartitionSelector(
table = new IrisGridTestUtils(dh).makeTable(),
columns = [new IrisGridTestUtils(dh).makeColumn()],
onChange = jest.fn(),
onMerge = jest.fn(),
onKeyTable = jest.fn(),
getFormattedString = jest.fn(value => `${value}`)
getFormattedString = jest.fn(value => `${value}`),
partitionConfig = { partitions: [], mode: 'merged' }
) {
const tablePromise = Promise.resolve(table);
return render(
Expand All @@ -22,6 +24,7 @@ function makeIrisGridPartitionSelector(
onChange={onChange}
onMerge={onMerge}
onKeyTable={onKeyTable}
partitionConfig={partitionConfig as PartitionConfig}
/>
);
}
Expand Down
5 changes: 1 addition & 4 deletions packages/iris-grid/src/IrisGridProxyModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,7 @@ class IrisGridProxyModel extends IrisGridModel implements PartitionedGridModel {
this.setNextModel(
tablePromise.then(table => makeModel(this.dh, table, this.formatter))
);
} else if (
isIrisGridTableModelTemplate(this.originalModel) &&
this.model !== this.originalModel
) {
} else if (isIrisGridTableModelTemplate(this.originalModel)) {
this.setNextModel(Promise.resolve(this.originalModel));
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/iris-grid/src/IrisGridTableModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class IrisGridTableModel
}

set partitionConfig(partitionConfig: PartitionConfig) {
log.log('setting partition', partitionConfig);
log.debug('setting partition', partitionConfig);
const { partitions, mode } = partitionConfig;
const partitionFilters = [];

Expand Down
61 changes: 0 additions & 61 deletions packages/iris-grid/src/IrisGridUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,6 @@ describe('dehydration methods', () => {
IrisGridUtils.dehydrateIrisGridPanelState(irisGridTestUtils.makeModel(), {
isSelectingPartition: false,
partitions: [],
partitionColumns: [],
advancedSettings: new Map(),
}),
],
Expand Down Expand Up @@ -676,55 +675,11 @@ describe('hydration methods', () => {
);

it.each([
[
'hydrateIrisGridPanelStateV1',
{
isSelectingPartition: false,
partition: null,
partitionColumn: 'INVALID',
advancedSettings: [],
},
],
[
'hydrateIrisGridPanelStateV2',
{
isSelectingPartition: false,
partitions: [null],
partitionColumns: ['INVALID'],
advancedSettings: [],
},
],
])('%s invalid column error', (_label, panelState) => {
expect(() =>
IrisGridUtils.hydrateIrisGridPanelState(model, panelState)
).toThrow('Invalid partition column INVALID');
});

it.each([
[
'hydrateIrisGridPanelStateV1 null partition column',
{
isSelectingPartition: false,
partition: null,
partitionColumn: null,
advancedSettings: [],
},
],
[
'hydrateIrisGridPanelStateV1 null partition',
{
isSelectingPartition: false,
partition: null,
partitionColumn: 'name_0',
advancedSettings: [],
},
],
[
'hydrateIrisGridPanelStateV1 unselected partition',
{
isSelectingPartition: false,
partition: 'a',
partitionColumn: 'name_0',
advancedSettings: [],
},
],
Expand All @@ -733,7 +688,6 @@ describe('hydration methods', () => {
{
isSelectingPartition: true,
partition: 'a',
partitionColumn: 'name_0',
advancedSettings: [],
},
],
Expand All @@ -742,7 +696,6 @@ describe('hydration methods', () => {
{
isSelectingPartition: false,
partitions: [],
partitionColumns: [],
advancedSettings: [],
},
],
Expand All @@ -751,7 +704,6 @@ describe('hydration methods', () => {
{
isSelectingPartition: true,
partitions: [null, null],
partitionColumns: ['name_0', 'name_1'],
advancedSettings: [],
},
],
Expand All @@ -760,7 +712,6 @@ describe('hydration methods', () => {
{
isSelectingPartition: true,
partitions: ['a', 'b'],
partitionColumns: ['name_0', 'name_1'],
advancedSettings: [],
},
],
Expand All @@ -769,7 +720,6 @@ describe('hydration methods', () => {
{
isSelectingPartition: true,
partitions: [null, 'b', null],
partitionColumns: ['name_0', 'name_1', 'name_2'],
advancedSettings: [],
},
],
Expand All @@ -778,7 +728,6 @@ describe('hydration methods', () => {
{
isSelectingPartition: true,
partitions: ['a', null, 'b'],
partitionColumns: ['name_0', 'name_1', 'name_2'],
advancedSettings: [],
},
],
Expand All @@ -787,18 +736,8 @@ describe('hydration methods', () => {
expect(result.isSelectingPartition).toBe(panelState.isSelectingPartition);
if (isPanelStateV1(panelState)) {
expect(result.partitions).toEqual([panelState.partition]);
if (panelState.partitionColumn !== null) {
expect(result.partitionColumns[0].name).toBe(
panelState.partitionColumn
);
} else {
expect(result.partitionColumns).toEqual([]);
}
} else {
expect(result.partitions).toEqual(panelState.partitions);
panelState.partitionColumns.forEach((partition, index) => {
expect(result.partitionColumns[index].name === partition).toBeTruthy();
});
}
});
});

0 comments on commit e86692c

Please sign in to comment.