-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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: fix/suppress webpack console warnings #31830
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f74d0ba
fix: a new console warnings
mistercrunch e7862e9
suppress long-standing other warning about superset_text
mistercrunch 3152fe7
fix build
mistercrunch 542afec
fixes
mistercrunch a12acc9
fix
mistercrunch 555b359
add missing count
mistercrunch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
145 changes: 145 additions & 0 deletions
145
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/common.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 { JsonObject, QueryFormData } from '@superset-ui/core'; | ||
import { getAggFunc, commonLayerProps } from './common'; | ||
|
||
const partialformData: Partial<QueryFormData> = { | ||
viz_type: 'table', | ||
datasource: '3_sqla', | ||
}; | ||
|
||
describe('getAggFunc', () => { | ||
it('returns correct function for sum', () => { | ||
const aggFunc = getAggFunc('sum'); | ||
const result = aggFunc([1, 2, 3, 4]); | ||
expect(result).toBe(10); | ||
}); | ||
|
||
it('returns correct function for min', () => { | ||
const aggFunc = getAggFunc('min'); | ||
const result = aggFunc([1, 2, 3, 4]); | ||
expect(result).toBe(1); | ||
}); | ||
|
||
it('returns correct function for max', () => { | ||
const aggFunc = getAggFunc('max'); | ||
const result = aggFunc([1, 2, 3, 4]); | ||
expect(result).toBe(4); | ||
}); | ||
|
||
it('returns correct function for mean', () => { | ||
const aggFunc = getAggFunc('mean'); | ||
const result = aggFunc([1, 2, 3, 4]); | ||
expect(result).toBe(2.5); | ||
}); | ||
|
||
it('returns correct function for median', () => { | ||
const aggFunc = getAggFunc('median'); | ||
const result = aggFunc([1, 2, 3, 4, 5]); | ||
expect(result).toBe(3); | ||
}); | ||
|
||
it('returns correct function for variance', () => { | ||
const aggFunc = getAggFunc('variance'); | ||
const result = aggFunc([1, 2, 3, 4]); | ||
expect(result).toBeCloseTo(1.6666666666666667); | ||
}); | ||
|
||
it('returns correct function for deviation', () => { | ||
const aggFunc = getAggFunc('deviation'); | ||
const result = aggFunc([1, 2, 3, 4]); | ||
expect(result).toBeCloseTo(1.29099, 5); | ||
}); | ||
|
||
it('returns correct function for count', () => { | ||
const aggFunc = getAggFunc('count'); | ||
const result = aggFunc([1, 2, 3, 4]); | ||
expect(result).toBe(4); | ||
}); | ||
|
||
it('returns correct function for p95 (percentiles)', () => { | ||
const aggFunc = getAggFunc('p95'); | ||
const result = aggFunc([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); | ||
expect(result).toBeCloseTo(9.55, 5); | ||
}); | ||
|
||
it('throws an error for unsupported aggregation type', () => { | ||
expect(() => getAggFunc('unsupported')).toThrow( | ||
'Unsupported aggregation type: unsupported', | ||
); | ||
}); | ||
}); | ||
|
||
describe('commonLayerProps', () => { | ||
const mockSetTooltip = jest.fn(); | ||
const mockSetTooltipContent = jest.fn( | ||
() => (o: JsonObject) => `Tooltip for ${o}`, | ||
); | ||
const mockOnSelect = jest.fn(); | ||
|
||
it('returns correct props when js_tooltip is provided', () => { | ||
const formData = { | ||
...partialformData, | ||
js_tooltip: 'tooltip => tooltip.content', | ||
} as QueryFormData; | ||
const props = commonLayerProps( | ||
formData, | ||
mockSetTooltip, | ||
mockSetTooltipContent, | ||
); | ||
expect(props.pickable).toBe(true); | ||
expect(props.onHover).toBeDefined(); | ||
}); | ||
|
||
it('calls onHover and sets tooltip', () => { | ||
const formData = { ...partialformData, js_tooltip: null } as QueryFormData; | ||
const props = commonLayerProps( | ||
formData, | ||
mockSetTooltip, | ||
mockSetTooltipContent, | ||
); | ||
|
||
const mockObject = { picked: true, x: 10, y: 20 }; | ||
props.onHover?.(mockObject); | ||
expect(mockSetTooltip).toHaveBeenCalledWith({ | ||
content: expect.any(Function), // Matches any function | ||
x: 10, | ||
y: 20, | ||
}); | ||
}); | ||
|
||
it('calls onSelect when table_filter is enabled', () => { | ||
const formData = { | ||
...partialformData, | ||
table_filter: true, | ||
line_column: 'name', | ||
} as QueryFormData; | ||
const props = commonLayerProps( | ||
formData, | ||
mockSetTooltip, | ||
mockSetTooltipContent, | ||
mockOnSelect, | ||
); | ||
|
||
const mockObject = { object: { name: 'John Doe' } }; | ||
props.onClick?.(mockObject); | ||
expect(mockOnSelect).toHaveBeenCalledWith('John Doe'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaking Change in Aggregation Function Support
Tell me more
What is the issue?
The change from using d3array[type] to throwing an error for unsupported types may break backward compatibility for any existing charts using aggregation types not included in the new d3functions mapping.
Why this matters
If any dashboards or charts are currently using d3-array functions that aren't explicitly listed in d3functions (like 'bisect', 'group', etc.), they will now fail with an error instead of working as before.
Suggested change ∙ Feature Preview
Consider one of these approaches:
Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews.