Skip to content

Fixes #32981: let the class base suppress the shared test-result graph - #32982

Merged
ShaileshParmar11 merged 2 commits into
open-metadata:mainfrom
TeddyCr:feat/test-case-result-tab-should-render-default-graph
Sep 9, 2026
Merged

ShaileshParmar11 merged 2 commits into
open-metadata:mainfrom
TeddyCr:feat/test-case-result-tab-should-render-default-graph

Conversation

@TeddyCr

@TeddyCr TeddyCr commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fixes #32981

TestCaseResultTab renders the shared TestSummary chart for every test case, and TestCaseResultTabClassBase exposes no way to say otherwise — only getAdditionalComponents and getAlertBanner, neither of which can suppress that render.

A downstream build that needs to plot a test type the shared chart reads wrongly (a freshness result stores signed slack rather than a measured delay, so the shared chart draws it as a descending line into negative durations) can therefore append its own chart, but cannot take the wrong one off the page. The only lever left is a CSS :has() rule, which does not unmount TestSummary — so the page issues getListTestCaseResults twice, renders a full recharts tree into a display: none container, and couples to class names owned by this repo.

This adds shouldRenderDefaultGraph(testCaseData) to the class base, defaulting to true so OSS behaviour is unchanged, surfaces it through useTestCaseResultTab, and gates the TestSummary block on it. An override that returns false unmounts the chart rather than hiding it, so its fetch never fires.

The gate goes through shouldRenderTestSummary in TestCaseResultTab.utils rather than inline. It is a type predicate, so TestSummary still receives a narrowed TestCase, and it keeps TestCaseResultTab under the sonarjs/cyclomatic-complexity ceiling of 10 — the inline testCaseData && shouldRenderDefaultGraph && form pushed it to 11 and failed lint.

Downstream consumer: openmetadata-collate#6385 overrides this hook in TestCaseResultTabClassCollate to return false for tableDataToBeFresh, where it supplies a replacement FreshnessGraph. That PR is blocked on this one — its override is inert until this lands and the submodule pointer moves.

Type of change:

  • Improvement

High-level design:

N/A — small change. Three files touched plus their tests; the hook is additive with a true default, so no existing caller changes behaviour.

Tests:

Use cases covered

  • A test case renders the shared TestSummary chart (unchanged default)
  • A class base that returns false for a test type unmounts the chart, so it neither renders nor fetches

Unit tests

  • TestCaseResultTabClassBase.test.ts — the default returns true for no argument, undefined, and a real test case; a subclass can suppress per test type
  • useTestCaseResultTab.test.tsx — the hook calls the class base with the current test case and surfaces both true and false
  • TestCaseResultTab.test.tsx — TestSummary is not in the document when the class base suppresses it

Verified locally: yarn test --testPathPattern TestCaseResultTab → 53 passed, and the new tab assertion fails on main without the gate (checked by reverting the condition). npx tsc --noEmit reports nothing on the changed files; ui-checkstyle sequence (organize-imports → eslint --fix → prettier) leaves them clean with 0 errors.

Integration tests

N/A — UI-only change.

Playwright tests

N/A — no user-visible change in OSS; the default keeps the current behaviour.

🤖 Generated with Claude Code

https://claude.ai/code/session_019Z6H2Crk88aujoBtrELGJK

`TestCaseResultTab` renders `TestSummary` for every test case, and
`TestCaseResultTabClassBase` exposes no way to say otherwise. A downstream
build that needs to plot a test type the shared chart reads wrongly can
therefore only append its own chart through `getAdditionalComponents` and hide
the shared one with CSS - which leaves `TestSummary` mounted, so the page
issues `getListTestCaseResults` twice and renders a full recharts tree into a
hidden container.

Add `shouldRenderDefaultGraph(testCaseData)` to the class base, defaulting to
`true` so OSS behaviour is unchanged, surface it through
`useTestCaseResultTab`, and gate the `TestSummary` block on it. An override
that returns `false` unmounts the chart rather than hiding it, so its fetch
never fires.

The gate goes through `shouldRenderTestSummary` in `TestCaseResultTab.utils`
rather than inline: it is a type predicate, so `TestSummary` still gets a
narrowed `TestCase`, and it keeps the component under the cyclomatic
complexity ceiling.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019Z6H2Crk88aujoBtrELGJK
Copilot AI lite review requested due to automatic review settings September 8, 2026 18:12
@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Sep 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The change is additive with a safe default and includes focused unit test coverage for both default and suppressed rendering paths.

Pull request overview

This PR adds an extension point to let downstream builds suppress the shared TestSummary graph in TestCaseResultTab (without CSS hacks), so incorrect default visualizations can be replaced cleanly and the extra getListTestCaseResults fetch is avoided when suppressed.

Changes:

  • Added shouldRenderDefaultGraph(testCaseData?: TestCase) to TestCaseResultTabClassBase (default true) and surfaced it through useTestCaseResultTab.
  • Gated rendering of TestSummary in TestCaseResultTab via a new shouldRenderTestSummary type-predicate helper.
  • Added/updated unit tests to cover default behavior and suppression behavior (including ensuring the graph is not mounted when suppressed).
File summaries
File Description
openmetadata-ui/src/main/resources/ui/src/components/DataQuality/IncidentManager/TestCaseResultTab/useTestCaseResultTab.tsx Exposes shouldRenderDefaultGraph from the class base to the tab renderer.
openmetadata-ui/src/main/resources/ui/src/components/DataQuality/IncidentManager/TestCaseResultTab/useTestCaseResultTab.test.tsx Verifies the hook forwards the class-base decision for the current test case.
openmetadata-ui/src/main/resources/ui/src/components/DataQuality/IncidentManager/TestCaseResultTab/TestCaseResultTabClassBase.ts Adds the new overridable shouldRenderDefaultGraph hook (defaulting to OSS behavior).
openmetadata-ui/src/main/resources/ui/src/components/DataQuality/IncidentManager/TestCaseResultTab/TestCaseResultTabClassBase.test.ts Adds coverage for default behavior and subclass suppression per test type.
openmetadata-ui/src/main/resources/ui/src/components/DataQuality/IncidentManager/TestCaseResultTab/TestCaseResultTab.utils.ts Introduces shouldRenderTestSummary type predicate to keep TestSummary callsites typed and lint-complexity compliant.
openmetadata-ui/src/main/resources/ui/src/components/DataQuality/IncidentManager/TestCaseResultTab/TestCaseResultTab.test.tsx Adds test ensuring TestSummary is absent when the class base suppresses the default graph.
openmetadata-ui/src/main/resources/ui/src/components/DataQuality/IncidentManager/TestCaseResultTab/TestCaseResultTab.component.tsx Applies the render gate so the shared graph can be unmounted when suppressed.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copilot AI review requested due to automatic review settings September 8, 2026 18:18
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

⚠️ UI Checkstyle passed — lint findings in changed files

🔍 ESLint findings in this PR's files — 0 error(s), 3 warning(s)

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

0 error(s), 3 warning(s) across 2 changed file(s).

Count Rule
2 openmetadata-imports/no-lower-layer-page-imports
1 react-hooks/exhaustive-deps
All findings
Location Rule Message
🟡 src/components/DataQuality/IncidentManager/TestCaseResultTab/TestCaseResultTab.component.tsx:26:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/components/DataQuality/IncidentManager/TestCaseResultTab/TestCaseResultTab.component.tsx:325:6 react-hooks/exhaustive-deps React Hook useMemo has a missing dependency: 't'. Either include it or remove the dependency array.
🟡 src/components/DataQuality/IncidentManager/TestCaseResultTab/useTestCaseResultTab.tsx:35:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.

Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs and removed safe to test Add this label to run secure Github workflows on PRs labels Sep 8, 2026
@gitar-bot

gitar-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Adds shouldRenderDefaultGraph(testCaseData) to TestCaseResultTabClassBase to let downstream builds suppress the shared test-result graph, defaulting to true so OSS behaviour is unchanged. The gate unmounts TestSummary rather than hiding it, preventing unnecessary fetches and recharts rendering. Unit tests cover the default behaviour and suppression per test type. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The change is additive with a safe default, cleanly gates the problematic render path, and includes focused unit tests covering both default and suppressed behavior.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@TeddyCr

TeddyCr commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

All three warnings are pre-existing on main — this PR adds none.

I linted the main version of the two flagged files and the changed version, same ESLint invocation:

upstream/main (a4cd3ef), files untouched:

TestCaseResultTab.component.tsx
   26:1  warning  ... openmetadata-imports/no-lower-layer-page-imports
  323:6  warning  React Hook useMemo has a missing dependency: 't' ... react-hooks/exhaustive-deps
useTestCaseResultTab.tsx
   35:1  warning  ... openmetadata-imports/no-lower-layer-page-imports

✖ 3 problems (0 errors, 3 warnings)

This branch: the same 3, at 26:1, 325:6, 35:1 — the two-line shift is my added shouldRenderTestSummary import. Zero added findings, which is what the bot is guarding ("listed so this PR does not add to it").

On fixing them here rather than flagging them:

  • no-lower-layer-page-imports (×2) — both are useTestCaseStore, which lives at pages/IncidentManager/IncidentManagerDetailPage/useTestCase.store. Clearing them means relocating that store to a lower layer, which touches its 18 consumers across components/DataQuality/IncidentManager/**, components/Database/Profiler/TestSummary/** and pages/TableDetailsPageV1. That is a real cleanup, but it is a cross-cutting refactor unrelated to this extension point, and folding it in would bury a 7-file diff in a 25-file one. docs/ui-code-quality-gate.md records this rule at a 291-finding / 271-file baseline, so it wants its own pass.
  • react-hooks/exhaustive-deps — a useMemo I did not author or move. One-line fix, happy to include it if you would rather the file come out clean; left out by default as unrelated churn.

Blocking checkstyle status is green: 0 errors, and the ui-checkstyle sequence (organize-imports → eslint --fix → prettier) leaves the changed files with no diff.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 70%
70.47% (95253/135163) 55.02% (56362/102438) 56.38% (18815/33369)

@sonarqubecloud

sonarqubecloud Bot commented Sep 8, 2026

Copy link
Copy Markdown

@ShaileshParmar11
ShaileshParmar11 added this pull request to the merge queue Sep 9, 2026
Merged via the queue into open-metadata:main with commit 0bf732f Sep 9, 2026
94 of 97 checks passed
ShaileshParmar11 added a commit that referenced this pull request Sep 10, 2026
Conflicts came from #32982, which added a class-base gate on the shared
test-result graph while this branch moved that same graph to the top of the
main column.

* `TestCaseResultTab.component.tsx` — the graph keeps this branch's position
  and takes main's gate: `shouldRenderTestSummary(testCaseData,
  shouldRenderDefaultGraph)`. Git saw main "adding" the block at the old
  location only because this branch had removed it there, so that copy is
  dropped rather than duplicated — one `TestSummary` remains.

* `TestCaseResultTab.test.tsx` — both sides added a declaration and a reset in
  the same two places; both are kept.

One thing the textual merge could not see: #32982 moved the class base behind a
`default` export, so `jest.requireMock('./TestCaseResultTabClassBase')` in the
extension-components suite now resolves one level higher than the mock. It is
repointed at `.default`, which the tests would otherwise fail on despite a
clean merge.

Co-Authored-By: Claude Opus 5 <[email protected]>
ShaileshParmar11 added a commit that referenced this pull request Sep 10, 2026
…uration-card

Brings main (via TCD-0's merge) into the stack. The component auto-merged: the
class-base graph gate from #32982 landed on the card-reflowed layout without a
conflict, because TCD-0 resolved it to the identical text.

Two things the textual merge got wrong:

* `TestCaseResultTab.utils.ts` — this branch deleted `shouldShowSqlParamsSection`
  and with it the now-unused `isUndefined` import, while main added
  `shouldRenderTestSummary`, which uses `isUndefined`. Different lines, so no
  conflict was reported and the module threw `isUndefined is not defined` at
  runtime. The import is restored.

* The one real conflict was the `afterEach` reset: this branch sets
  `isTabExpanded` to `true` to match `useTestCase.store`'s default, main added a
  graph-gate reset in the same place. Both are kept.

Co-Authored-By: Claude Opus 5 <[email protected]>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TestCaseResultTab has no extension point to replace the shared TestSummary graph

3 participants