Repository navigation
test(explore): cover column config, conditional formatting, and contour controls - #44843
Conversation
…ur controls Add React Testing Library coverage for the CRUD-style controls: column config rows, popover edits and pruning, conditional formatting add/edit/remove flows, and the contour list, popover, and option. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The flagged issue is correct. Testing only a single field in a form that uses debounced updates can fail to detect race conditions where concurrent updates to different fields overwrite each other with stale state. To resolve this, you should update the test to perform sequential interactions on multiple fields and verify that the final state correctly reflects all changes, rather than just the last one. Would you like me to fetch all other comments on this PR to validate them and implement fixes for those as well? |
There was a problem hiding this comment.
Code Review Agent Run #877f71
Actionable Suggestions - 1
-
superset-frontend/src/explore/components/controls/ContourControl/ContourOption.test.tsx - 1
- Misleading test name · Line 102-102
Additional Suggestions - 12
-
superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/ControlForm.test.tsx - 2
-
Unused debounceDelay option · Line 35-35`renderForm` declares `debounceDelay?: number` (line 35) and forwards it via `debounceDelay={props.debounceDelay}` (line 48), but none of the five call sites passes it, so the plumbing is never exercised. Remove the option, or add a test that drives a custom delay through `ControlFormItem`'s `debounceDelay` prop.
-
Hardcoded 400ms wait · Line 95-95The inline `new Promise(resolve => setTimeout(resolve, 400))` reimplements the `sleep` helper already exported by `spec/helpers/testing-library` (which this file imports from) and hardcodes the margin over `Constants.FAST_DEBOUNCE` (250ms). Prefer `await sleep(Constants.FAST_DEBOUNCE + 150)`, matching the derivation pattern in `Select.test.tsx`.
-
-
superset-frontend/src/explore/components/controls/ConditionalFormattingControl/ConditionalFormattingControl.test.tsx - 3
-
Duplicated select helper · Line 151-159`pickColumn` (151-159) repeats the mechanism of `selectFieldOption` in `FormattingPopoverContent.test.tsx` (94-101): same combobox lookup, `.ant-select` parent scoping, click-through. The shared `selectOption` helper is documented unsafe for these inline popups, so extract one corrected helper into `spec/helpers/testing-library` instead of keeping per-file copies that can drift.
-
Unguarded mock.calls index · Line 146-147If `lastChange` runs before `onChange` has recorded any call, `mock.calls[length - 1]` is undefined and `[0]` throws a TypeError inside `waitFor`, surfacing as a timeout rather than a clean assertion failure. Current tests are safe because the control's mount effect always fires `onChange` (`ConditionalFormattingControl.tsx`), but optional chaining keeps future uses failing clearly.
-
Duplicated edit-flow steps · Line 215-220Lines 215-220 and 239-244 repeat the same six-step edit flow verbatim (click formatter label, await 'Edit formatter', get 'Target value', clear, type, click 'Apply'), differing only in label and typed value. A shared helper beside `pickColumn` would remove ~10 duplicated lines and keep each test focused on its distinct assertion (replace-at-index vs. preserving siblings).
-
-
superset-frontend/src/explore/components/controls/ContourControl/index.test.tsx - 7
-
Magic alpha value in fixtures · Line 30-31`a: 100` encodes the alpha value `updateColor` in `ContourPopoverControl.tsx` forces on every picked color; if that normalization changes, these fixtures silently stop matching real state. Add a brief comment tying 100 to the picker's forced alpha, or derive it from a shared constant.
-
Misleading placeholder type prop · Line 57-59`type="BoundsControl"` is a placeholder for a required prop the component ignores; the value is a real control type, so readers and future copy-pastes can misread this as a bounds control. Consider widening `ControlType` with a `ContourControl` member or making `type` optional for custom controls.
-
Unguarded mock.calls dereference · Line 69-70`lastChange` indexes `onChange.mock.calls[length - 1][0]` without guarding an empty calls array; inside the `waitFor` predicates (lines 100, 135, 157, 176, 194) a never-fired `onChange` throws `TypeError: Cannot read properties of undefined (reading '0')` instead of a clean timeout failure. Return `calls.at(-1)?.[0] ?? []`.
-
Unsound array type cast · Line 72-72`getAllByTestId` returns `HTMLElement[]`; the blanket `as HTMLInputElement[]` cast silences the compiler without checking, so a non-input `inline-name` element surfaces as a runtime `value`/`type` failure inside `userEvent.type` rather than a type error. Map and cast per element, or assert `instanceof HTMLInputElement`.
-
Unguarded querySelector click target · Line 74-78`pickColor` dereferences `document.querySelector('.ant-color-picker-trigger')` immediately; if the color picker has not mounted yet the `as HTMLElement` cast hides `null` and `userEvent.click(trigger)` throws `TypeError: trigger is null`. Wrap the lookup in the same `waitFor` retry pattern used for the preset below.
-
Magic default-contour count · Line 89-89`toHaveLength(3)` hardcodes the count of `DEFAULT_CONTOURS` in `index.tsx`; adding or removing a default contour silently breaks this test with an unexplained number. Export `DEFAULT_CONTOURS` and assert `toHaveLength(DEFAULT_CONTOURS.length)` so the link is explicit.
-
Repeated debounce sleep magic · Line 126-128`Constants.FAST_DEBOUNCE + 100` is repeated three times (lines 126, 128, 153); the bare `100` is an unexplained debounce-settling slack. Extract a named helper (e.g. `const debounceSettled = () => sleep(Constants.FAST_DEBOUNCE + 100)`) with a comment so the magic slack is defined once.
-
Review Details
-
Files reviewed - 7 · Commit Range:
6aa62bb..c9a4470- superset-frontend/src/explore/components/controls/ColumnConfigControl/ColumnConfigControl.test.tsx
- superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/ControlForm.test.tsx
- superset-frontend/src/explore/components/controls/ConditionalFormattingControl/ConditionalFormattingControl.test.tsx
- superset-frontend/src/explore/components/controls/ContourControl/ContourOption.test.tsx
- superset-frontend/src/explore/components/controls/ContourControl/ContourPopoverControl.test.tsx
- superset-frontend/src/explore/components/controls/ContourControl/ContourPopoverTrigger.test.tsx
- superset-frontend/src/explore/components/controls/ContourControl/index.test.tsx
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers an incremental AI Review. -
/review full- Manually triggers a full AI Review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ntrols Keep the upstream ColumnConfigControl.test.tsx unchanged and move the popover-based cases to ColumnConfigControl.popover.test.tsx, since the upstream file mocks ColumnConfigItem file-wide. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #44843 +/- ##
==========================================
+ Coverage 82.14% 82.27% +0.12%
==========================================
Files 2995 2995
Lines 184988 184988
Branches 42814 42814
==========================================
+ Hits 151960 152195 +235
+ Misses 30269 30034 -235
Partials 2759 2759
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Code Review Agent Run #e8e8deActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Code Review Agent Run #517aa1Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
rusackas
left a comment
There was a problem hiding this comment.
Solid test-only PR, and I like that it calls out the pre-existing bugs it deliberately doesn't pin (verified the isoband-upper-threshold-of-0 truthiness quirk is real in ContourPopoverControl.tsx, so that's an honest caveat, not a cop-out). Both of CodeAnt's race-condition asks got real follow-up tests with a clear explanation of what was and wasn't reproducible. Bito's remaining nits (shared helpers, magic numbers in fixtures) are optional cleanup, not blockers for test code.
Needs a rebase before it's mergeable, but LGTM otherwise.
…ntrols Resolve ConditionalFormattingControl.test.tsx: keep both sides' tests. Master's file-level FormattingPopover stub replaced the real popover the CRUD tests drive, so the stub is dropped and the add/remove test uses the real popover. Two prune tests no longer expect the mount-time onChange echo removed in #45352. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
CodeAnt PR Risk: Medium Risk
Assessed commit: |
…migration The popover test added in #44843 asserted that a config stored under the display alias `Time` is ignored. #44955 deliberately reads legacy `Time`-keyed configs and migrates them onto `__timestamp`, so the assertion is stale. Assert the intended behaviour instead: the legacy config is read back and an edit is saved under `__timestamp`. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 34d5617)
SUMMARY
Adds React Testing Library coverage for three CRUD-style Explore controls. This change touches test files only.
ColumnConfigControl.test.tsxandControlForm.test.tsx, both new)appliedColumnNames, and the 12-column "show all" threshold with its toggle.__timestampalias label.ControlForm: field seeding, merged and debounced edits, validation errors, and empty values.ConditionalFormattingControl.test.tsx)onChangelist keeps the other formatters in place.ContourControl/*.test.tsx, new)ContourPopoverControl: picks the isoline or isoband tab, saves the right shape, switches between tabs, and validates integers and threshold order.ContourPopoverTrigger: controlled and uncontrolled visibility.ContourOption: labels, remove, and edit.ContourControllist: defaults, z-index ordering, add, edit and remove.Each new test was checked by breaking the related product code, and the test failed each time.
Some behavior that looks like a bug was left unpinned on purpose, so a later fix won't have to rewrite these tests:
ColumnConfigControlsaves edits to the time column under its display alias ("Time"). The table plugins look the config up under__timestamp.NaN.0is treated as an isoline, because of a truthiness check.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A: tests only.
TESTING INSTRUCTIONS
cd superset-frontend npx jest \ src/explore/components/controls/ColumnConfigControl \ src/explore/components/controls/ConditionalFormattingControl \ src/explore/components/controls/ContourControlADDITIONAL INFORMATION
🤖 Generated with Claude Code