mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
chore(lint): migrate Jest lint rules from eslint to oxlint (#37787)
Signed-off-by: hainenber <dotronghai96@gmail.com>
This commit is contained in:
@@ -26,7 +26,7 @@ import type {
|
||||
|
||||
describe('agGridFilterConverter', () => {
|
||||
describe('Empty and invalid inputs', () => {
|
||||
it('should handle empty filter model', () => {
|
||||
test('should handle empty filter model', () => {
|
||||
const result = convertAgGridFiltersToSQL({});
|
||||
|
||||
expect(result.simpleFilters).toEqual([]);
|
||||
@@ -34,7 +34,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.havingClause).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should handle null filter model', () => {
|
||||
test('should handle null filter model', () => {
|
||||
const result = convertAgGridFiltersToSQL(null as any);
|
||||
|
||||
expect(result.simpleFilters).toEqual([]);
|
||||
@@ -42,7 +42,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.havingClause).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should skip invalid column names', () => {
|
||||
test('should skip invalid column names', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
valid_column: {
|
||||
filterType: 'text',
|
||||
@@ -62,7 +62,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.simpleFilters[0].col).toBe('valid_column');
|
||||
});
|
||||
|
||||
it('should skip filters with invalid objects', () => {
|
||||
test('should skip filters with invalid objects', () => {
|
||||
const filterModel = {
|
||||
column1: null,
|
||||
column2: 'invalid string',
|
||||
@@ -81,7 +81,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
|
||||
describe('Simple text filters', () => {
|
||||
it('should convert equals filter', () => {
|
||||
test('should convert equals filter', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
name: {
|
||||
filterType: 'text',
|
||||
@@ -100,7 +100,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert notEqual filter', () => {
|
||||
test('should convert notEqual filter', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
status: {
|
||||
filterType: 'text',
|
||||
@@ -118,7 +118,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert contains filter with wildcard', () => {
|
||||
test('should convert contains filter with wildcard', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
description: {
|
||||
filterType: 'text',
|
||||
@@ -136,7 +136,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert notContains filter with wildcard', () => {
|
||||
test('should convert notContains filter with wildcard', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
description: {
|
||||
filterType: 'text',
|
||||
@@ -154,7 +154,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert startsWith filter with trailing wildcard', () => {
|
||||
test('should convert startsWith filter with trailing wildcard', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
email: {
|
||||
filterType: 'text',
|
||||
@@ -172,7 +172,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert endsWith filter with leading wildcard', () => {
|
||||
test('should convert endsWith filter with leading wildcard', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
email: {
|
||||
filterType: 'text',
|
||||
@@ -192,7 +192,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
|
||||
describe('Numeric filters', () => {
|
||||
it('should convert lessThan filter', () => {
|
||||
test('should convert lessThan filter', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
age: {
|
||||
filterType: 'number',
|
||||
@@ -210,7 +210,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert lessThanOrEqual filter', () => {
|
||||
test('should convert lessThanOrEqual filter', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
price: {
|
||||
filterType: 'number',
|
||||
@@ -228,7 +228,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert greaterThan filter', () => {
|
||||
test('should convert greaterThan filter', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
score: {
|
||||
filterType: 'number',
|
||||
@@ -246,7 +246,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert greaterThanOrEqual filter', () => {
|
||||
test('should convert greaterThanOrEqual filter', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
rating: {
|
||||
filterType: 'number',
|
||||
@@ -264,7 +264,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert inRange filter to BETWEEN', () => {
|
||||
test('should convert inRange filter to BETWEEN', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
age: {
|
||||
filterType: 'number',
|
||||
@@ -287,7 +287,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
|
||||
describe('Null/blank filters', () => {
|
||||
it('should convert blank filter to IS NULL', () => {
|
||||
test('should convert blank filter to IS NULL', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
optional_field: {
|
||||
filterType: 'text',
|
||||
@@ -304,7 +304,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert notBlank filter to IS NOT NULL', () => {
|
||||
test('should convert notBlank filter to IS NOT NULL', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
required_field: {
|
||||
filterType: 'text',
|
||||
@@ -323,7 +323,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
|
||||
describe('Set filters', () => {
|
||||
it('should convert set filter to IN operator', () => {
|
||||
test('should convert set filter to IN operator', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
status: {
|
||||
filterType: 'set',
|
||||
@@ -340,7 +340,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle set filter with numeric values', () => {
|
||||
test('should handle set filter with numeric values', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
priority: {
|
||||
filterType: 'set',
|
||||
@@ -357,7 +357,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should skip empty set filters', () => {
|
||||
test('should skip empty set filters', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
status: {
|
||||
filterType: 'set',
|
||||
@@ -372,7 +372,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
|
||||
describe('Compound filters', () => {
|
||||
it('should combine conditions with AND operator', () => {
|
||||
test('should combine conditions with AND operator', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
age: {
|
||||
filterType: 'number',
|
||||
@@ -395,7 +395,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.complexWhere).toBe('(age >= 18 AND age < 65)');
|
||||
});
|
||||
|
||||
it('should combine conditions with OR operator', () => {
|
||||
test('should combine conditions with OR operator', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
status: {
|
||||
filterType: 'text',
|
||||
@@ -420,7 +420,7 @@ describe('agGridFilterConverter', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle compound filter with inRange', () => {
|
||||
test('should handle compound filter with inRange', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
date: {
|
||||
filterType: 'date',
|
||||
@@ -444,7 +444,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.complexWhere).toContain('IS NOT NULL');
|
||||
});
|
||||
|
||||
it('should handle compound filter with invalid conditions gracefully', () => {
|
||||
test('should handle compound filter with invalid conditions gracefully', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
field: {
|
||||
filterType: 'text',
|
||||
@@ -468,7 +468,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.complexWhere).toBe("field = 'valid'");
|
||||
});
|
||||
|
||||
it('should handle multi-condition filters (conditions array)', () => {
|
||||
test('should handle multi-condition filters (conditions array)', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
category: {
|
||||
filterType: 'text',
|
||||
@@ -502,7 +502,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
|
||||
describe('Metric vs Dimension separation', () => {
|
||||
it('should put dimension filters in simpleFilters/complexWhere', () => {
|
||||
test('should put dimension filters in simpleFilters/complexWhere', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
state: {
|
||||
filterType: 'text',
|
||||
@@ -517,7 +517,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.havingClause).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should put metric filters in havingClause', () => {
|
||||
test('should put metric filters in havingClause', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
'SUM(revenue)': {
|
||||
filterType: 'number',
|
||||
@@ -532,7 +532,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.havingClause).toBe('SUM(revenue) > 1000');
|
||||
});
|
||||
|
||||
it('should separate mixed metric and dimension filters', () => {
|
||||
test('should separate mixed metric and dimension filters', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
state: {
|
||||
filterType: 'text',
|
||||
@@ -559,7 +559,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.havingClause).toBe('SUM(revenue) > 1000');
|
||||
});
|
||||
|
||||
it('should handle metric set filters in HAVING clause', () => {
|
||||
test('should handle metric set filters in HAVING clause', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
'AVG(score)': {
|
||||
filterType: 'set',
|
||||
@@ -573,7 +573,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.havingClause).toBe('AVG(score) IN (90, 95, 100)');
|
||||
});
|
||||
|
||||
it('should handle metric blank filters in HAVING clause', () => {
|
||||
test('should handle metric blank filters in HAVING clause', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
'COUNT(*)': {
|
||||
filterType: 'number',
|
||||
@@ -588,7 +588,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
|
||||
describe('Multiple filters combination', () => {
|
||||
it('should handle both simple and compound filters', () => {
|
||||
test('should handle both simple and compound filters', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
status: {
|
||||
filterType: 'text',
|
||||
@@ -625,7 +625,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.complexWhere).toBe('(age > 18 AND age < 65)');
|
||||
});
|
||||
|
||||
it('should combine multiple HAVING filters with AND', () => {
|
||||
test('should combine multiple HAVING filters with AND', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
'SUM(revenue)': {
|
||||
filterType: 'number',
|
||||
@@ -649,7 +649,7 @@ describe('agGridFilterConverter', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle single WHERE filter without parentheses', () => {
|
||||
test('should handle single WHERE filter without parentheses', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
age: {
|
||||
filterType: 'number',
|
||||
@@ -674,7 +674,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
|
||||
describe('SQL injection prevention', () => {
|
||||
it('should escape single quotes in filter values', () => {
|
||||
test('should escape single quotes in filter values', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
name: {
|
||||
filterType: 'text',
|
||||
@@ -689,7 +689,7 @@ describe('agGridFilterConverter', () => {
|
||||
// The actual escaping happens in SQL generation, but value is preserved
|
||||
});
|
||||
|
||||
it('should escape single quotes in complex filters', () => {
|
||||
test('should escape single quotes in complex filters', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
description: {
|
||||
filterType: 'text',
|
||||
@@ -704,7 +704,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.simpleFilters[0].val).toBe("%It's working%");
|
||||
});
|
||||
|
||||
it('should reject column names with SQL injection attempts', () => {
|
||||
test('should reject column names with SQL injection attempts', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
"name'; DROP TABLE users--": {
|
||||
filterType: 'text',
|
||||
@@ -718,7 +718,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.simpleFilters).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('should reject column names with special characters', () => {
|
||||
test('should reject column names with special characters', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
'column<script>alert(1)</script>': {
|
||||
filterType: 'text',
|
||||
@@ -732,7 +732,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.simpleFilters).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('should accept valid column names with allowed special characters', () => {
|
||||
test('should accept valid column names with allowed special characters', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
valid_column_123: {
|
||||
filterType: 'text',
|
||||
@@ -756,7 +756,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.simpleFilters).toHaveLength(3);
|
||||
});
|
||||
|
||||
it('should handle very long column names', () => {
|
||||
test('should handle very long column names', () => {
|
||||
const longColumnName = 'a'.repeat(300);
|
||||
const filterModel: AgGridFilterModel = {
|
||||
[longColumnName]: {
|
||||
@@ -774,7 +774,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
|
||||
describe('Edge cases', () => {
|
||||
it('should skip filters with missing type', () => {
|
||||
test('should skip filters with missing type', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
column: {
|
||||
filterType: 'text',
|
||||
@@ -787,7 +787,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.simpleFilters).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('should skip filters with unknown operator type', () => {
|
||||
test('should skip filters with unknown operator type', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
column: {
|
||||
filterType: 'text',
|
||||
@@ -801,7 +801,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.simpleFilters).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('should skip filters with invalid value types', () => {
|
||||
test('should skip filters with invalid value types', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
column: {
|
||||
filterType: 'text',
|
||||
@@ -815,7 +815,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.simpleFilters).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('should handle boolean filter values', () => {
|
||||
test('should handle boolean filter values', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
is_active: {
|
||||
filterType: 'boolean',
|
||||
@@ -833,7 +833,7 @@ describe('agGridFilterConverter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle null filter values for blank operators', () => {
|
||||
test('should handle null filter values for blank operators', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
field: {
|
||||
filterType: 'text',
|
||||
@@ -847,7 +847,7 @@ describe('agGridFilterConverter', () => {
|
||||
expect(result.simpleFilters[0].val).toBeNull();
|
||||
});
|
||||
|
||||
it('should handle metric filters with set filter', () => {
|
||||
test('should handle metric filters with set filter', () => {
|
||||
const filterModel: AgGridFilterModel = {
|
||||
'SUM(amount)': {
|
||||
filterType: 'set',
|
||||
|
||||
@@ -23,7 +23,7 @@ import { FILTER_INPUT_POSITIONS } from '../../src/consts';
|
||||
|
||||
describe('filterStateManager', () => {
|
||||
describe('getCompleteFilterState', () => {
|
||||
it('should return empty state when gridRef.current is null', async () => {
|
||||
test('should return empty state when gridRef.current is null', async () => {
|
||||
const gridRef = { current: null } as RefObject<AgGridReact>;
|
||||
|
||||
const result = await getCompleteFilterState(gridRef, []);
|
||||
@@ -38,7 +38,7 @@ describe('filterStateManager', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should return empty state when gridRef.current.api is undefined', async () => {
|
||||
test('should return empty state when gridRef.current.api is undefined', async () => {
|
||||
const gridRef = {
|
||||
current: { api: undefined } as any,
|
||||
} as RefObject<AgGridReact>;
|
||||
@@ -55,7 +55,7 @@ describe('filterStateManager', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert simple filters correctly', async () => {
|
||||
test('should convert simple filters correctly', async () => {
|
||||
const filterModel = {
|
||||
name: { filterType: 'text', type: 'equals', filter: 'John' },
|
||||
age: { filterType: 'number', type: 'greaterThan', filter: 25 },
|
||||
@@ -86,7 +86,7 @@ describe('filterStateManager', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should separate dimension and metric filters', async () => {
|
||||
test('should separate dimension and metric filters', async () => {
|
||||
const filterModel = {
|
||||
state: { filterType: 'text', type: 'equals', filter: 'CA' },
|
||||
'SUM(revenue)': {
|
||||
@@ -115,7 +115,7 @@ describe('filterStateManager', () => {
|
||||
expect(result.havingClause).toBe('SUM(revenue) > 1000');
|
||||
});
|
||||
|
||||
it('should detect first input position when active element is in first condition body', async () => {
|
||||
test('should detect first input position when active element is in first condition body', async () => {
|
||||
const filterModel = {
|
||||
name: { filterType: 'text', type: 'equals', filter: 'test' },
|
||||
};
|
||||
@@ -153,7 +153,7 @@ describe('filterStateManager', () => {
|
||||
expect(result.inputPosition).toBe(FILTER_INPUT_POSITIONS.FIRST);
|
||||
});
|
||||
|
||||
it('should detect second input position when active element is in second condition body', async () => {
|
||||
test('should detect second input position when active element is in second condition body', async () => {
|
||||
const filterModel = {
|
||||
age: {
|
||||
filterType: 'number',
|
||||
@@ -197,7 +197,7 @@ describe('filterStateManager', () => {
|
||||
expect(result.inputPosition).toBe(FILTER_INPUT_POSITIONS.SECOND);
|
||||
});
|
||||
|
||||
it('should return unknown position when active element is not in any condition body', async () => {
|
||||
test('should return unknown position when active element is not in any condition body', async () => {
|
||||
const filterModel = {
|
||||
name: { filterType: 'text', type: 'equals', filter: 'test' },
|
||||
};
|
||||
@@ -233,7 +233,7 @@ describe('filterStateManager', () => {
|
||||
expect(result.lastFilteredColumn).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should handle multiple filtered columns and detect the correct one', async () => {
|
||||
test('should handle multiple filtered columns and detect the correct one', async () => {
|
||||
const filterModel = {
|
||||
name: { filterType: 'text', type: 'equals', filter: 'John' },
|
||||
age: { filterType: 'number', type: 'greaterThan', filter: 25 },
|
||||
@@ -287,7 +287,7 @@ describe('filterStateManager', () => {
|
||||
expect(result.inputPosition).toBe(FILTER_INPUT_POSITIONS.FIRST);
|
||||
});
|
||||
|
||||
it('should handle filter instance without eConditionBodies', async () => {
|
||||
test('should handle filter instance without eConditionBodies', async () => {
|
||||
const filterModel = {
|
||||
name: { filterType: 'text', type: 'equals', filter: 'test' },
|
||||
};
|
||||
@@ -314,7 +314,7 @@ describe('filterStateManager', () => {
|
||||
expect(result.lastFilteredColumn).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should handle empty filter model', async () => {
|
||||
test('should handle empty filter model', async () => {
|
||||
const filterModel = {};
|
||||
|
||||
const mockApi = {
|
||||
@@ -335,7 +335,7 @@ describe('filterStateManager', () => {
|
||||
expect(result.inputPosition).toBe(FILTER_INPUT_POSITIONS.UNKNOWN);
|
||||
});
|
||||
|
||||
it('should handle compound filters correctly', async () => {
|
||||
test('should handle compound filters correctly', async () => {
|
||||
const filterModel = {
|
||||
age: {
|
||||
filterType: 'number',
|
||||
@@ -363,7 +363,7 @@ describe('filterStateManager', () => {
|
||||
expect(result.complexWhere).toBe('(age >= 18 AND age < 65)');
|
||||
});
|
||||
|
||||
it('should handle set filters correctly', async () => {
|
||||
test('should handle set filters correctly', async () => {
|
||||
const filterModel = {
|
||||
status: {
|
||||
filterType: 'set',
|
||||
@@ -390,7 +390,7 @@ describe('filterStateManager', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should break detection loop after finding active element', async () => {
|
||||
test('should break detection loop after finding active element', async () => {
|
||||
const filterModel = {
|
||||
col1: { filterType: 'text', type: 'equals', filter: 'a' },
|
||||
col2: { filterType: 'text', type: 'equals', filter: 'b' },
|
||||
@@ -405,7 +405,7 @@ describe('filterStateManager', () => {
|
||||
const mockApi = {
|
||||
getFilterModel: jest.fn(() => filterModel),
|
||||
getColumnFilterInstance: jest.fn((colId: string) => {
|
||||
callCount++;
|
||||
callCount += 1;
|
||||
// Return match on col2
|
||||
if (colId === 'col2') {
|
||||
return Promise.resolve({
|
||||
@@ -437,7 +437,7 @@ describe('filterStateManager', () => {
|
||||
expect(callCount).toBeLessThanOrEqual(2);
|
||||
});
|
||||
|
||||
it('should handle null filter instance gracefully', async () => {
|
||||
test('should handle null filter instance gracefully', async () => {
|
||||
const filterModel = {
|
||||
name: { filterType: 'text', type: 'equals', filter: 'test' },
|
||||
};
|
||||
@@ -457,7 +457,7 @@ describe('filterStateManager', () => {
|
||||
expect(result.originalFilterModel).toEqual(filterModel);
|
||||
});
|
||||
|
||||
it('should maintain filter model reference integrity', async () => {
|
||||
test('should maintain filter model reference integrity', async () => {
|
||||
const originalFilterModel = {
|
||||
name: { filterType: 'text', type: 'equals', filter: 'test' },
|
||||
};
|
||||
@@ -477,7 +477,7 @@ describe('filterStateManager', () => {
|
||||
expect(result.originalFilterModel).toBe(originalFilterModel);
|
||||
});
|
||||
|
||||
it('should detect active element in eJoinAnds array', async () => {
|
||||
test('should detect active element in eJoinAnds array', async () => {
|
||||
const filterModel = {
|
||||
age: {
|
||||
filterType: 'number',
|
||||
@@ -524,7 +524,7 @@ describe('filterStateManager', () => {
|
||||
expect(result.inputPosition).toBe(FILTER_INPUT_POSITIONS.FIRST);
|
||||
});
|
||||
|
||||
it('should detect active element in eJoinOrs array', async () => {
|
||||
test('should detect active element in eJoinOrs array', async () => {
|
||||
const filterModel = {
|
||||
status: {
|
||||
filterType: 'text',
|
||||
@@ -571,7 +571,7 @@ describe('filterStateManager', () => {
|
||||
expect(result.inputPosition).toBe(FILTER_INPUT_POSITIONS.FIRST);
|
||||
});
|
||||
|
||||
it('should check condition bodies before join operators', async () => {
|
||||
test('should check condition bodies before join operators', async () => {
|
||||
const filterModel = {
|
||||
name: { filterType: 'text', type: 'equals', filter: 'test' },
|
||||
};
|
||||
@@ -613,7 +613,7 @@ describe('filterStateManager', () => {
|
||||
expect(result.inputPosition).toBe(FILTER_INPUT_POSITIONS.SECOND);
|
||||
});
|
||||
|
||||
it('should handle multiple eJoinAnds elements', async () => {
|
||||
test('should handle multiple eJoinAnds elements', async () => {
|
||||
const filterModel = {
|
||||
score: { filterType: 'number', type: 'greaterThan', filter: 90 },
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@ import type { AgGridChartState } from '@superset-ui/core';
|
||||
|
||||
describe('getInitialFilterModel', () => {
|
||||
describe('Priority: chartState > serverPaginationData', () => {
|
||||
it('should prioritize chartState.filterModel over serverPaginationData', () => {
|
||||
test('should prioritize chartState.filterModel over serverPaginationData', () => {
|
||||
const chartState: Partial<AgGridChartState> = {
|
||||
filterModel: {
|
||||
name: {
|
||||
@@ -47,7 +47,7 @@ describe('getInitialFilterModel', () => {
|
||||
expect(result).toEqual(chartState.filterModel);
|
||||
});
|
||||
|
||||
it('should use serverPaginationData when chartState.filterModel is unavailable', () => {
|
||||
test('should use serverPaginationData when chartState.filterModel is unavailable', () => {
|
||||
const chartState: Partial<AgGridChartState> = {};
|
||||
|
||||
const serverPaginationData = {
|
||||
@@ -65,7 +65,7 @@ describe('getInitialFilterModel', () => {
|
||||
expect(result).toEqual(serverPaginationData.agGridFilterModel);
|
||||
});
|
||||
|
||||
it('should use serverPaginationData when chartState is undefined', () => {
|
||||
test('should use serverPaginationData when chartState is undefined', () => {
|
||||
const serverPaginationData = {
|
||||
agGridFilterModel: {
|
||||
status: { filterType: 'text', type: 'equals', filter: 'active' },
|
||||
@@ -83,7 +83,7 @@ describe('getInitialFilterModel', () => {
|
||||
});
|
||||
|
||||
describe('Empty object handling', () => {
|
||||
it('should return undefined when chartState.filterModel is empty object', () => {
|
||||
test('should return undefined when chartState.filterModel is empty object', () => {
|
||||
const chartState: Partial<AgGridChartState> = {
|
||||
filterModel: {},
|
||||
};
|
||||
@@ -104,7 +104,7 @@ describe('getInitialFilterModel', () => {
|
||||
expect(result).toEqual(serverPaginationData.agGridFilterModel);
|
||||
});
|
||||
|
||||
it('should return undefined when serverPaginationData.agGridFilterModel is empty object', () => {
|
||||
test('should return undefined when serverPaginationData.agGridFilterModel is empty object', () => {
|
||||
const chartState: Partial<AgGridChartState> = {};
|
||||
|
||||
const serverPaginationData = {
|
||||
@@ -120,7 +120,7 @@ describe('getInitialFilterModel', () => {
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should handle both being empty objects', () => {
|
||||
test('should handle both being empty objects', () => {
|
||||
const chartState: Partial<AgGridChartState> = {
|
||||
filterModel: {},
|
||||
};
|
||||
@@ -140,19 +140,19 @@ describe('getInitialFilterModel', () => {
|
||||
});
|
||||
|
||||
describe('Undefined/null handling', () => {
|
||||
it('should return undefined when all inputs are undefined', () => {
|
||||
test('should return undefined when all inputs are undefined', () => {
|
||||
const result = getInitialFilterModel(undefined, undefined, true);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return undefined when chartState and serverPaginationData are undefined', () => {
|
||||
test('should return undefined when chartState and serverPaginationData are undefined', () => {
|
||||
const result = getInitialFilterModel(undefined, undefined, false);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return undefined when serverPagination is disabled', () => {
|
||||
test('should return undefined when serverPagination is disabled', () => {
|
||||
const chartState: Partial<AgGridChartState> = {};
|
||||
|
||||
const serverPaginationData = {
|
||||
@@ -170,7 +170,7 @@ describe('getInitialFilterModel', () => {
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should use chartState even when serverPagination is disabled', () => {
|
||||
test('should use chartState even when serverPagination is disabled', () => {
|
||||
const chartState: Partial<AgGridChartState> = {
|
||||
filterModel: {
|
||||
name: {
|
||||
@@ -199,7 +199,7 @@ describe('getInitialFilterModel', () => {
|
||||
});
|
||||
|
||||
describe('Complex filter models', () => {
|
||||
it('should handle complex chartState filter model', () => {
|
||||
test('should handle complex chartState filter model', () => {
|
||||
const chartState: Partial<AgGridChartState> = {
|
||||
filterModel: {
|
||||
name: { filterType: 'text', type: 'equals', filter: 'John' },
|
||||
@@ -222,7 +222,7 @@ describe('getInitialFilterModel', () => {
|
||||
expect(result).toEqual(chartState.filterModel);
|
||||
});
|
||||
|
||||
it('should handle complex serverPaginationData filter model', () => {
|
||||
test('should handle complex serverPaginationData filter model', () => {
|
||||
const serverPaginationData = {
|
||||
agGridFilterModel: {
|
||||
category: { filterType: 'text', type: 'contains', filter: 'tech' },
|
||||
@@ -241,7 +241,7 @@ describe('getInitialFilterModel', () => {
|
||||
});
|
||||
|
||||
describe('Real-world scenarios', () => {
|
||||
it('should handle permalink scenario with chartState', () => {
|
||||
test('should handle permalink scenario with chartState', () => {
|
||||
// User shares a permalink with saved filter state
|
||||
const chartState: Partial<AgGridChartState> = {
|
||||
filterModel: {
|
||||
@@ -258,7 +258,7 @@ describe('getInitialFilterModel', () => {
|
||||
expect(result?.revenue).toBeDefined();
|
||||
});
|
||||
|
||||
it('should handle fresh page load with server state', () => {
|
||||
test('should handle fresh page load with server state', () => {
|
||||
// Fresh page load - no chartState, but has serverPaginationData from ownState
|
||||
const serverPaginationData = {
|
||||
agGridFilterModel: {
|
||||
@@ -281,7 +281,7 @@ describe('getInitialFilterModel', () => {
|
||||
expect(result).toEqual(serverPaginationData.agGridFilterModel);
|
||||
});
|
||||
|
||||
it('should handle chart without any filters applied', () => {
|
||||
test('should handle chart without any filters applied', () => {
|
||||
// No filters applied anywhere
|
||||
const chartState: Partial<AgGridChartState> = {
|
||||
columnState: [],
|
||||
@@ -301,7 +301,7 @@ describe('getInitialFilterModel', () => {
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should handle transition from no filters to filters via permalink', () => {
|
||||
test('should handle transition from no filters to filters via permalink', () => {
|
||||
// User applies filters, creates permalink, then loads it
|
||||
const chartState: Partial<AgGridChartState> = {
|
||||
filterModel: {
|
||||
@@ -324,7 +324,7 @@ describe('getInitialFilterModel', () => {
|
||||
});
|
||||
|
||||
describe('Edge cases', () => {
|
||||
it('should handle null values in serverPaginationData', () => {
|
||||
test('should handle null values in serverPaginationData', () => {
|
||||
const serverPaginationData = {
|
||||
agGridFilterModel: null as any,
|
||||
};
|
||||
@@ -338,7 +338,7 @@ describe('getInitialFilterModel', () => {
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should handle serverPaginationData without agGridFilterModel key', () => {
|
||||
test('should handle serverPaginationData without agGridFilterModel key', () => {
|
||||
const serverPaginationData = {
|
||||
currentPage: 0,
|
||||
pageSize: 20,
|
||||
@@ -353,7 +353,7 @@ describe('getInitialFilterModel', () => {
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should handle chartState with null filterModel', () => {
|
||||
test('should handle chartState with null filterModel', () => {
|
||||
const chartState: Partial<AgGridChartState> = {
|
||||
filterModel: null as any,
|
||||
};
|
||||
@@ -373,7 +373,7 @@ describe('getInitialFilterModel', () => {
|
||||
expect(result).toEqual(serverPaginationData.agGridFilterModel);
|
||||
});
|
||||
|
||||
it('should handle serverPagination undefined (defaults to false)', () => {
|
||||
test('should handle serverPagination undefined (defaults to false)', () => {
|
||||
const serverPaginationData = {
|
||||
agGridFilterModel: {
|
||||
name: { filterType: 'text', type: 'equals', filter: 'test' },
|
||||
@@ -389,7 +389,7 @@ describe('getInitialFilterModel', () => {
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should preserve filter model structure without modification', () => {
|
||||
test('should preserve filter model structure without modification', () => {
|
||||
const originalFilterModel = {
|
||||
complexFilter: {
|
||||
filterType: 'number',
|
||||
|
||||
Reference in New Issue
Block a user