Skip to content

Commit

Permalink
[test] Fix console warnings while executing tests with React 18 (#16386)
Browse files Browse the repository at this point in the history
  • Loading branch information
arminmeh authored Jan 29, 2025
1 parent 07201fb commit 4eacfd4
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,18 @@ describe('<DataGridPremium /> - Data source aggregation', () => {

it('should show aggregation option in the column menu', async () => {
const { user } = render(<TestDataSourceAggregation />);
await waitFor(() => {
expect(getRowsSpy.callCount).to.be.greaterThan(0);
});
await user.click(within(getColumnHeaderCell(0)).getByLabelText('Menu'));
expect(screen.queryByLabelText('Aggregation')).not.to.equal(null);
});

it('should not show aggregation option in the column menu when no aggregation function is defined', async () => {
const { user } = render(<TestDataSourceAggregation aggregationFunctions={{}} />);
await waitFor(() => {
expect(getRowsSpy.callCount).to.be.greaterThan(0);
});
await user.click(within(getColumnHeaderCell(0)).getByLabelText('Menu'));
expect(screen.queryByLabelText('Aggregation')).to.equal(null);
});
Expand All @@ -117,6 +123,9 @@ describe('<DataGridPremium /> - Data source aggregation', () => {
}}
/>,
);
await waitFor(() => {
expect(getRowsSpy.callCount).to.be.greaterThan(0);
});
expect(getRowsSpy.args[0][0].aggregationModel).to.deep.equal({ id: 'size' });
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,15 @@ GridHeaderFilterCell.propTypes = {
inputRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({
current: PropTypes.any.isRequired,
current: (props, propName) => {
if (props[propName] == null) {
return null;
}
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
return new Error(`Expected prop '${propName}' to be of type Element`);
}
return null;
},
}),
]),
isFilterActive: PropTypes.bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,15 @@ GridHeaderFilterMenu.propTypes = {
inputRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({
current: PropTypes.any.isRequired,
current: (props, propName) => {
if (props[propName] == null) {
return null;
}
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
return new Error(`Expected prop '${propName}' to be of type Element`);
}
return null;
},
}),
]),
isFilterActive: PropTypes.bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,15 @@ GridHeaderFilterMenuContainer.propTypes = {
inputRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({
current: PropTypes.any.isRequired,
current: (props, propName) => {
if (props[propName] == null) {
return null;
}
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
return new Error(`Expected prop '${propName}' to be of type Element`);
}
return null;
},
}),
]),
isFilterActive: PropTypes.bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,15 @@ GridFilterInputBoolean.propTypes = {
inputRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({
current: PropTypes.any.isRequired,
current: (props, propName) => {
if (props[propName] == null) {
return null;
}
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
return new Error(`Expected prop '${propName}' to be of type Element`);
}
return null;
},
}),
]),
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,15 @@ GridFilterInputDate.propTypes = {
inputRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({
current: PropTypes.any.isRequired,
current: (props, propName) => {
if (props[propName] == null) {
return null;
}
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
return new Error(`Expected prop '${propName}' to be of type Element`);
}
return null;
},
}),
]),
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,15 @@ GridFilterInputMultipleSingleSelect.propTypes = {
inputRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({
current: PropTypes.any.isRequired,
current: (props, propName) => {
if (props[propName] == null) {
return null;
}
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
return new Error(`Expected prop '${propName}' to be of type Element`);
}
return null;
},
}),
]),
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,15 @@ GridFilterInputMultipleValue.propTypes = {
inputRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({
current: PropTypes.any.isRequired,
current: (props, propName) => {
if (props[propName] == null) {
return null;
}
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
return new Error(`Expected prop '${propName}' to be of type Element`);
}
return null;
},
}),
]),
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,15 @@ GridFilterInputSingleSelect.propTypes = {
inputRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({
current: PropTypes.any.isRequired,
current: (props, propName) => {
if (props[propName] == null) {
return null;
}
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
return new Error(`Expected prop '${propName}' to be of type Element`);
}
return null;
},
}),
]),
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,15 @@ GridFilterInputValue.propTypes = {
inputRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({
current: PropTypes.any.isRequired,
current: (props, propName) => {
if (props[propName] == null) {
return null;
}
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
return new Error(`Expected prop '${propName}' to be of type Element`);
}
return null;
},
}),
]),
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type GridFilterInputValueProps<
applyValue: (value: GridFilterItem) => void;
// Is any because if typed as GridApiRef a dep cycle occurs. Same happens if ApiContext is used.
apiRef: RefObject<Api>;
inputRef?: React.Ref<any>;
inputRef?: React.Ref<HTMLElement | null>;
focusElementRef?: React.Ref<any>;
headerFilterMenu?: React.ReactNode;
clearButton?: React.ReactNode | null;
Expand Down

0 comments on commit 4eacfd4

Please sign in to comment.