Skip to content

fix(test): handle CsvJobsTray auto-open race in SearchExport tray step - #30837

Merged
anuj-kumary merged 1 commit into
mainfrom
fix/search-export-tray-auto-open
Aug 3, 2026
Merged

anuj-kumary merged 1 commit into
mainfrom
fix/search-export-tray-auto-open

Conversation

@anuj-kumary

@anuj-kumary anuj-kumary commented Aug 3, 2026 •

Copy link
Copy Markdown
Member

Root cause

PR #30615 added a useEffect to CsvJobsTray that calls setOpen(true) whenever a job transitions to a terminal status. When the export completes quickly (typical in CI), the tray auto-opens before the test reaches the "Jobs tray surfaces" step.

Once open, the launcher button is hidden by {!open && !isEmpty(visibleJobs) && (...)}. The test's unconditional .getByRole('button', { name: /Background jobs|jobs running/ }).click() then times out.

Fix

  • Add data-testid="csv-jobs-tray" to the tray popover so tests can check its visibility without relying on CSS class names.
  • Guard the launcher click in SearchExport.spec.ts: only click when the tray isn't already open.
const tray = page.getByTestId('csv-jobs-tray');
if (!(await tray.isVisible())) {
  await page.getByRole('button', { name: /Background jobs|jobs running/ }).click();
}

Test plan

  • SearchExport.spec.ts › Export queues a background job and downloads from the jobs tray passes when the export completes before the tray step (fast CI path)
  • Same test passes when the export is still in progress at that step (slow path — manually clicked button)

🤖 Generated with Claude Code


Summary by Gitar

  • Query Builder Migration:
    • Migrated query builder components from Ant Design to @react-awesome-query-builder/ui and core components
    • Added custom widgets for fields, operators, text, numbers, select, multiselect, booleans, and dates in QueryBuilderOMConfig.tsx
  • UI Component Updates:
    • Updated MultiSelectBase to derive visible options from live items instead of snapshotting initial items on mount

This will update automatically on new commits.

@anuj-kumary
anuj-kumary requested review from a team, chirag-madlani and karanh37 as code owners August 3, 2026 06:53
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

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

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 the UI UI specific issues label Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@anuj-kumary anuj-kumary self-assigned this Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 9eb2ccf59e7b1c999e7da48b089e04490398042f in Playwright run 30798482075, attempt 1.

✅ 53 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 3 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 51m 0s

⏱️ Max setup 1m 25s · max shard execution 6m 44s · max shard-job elapsed before upload 11m 58s · reporting 3s

🌐 133.72 requests/attempt · 1.35 app boots/UI scenario · 0.00% common-shard skew

Optimization targets still in progress:

  • Application boot ratio was 1.35 per UI scenario (74 boots / 55 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 46 0 0 3 0 0
✅ Shard import-export-01 7 0 0 0 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@anuj-kumary
anuj-kumary force-pushed the fix/search-export-tray-auto-open branch from 4e53410 to 0bfc66e Compare August 3, 2026 07:24
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@anuj-kumary
anuj-kumary force-pushed the fix/search-export-tray-auto-open branch from 0bfc66e to 11c1495 Compare August 3, 2026 07:29
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@anuj-kumary anuj-kumary added safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check labels Aug 3, 2026
@anuj-kumary
anuj-kumary force-pushed the fix/search-export-tray-auto-open branch from 21c1383 to 345e4c6 Compare August 3, 2026 07:37
@anuj-kumary
anuj-kumary enabled auto-merge August 3, 2026 08:30
…Export

PR #30615 added a useEffect that calls setOpen(true) when an export job
reaches a terminal state, auto-opening the tray and hiding the launcher
button. The old unconditional .click() then timed out because the button
was no longer in the DOM.

The initial isVisible() guard fixed one failure mode but introduced a
new race: right after startAsyncExport there is a window where
visibleJobs is still empty, so neither the launcher nor the tray has
rendered yet. isVisible() returns false in that window, the click is
skipped, and the /Exporting|Exported/ assertion times out.

Fix: use locator.or() to wait until either the launcher button or the
tray popover becomes visible, then gate the click on which one won.
The tray popover is detected via its stable CSS class, requiring no
data-testid on the component.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@anuj-kumary
anuj-kumary added this pull request to the merge queue Aug 3, 2026
Merged via the queue into main with commit 53ffb0d Aug 3, 2026
67 checks passed
@anuj-kumary
anuj-kumary deleted the fix/search-export-tray-auto-open branch August 3, 2026 21:35
@gitar-bot

gitar-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 4 resolved / 4 findings

Guards the launcher click in SearchExport.spec.ts to prevent auto-open race conditions and adds a data-testid to CsvJobsTray. Addressed stale OMSelectWidget state and stale async results, cleaned up commented CSS, and resolved the isVisible gate race condition finding.

✅ 4 resolved
✅ Bug: OMSelectWidget snapshots static options in state, goes stale

📄 openmetadata-ui/src/main/resources/ui/src/utils/queryBuilderWidgets/OMSelectWidget.tsx:49-50 📄 openmetadata-ui/src/main/resources/ui/src/utils/queryBuilderWidgets/OMSelectWidget.tsx:112-125
In OMSelectWidget the static (non-async) options are stored via useState(staticItems) and only ever updated by the async loader — never re-derived from the listValues prop. RAQB reuses the same widget instance when a rule's field changes (this is exactly the reason OMMultiSelectWidget and OMFieldSelect deliberately derive their items from props each render, per their own inline comments). So if a static enum select field is switched to another static field on the same rule row, the dropdown keeps showing the previous field's options. Derive the static items from props (e.g. useMemo keyed on serialized listValues) instead of holding them in mount-time state, matching OMMultiSelectWidget.

✅ Quality: Async OMSelectWidget doesn't clear stale results on field switch

📄 openmetadata-ui/src/main/resources/ui/src/utils/queryBuilderWidgets/OMSelectWidget.tsx:74-78
Unlike OMMultiSelectWidget (which calls setAsyncItems([]) before re-fetching when the async field changes), OMSelectWidget's effect only calls loadAsync('') without first clearing items. When switching between two async fields the previous field's catalogue remains visible in the dropdown until the new fetch resolves. Clear the items before the fetch to avoid briefly showing options from the wrong field.

✅ Quality: Commented-out CSS block left in add-data-contract.less

📄 openmetadata-ui/src/main/resources/ui/src/components/DataContract/AddDataContract/add-data-contract.less:227-235
The input[type='text'], .ant-picker rule was commented out rather than removed, leaving dead code in the stylesheet. Either delete the block or restore it if the styling is still needed for the migrated inputs; commented CSS accumulates and obscures intent.

✅ Edge Case: isVisible() gate reintroduces the auto-open race it aims to fix

📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/SearchExport.spec.ts:454-463
launcherButton.isVisible() is a point-in-time check with no auto-waiting. Right after startAsyncExport, there is a window where visibleJobs is still empty, so the launcher ({!open && !isEmpty(visibleJobs) && ...}) is not yet rendered AND the tray has not auto-opened. If the check runs during that window it returns false, the click is skipped, and the /Exporting|Exported/ assertion at line 461 times out. The previous code's .click() auto-waited for the launcher to appear, so this commit can make the test flakier rather than more robust. Wait for either the launcher or the tray to be visible before gating the click.

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 👍 / 👎 | Gitar | Powered by Gitar — free for open source

anuj-kumary added a commit that referenced this pull request Aug 4, 2026
…Export (#30837)

PR #30615 added a useEffect that calls setOpen(true) when an export job
reaches a terminal state, auto-opening the tray and hiding the launcher
button. The old unconditional .click() then timed out because the button
was no longer in the DOM.

The initial isVisible() guard fixed one failure mode but introduced a
new race: right after startAsyncExport there is a window where
visibleJobs is still empty, so neither the launcher nor the tray has
rendered yet. isVisible() returns false in that window, the click is
skipped, and the /Exporting|Exported/ assertion times out.

Fix: use locator.or() to wait until either the launcher button or the
tray popover becomes visible, then gate the click on which one won.
The tray popover is detected via its stable CSS class, requiring no
data-testid on the component.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
(cherry picked from commit 53ffb0d)
k-anshul pushed a commit to k-anshul/OpenMetadata that referenced this pull request Aug 12, 2026
…Export (open-metadata#30837)

PR open-metadata#30615 added a useEffect that calls setOpen(true) when an export job
reaches a terminal state, auto-opening the tray and hiding the launcher
button. The old unconditional .click() then timed out because the button
was no longer in the DOM.

The initial isVisible() guard fixed one failure mode but introduced a
new race: right after startAsyncExport there is a window where
visibleJobs is still empty, so neither the launcher nor the tray has
rendered yet. isVisible() returns false in that window, the click is
skipped, and the /Exporting|Exported/ assertion times out.

Fix: use locator.or() to wait until either the launcher button or the
tray popover becomes visible, then gate the click on which one won.
The tray popover is detected via its stable CSS class, requiring no
data-testid on the component.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

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

safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants