Skip to content

Refactor ontology playwright test - #31661

Open
anuj-kumary wants to merge 11 commits into
mainfrom
ontology-playwright
Open

Refactor ontology playwright test#31661
anuj-kumary wants to merge 11 commits into
mainfrom
ontology-playwright

Conversation

@anuj-kumary

@anuj-kumary anuj-kumary commented Aug 18, 2026

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #

I worked on ... because ...

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

High-level design:

N/A — small change.

Tests:

Use cases covered

Unit tests

Backend integration tests

Ingestion integration tests

Playwright (UI) tests

Manual testing performed

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
  • For UI changes: I attached a screen recording and/or screenshots above.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

Summary by Gitar

  • Test Utilities:
    • Updated createApiContext and disposeApiContext in ontology playwright utils to use performAdminLogin instead of browser pages.
  • Playwright Tests:
    • Refactored ontology and glossary tests to use the updated API context helper without opening unnecessary browser pages.

This will update automatically on new commits.

Greptile Summary

The PR refactors ontology Playwright tests to use fresh, independently owned admin API contexts and per-test entity lifecycles.

  • Replaces browser-page authentication with createAdminApiContext.
  • Delegates context cleanup to the returned afterAction callback.
  • Moves ontology test data creation and cleanup into per-test hooks.
  • Adds deterministic filtering and navigation behavior to reduce test flakiness.

Confidence Score: 5/5

The PR appears safe to merge.

The previously reported shared API-context disposal failure is fixed because the helper now creates a fresh context for each call and invokes the matching ownership-aware cleanup callback; no blocking failure remains.

Important Files Changed

Filename Overview
openmetadata-ui/src/main/resources/ui/playwright/utils/ontologyExplorer.ts The helper now creates fresh admin API contexts and delegates disposal to their ownership-aware cleanup callback, resolving the previously reported shared-context disposal issue.
openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/OntologyExplorer.spec.ts Test data setup and cleanup now run per test using fresh API contexts and guarded entity deletion.
openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/OntologyExplorerIntegration.spec.ts Integration scenarios now use per-test entities and deterministic re-navigation after API relation changes.
openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/OntologyExplorerFilters.spec.ts Filter tests now use per-test entities and search dropdowns by the generated glossary name rather than pagination position.
openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Glossary/GlossaryTermRelationsGraph.spec.ts Relations-graph fixtures now use isolated per-test entities and independently owned API contexts.

Sequence Diagram

sequenceDiagram
  participant Test as Playwright Test
  participant Helper as createApiContext
  participant Admin as createAdminApiContext
  participant API as Fresh API Context
  Test->>Helper: createApiContext(browser)
  Helper->>Admin: createAdminApiContext()
  Admin->>API: create independently owned context
  Admin-->>Helper: apiContext + afterAction
  Helper-->>Test: apiContext + afterAction
  Test->>API: seed or clean test entities
  Test->>Helper: disposeApiContext(afterAction, apiContext)
  Helper->>Admin: afterAction()
  Admin->>API: dispose owned contexts
Loading

Reviews (8): Last reviewed commit: "fix(e2e): add test.slow() to Relation Sy..." | Re-trigger Greptile

@anuj-kumary anuj-kumary self-assigned this Aug 18, 2026
@anuj-kumary anuj-kumary added the UI UI specific issues label Aug 18, 2026
@anuj-kumary anuj-kumary added the safe to test Add this label to run secure Github workflows on PRs label Aug 18, 2026
@anuj-kumary anuj-kumary added the skip-pr-checks Bypass PR metadata validation check label Aug 18, 2026
Comment thread openmetadata-ui/src/main/resources/ui/playwright/utils/ontologyExplorer.ts Outdated
@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🔴 Playwright Results — workflow failed

Validated commit 5a0d3210cbe445d31fbbf7bc42a9726411999dff in Playwright run 32104679331, attempt 1.

✅ 693 passed · ❌ 1 failed · 🟡 0 flaky · ⏭️ 0 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) 48m 49s

⏱️ Max setup 3m 24s · max shard execution 20m 16s · max shard-job elapsed before upload 23m 44s · reporting 4s

🌐 195.85 requests/attempt · 2.48 app boots/UI scenario · 8.88% common-shard skew

Optimization targets still in progress:

  • Application boot ratio was 2.48 per UI scenario (1776 boots / 716 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 126 0 0 0 0 0
✅ Shard chromium-02 155 0 0 0 0 0
✅ Shard chromium-03 131 0 0 0 0 0
🔴 Shard chromium-04 129 1 0 0 0 0
✅ Shard data-asset-rules-01 61 0 0 0 0 0
✅ Shard domain-isolation-01 14 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0

Genuine Failures (failed on all attempts)

Features/OntologyExplorerIntegration.spec.tsshould reflect relation add and remove in the graph (shard chromium-04)
�[31mTest timeout of 60000ms exceeded.�[39m

📦 Download artifacts

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

anuj-kumary and others added 4 commits August 18, 2026 09:42
…er context disposal

createApiContext now calls createAdminApiContext() to get an independently
owned context per suite. The previous performAdminLogin path returned the
shared worker-scoped APIRequestContext; disposeApiContext then called
apiContext.dispose() on it, closing the worker context and causing every
subsequent suite's afterAll cleanup to fail with "Target page, context or
browser has been closed". Also fixes the double-dispose: afterAction from
createAdminApiContext already tears down both the login context and the
API context, so the unconditional apiContext.dispose() before the branch
is removed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The refresh button intermittently clears the glossary filter state due
to a timing race between the WebSocket auto-update event (from the API
relation add/remove) and the manual reload cycle. When the race goes
wrong, the graph reloads without the filter and stats show
"0 Terms0 Relations0 Isolated" instead of the expected counts.

Replace both refresh→waitForGraphLoaded sequences in the Relation Sync
test with navigateAndFilterByGlossary, which always fetches fresh data
with the filter correctly applied. The test still verifies that API
changes are reflected in the graph — just via a deterministic path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ght specs

Move entity setup from beforeAll/afterAll (shared across tests) to
beforeEach/afterEach (fresh per test). Each test now creates its own
glossary + terms, runs, and deletes them — eliminating all cross-test
shared-state failure modes:

- No cascade failure when one test's afterAll disposes a context used
  by another test's beforeAll
- No cross-worker WebSocket delete-toast contamination (createApiContext
  is pure HTTP — no browser page, no WS session opened)
- No stats-assertion drift from other parallel workers' entities (each
  test filters by its own UUID-scoped glossary ID)

Also fixes OntologyExplorerFilters.spec.ts line ~197: the glossary
dropdown was opened without searching first, risking a pagination miss
on a busy AUT. Now searches by name before asserting visibility —
consistent with the pattern already used in the Dropdown Search tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
anuj-kumary and others added 5 commits August 18, 2026 10:51
…ilures

If beforeEach throws before all entity assignments complete (e.g. the
createApiContext call itself fails on the first test run), the module-level
`let` variables remain undefined. Playwright still runs afterEach, and
calling deleteEntities(apiContext, undefined, ...) or
undefined.delete(apiContext) would throw — masking the original failure.

Fix all 8 ontology spec files:
- Wrap deleteEntities() calls in `if (primaryEntity)` guards
- Use `?.delete()` optional chaining on GlossaryTermRelationsGraph direct
  .delete() calls
- Split multi-glossary afterEach blocks by glossary group so partial
  creation still cleans up the entities that did get created

Addresses gitar-bot review finding on PR #31661.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The "should reflect relation add and remove in the graph" test performs
three navigateAndFilterByGlossary calls, each of which internally calls
waitForGraphLoaded twice (up to 30 s each). Three navigations × two
waits = up to 180 s of graph-loading overhead — well beyond the default
60 s test budget, causing CI to timeout at the second navigation.

Fix: call test.slow() at the start of the test body to triple the
timeout to 180 s.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gitar-bot

gitar-bot Bot commented Aug 18, 2026

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

Refactors ontology Playwright tests to use per-test entity isolation and fresh API contexts, while guarding afterEach cleanup against partial beforeEach failures. No issues found.

✅ 1 resolved
Edge Case: afterEach may deref undefined entities if beforeEach fails midway

📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Glossary/GlossaryTermRelationsGraph.spec.ts:73-87 📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/OntologyExplorerFilters.spec.ts:62-74
The entities are now module-scoped let vars assigned inside beforeEach. If a beforeEach throws partway through creation (e.g. glossary2/glossaryY not yet assigned), Playwright still runs afterEach, which then calls deleteEntities(...)/glossaryY.delete(...) on undefined and throws — masking the original setup failure and potentially leaving created entities orphaned. Consider guarding cleanup with null checks (e.g. if (glossaryY) await glossaryY.delete(...)) so teardown is resilient to partial setup.

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

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.

1 participant