test(mixed-timeseries): regression coverage for #37921 (first metric duplicated with multi-metric + group-by)#40146
Draft
rusackas wants to merge 1 commit into
Draft
Conversation
…duplicated with multi-metric + group-by) Adds a failing unit test that pins down the residual mixed-chart bug reported in #37921 ("Residual" follow-up to #37055). The bug: in MixedTimeseries/transformProps.ts, MetricDisplayNameA is hard-coded to metrics[0]. When Query A has multiple metrics + at least one Group By dimension, the per-series display-name builder prepends that first-metric label to every series whose extractSeries name doesn't already include it: displayName = entryName.includes(metricPart) ? entryName : `${metricPart}, ${entryName}`; For series belonging to metrics[1+] (e.g. score_two), the `includes` check is false, so they end up named `score_one, score_two, A` instead of `score_two, A`. That is the "first metric duplicated in legend / tooltip" symptom the OP reported. This test reproduces the scenario with metrics=[score_one, score_two] + groupby=[category] and asserts: - each (metric, dim_value) combo appears exactly once with the correct metric prefix - no series name contains both metric labels concatenated (smoking-gun assertion for the duplication) Intentionally lands as a failing test — it'll go red in CI and stay red until the per-series metric resolution in transformProps.ts is fixed (e.g. by deriving each series' metric from labelMap rather than falling back to metrics[0]). Test name and comment block reference #37921 explicitly so the fix PR has an obvious place to flip the assertion expectations from "should be" to "verified".
6 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
SUMMARY
Adds a failing unit test that pins down the residual mixed-chart bug reported in #37921 ("Residual" follow-up to #37055). Intentionally lands as a failing test — it'll go red in CI and stay red until the duplication is fixed; that gives us clear regression coverage and a single place to flip "should be" assertions to "verified" once a fix lands.
The bug
In
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts,MetricDisplayNameAis hard-coded tometrics[0](line 254). When Query A has multiple metrics + at least one Group By dimension, the per-series display-name builder (~line 441) prepends that first-metric label to every series whoseextractSeriesname doesn't already contain it:For series belonging to
metrics[1+](e.g.score_two), theincludescheck is false, so they end up namedscore_one, score_two, Ainstead ofscore_two, A. That is the "first metric duplicated in legend/tooltip" symptom the OP reported.A correct fix would derive each series' metric from
labelMap(which already maps each output column to its[metric, dim_value]tuple) rather than always falling back tometrics[0].What this PR adds
A single test in
transformProps.test.tstitledregression #37921: multi-metric Query A with groupby does not duplicate first metric in series names. It:metrics: ['score_one', 'score_two']+groupby: ['category']on Query Ascore_one, A,score_one, B,score_two, A,score_two, B) with a matchinglabel_map(metric, dim_value)combo appears exactly once with the correct metric prefix/score_one,\s+score_two/)Why a unit test rather than e2e
The bug lives in a pure transformation (
formData→ echarts series config). A unit test reproduces it in milliseconds, asserts string-level invariants directly, and pins the contract regardless of how the surrounding rendering layer evolves. Playwright would be slower, brittler, and the bug isn't UI-interaction-shaped.Companion / related work
prevent duplicate legend entries), which the OP correctly noted didn't cover the multi-metric + group-by case.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A.
TESTING INSTRUCTIONS
Expected: test fails on this commit. Specifically, the
toContain('score_two, A')andtoContain('score_two, B')assertions fail (the actual names are'score_one, score_two, A'and'score_one, score_two, B'), and thenot.toMatch(/score_one,\s+score_two/)assertion fails for both score_two entries.ADDITIONAL INFORMATION