Skip to content

Commit da4e924

Browse files
sadpandajoeclaude
andcommitted
fix(chart): use isCustomControlItem in word cloud test type predicate
Fix tsc failure: the ad-hoc type predicate narrowed to a type that isn't assignable to ControlSetItem. Reuse the exported isCustomControlItem guard from @superset-ui/chart-controls, matching the pattern used in ControlPanelsContainer. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f1c12aa commit da4e924

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

superset-frontend/plugins/plugin-chart-word-cloud/test/controlPanel.test.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
import { isCustomControlItem } from '@superset-ui/chart-controls';
1920
import controlPanel from '../src/plugin/controlPanel';
2021
import React, { ReactElement } from 'react';
2122

@@ -58,14 +59,11 @@ test('sort_by_series defaults to true to preserve legacy ordering', () => {
5859

5960
const sortBySeriesEntry = querySection.controlSetRows
6061
.flat()
61-
.find(
62-
(item): item is { name: string; config: { default?: unknown } } =>
63-
typeof item === 'object' &&
64-
item !== null &&
65-
'name' in item &&
66-
(item as { name: string }).name === 'sort_by_series',
67-
);
62+
.find(item => isCustomControlItem(item) && item.name === 'sort_by_series');
6863

69-
expect(sortBySeriesEntry).toBeDefined();
70-
expect(sortBySeriesEntry?.config.default).toBe(true);
64+
expect(isCustomControlItem(sortBySeriesEntry)).toBe(true);
65+
if (!isCustomControlItem(sortBySeriesEntry)) {
66+
throw new Error('sort_by_series control missing');
67+
}
68+
expect(sortBySeriesEntry.config.default).toBe(true);
7169
});

0 commit comments

Comments
 (0)