Skip to content

test(canvas): lock filter scope parity between filter bar and table click - #9976

Open
Tyagiquamar wants to merge 1 commit into
rilldata:mainfrom
Tyagiquamar:test/canvas-filter-scope-parity
Open

Tyagiquamar wants to merge 1 commit into
rilldata:mainfrom
Tyagiquamar:test/canvas-filter-scope-parity

Conversation

@Tyagiquamar

Copy link
Copy Markdown
Contributor

Related to #9845.

Problem

#9845 reports that the same dimension filter reaches all metrics views when set from the filter bar (\ .=...\ per view) but only one view when set by clicking a table, while the bar renders an identical single chip in both cases.

Root cause

On current \main\ both paths already converge on the shared \DimensionFilterManager\ plus \JoinerFilterManager.buildExpression\ fan-out (unified by #9746), so the divergent writes from the issue no longer reproduce. Nothing pins that behavior, though: the pivot click path (\createPivotClickToFilter\ -> \dimensionFilterAction) had no coverage asserting what URL params a click produces.

Fix

No behavior change. Adds a two-metrics-view harness (\mv1\ + \mv2\ sharing \country) to \pivot-click-to-filter.spec.ts\ with two regression tests:

  • a table click writes \country IN (...)\ to both \ .mv1\ and \ .mv2;
  • the filter bar path (\�ddNewFilter\ + selection) writes byte-identical params, with a single chip.

Regression test

New \canvas filter scope parity\ describe block in \pivot-click-to-filter.spec.ts. Full file: 50/50 pass. \ExpressionFilterManager.spec.ts: 69/69 pass (unchanged).

Validation


  • px vitest run src/features/canvas/components/pivot/pivot-click-to-filter.spec.ts --pool threads --no-isolate: 50 passed.

  • px vitest run src/features/dashboards/filters/ExpressionFilterManager.spec.ts --pool threads --no-isolate: 69 passed.

  • px prettier --check\ on the spec file: clean.
    px eslint\ on it: 0 errors (1 pre-existing warning on untouched code).
  • Note: vitest needed --pool threads --no-isolate\ on Windows (forks worker RPC times out) and a local \paraglide-js compile\ for the gitignored i18n \gen/\ dir before the suites resolve imports. Full monorepo suite left to CI.

// Second metrics view declaring the same dimensions, mirroring a canvas with
// two metrics views such as `duckdb_commits_metrics` and `rill_commits_metrics`
// in https://github.com/rilldata/rill/issues/9845.
const PIVOT_MIRROR_METRICS_NAME = "mv2";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: move these alongside PIVOT_METRICS_INIT in pivot-test-data.

// for the dimension, fanned out to every metrics view that declares it.
// ---------------------------------------------------------------------------

describe("canvas filter scope parity", () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets not add a tests specifically for the issue.

  1. You can just add PIVOT_MIRROR_METRICS_NAME to the shared manager in the top level beforeAll.
  2. Add assertions in table variant tests, flat table: single-cell-per-row, nested table: multi-select and nested table: cross-parent selection isolation.
  3. Add a test in each where filter bar changes update pivot (maybe out of scope if this doesn't work)

);
});

it("filter bar writes byte-identical params for the same selection", () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant to checking individual metrics views. Adding assertion in existing tests should be enough.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants