Skip to content

test(playwright): E2E coverage for Persona AI Context rule builder - #31581

Open
anuj-kumary wants to merge 4 commits into
mainfrom
feat/playwright-persona-ai-context-rules
Open

test(playwright): E2E coverage for Persona AI Context rule builder#31581
anuj-kumary wants to merge 4 commits into
mainfrom
feat/playwright-persona-ai-context-rules

Conversation

@anuj-kumary

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

Copy link
Copy Markdown
Member

Summary

Root cause (documented in test)

elasticSearchFormat in QueryBuilderElasticsearchFormatUtils.js passed the raw config instead of extendedConfig to buildEsRule in the single-value branch. This caused getWidgetForFieldOp to return undefined, so the rule appeared "empty" to hasUnfinishedRule, which returned true and blocked save. The fix (PR #31565) always passes extendedConfig.

Why the existing unit tests didn't catch it

All hasUnfinishedRule unit tests used extension.* fields, which take the buildExtensionQuery shortcut path before widget resolution is attempted — so the broken single-value path was never exercised.

Tests added

Group Test
Rule CRUD (single test with steps) Empty state → create rule → edit name → delete → empty state
Filter validation Incomplete condition blocks save with error message
Filter validation Regression #31564 — Description Contains allows save
Filter validation Entity-type switch clears incomplete filter, unblocks save
Filter validation Duplicate rule name rejected
Rule editor fields Max assets clamps > 1000 → 1000 on blur
Rule editor fields Always in context and Fully rendered toggles are interactable
Rule editor fields Knowledge entity type forces Fully rendered on and disables it

Test plan

  • CI Playwright suite runs the new spec without failures
  • Manually verify on a deployed environment: create a rule with Description Contains "test" → should save without the filter error appearing

Adds 11 Playwright tests covering the full rule CRUD flow, filter
validation, and individual field behaviours for the AI Context tab in
Persona settings.

The most important addition is a regression test for #31564: before
PR #31565 a fully-completed single-value condition (e.g. Description
Contains "…") was incorrectly rejected with the "unfinished condition"
error because `elasticSearchFormat` passed raw `config` instead of
`extendedConfig` to `buildEsRule`, causing widget resolution to fail
and `hasUnfinishedRule` to return true.

Tests added:
- Rule CRUD serial group: empty state, create, edit, delete
- Filter validation serial group: incomplete condition blocks save,
  regression #31564 (Description Contains allows save), entity-type
  switch clears filter, duplicate name rejected
- Rule editor fields: max-assets clamping, toggle visibility,
  knowledge entity-type forces Fully rendered on

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

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 15, 2026
@github-actions

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 15, 2026
@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 15, 2026
…ion step

Live browser testing revealed two issues with the Persona AI Context
regression spec:

1. `page.locator('.rule').first()` finds the GROUP container which can
   be hidden in some builds — go directly to `.rule--field .ant-select`
   at page level instead.

2. The Description field uses `match_phrase` operators. The text widget
   (`.rule--widget--TEXT`) only renders after an operator is selected.
   Add an explicit "Contains" operator selection step so the input is
   available before we try to fill it.

Also: add `.first()` guard on the Fully rendered switch locator in the
knowledge-entity-type test (multiple elements can match) and add a note
that react-aria Switch stores state in the checked property, not
aria-checked.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Three issues raised in PR #31581 review:

1. `openAddRuleDrawer`: `isVisible({ timeout: 500 })` silently ignores
   the timeout and returns synchronously — replace with
   `emptyBtn.or(headerBtn).first().waitFor()` so we genuinely wait,
   then branch on `isVisible()` after the element is confirmed present.

2. `waitForTimeout(300)` sleeps after clicking add-context-condition are
   flaky: replaced with `page.locator('.rule--field .ant-select').first()
   .waitFor({ state: 'visible' })` at all three call sites.

3. Comment on the Fully rendered switch assertion said "use .isChecked()"
   but the code uses Playwright's `toBeChecked()` matcher — reworded to
   accurately describe why the property-based check is needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🔴 Playwright Results — workflow failed

Validated commit 928bf78e64f3a950814afae5164dfe08083331c4 in Playwright run 31899552857, attempt 1.

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

Pipeline and setup failures (5)

  • Duration-aware shard planning finished with status failure.
  • Fixture cache restoration finished with status skipped.
  • Seeded fixture preparation finished with status skipped.
  • The Playwright shard matrix was unexpectedly skipped.
  • No expected Playwright shards were declared.

Performance

⚪ Performance metrics unavailable; see the CI and reporting failures above.

Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky

📦 Download artifacts

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

…erial from filter validation

CRUD tests (empty→create→edit→delete) are an inherently sequential
flow where edit and delete depend on state created by earlier steps.
Collapsing them into a single test with test.step() makes the
dependency explicit and atomic: a step failure aborts only that test
rather than silently skipping later ones via describe.serial.

Filter validation tests are each self-contained (each creates and
discards its own rule within a single test body), so describe.serial
was unnecessary. Removing it ensures a failure in the "incomplete
condition" test never prevents the regression test (#31564) from
running.

Also replace waitForTimeout(300) with waitFor({ state: 'visible' })
on the condition-row field selector to eliminate timing-based flakes.

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

gitar-bot Bot commented Aug 15, 2026

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

Adds comprehensive Playwright E2E test coverage for the Persona AI Context rule builder, including a regression test for #31564. Addressed review findings regarding flaky assertions and visibility checks.

✅ 3 resolved
Edge Case: isVisible({ timeout: 500 }) does not actually wait

📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/PersonaAIContextRules.spec.ts:89-95
In openAddRuleDrawer, emptyBtn.isVisible({ timeout: 500 }).catch(() => false) cannot wait: Playwright's locator.isVisible() ignores the timeout option and returns synchronously, and it does not throw, so the .catch() is dead code. If the empty-state button hasn't rendered the instant this runs, the helper silently falls through to clicking the header button (which is absent in the empty state) and the drawer never opens. It happens to work today only because navigateToAIContextTab awaits loaders first. Use an assertion that genuinely waits, e.g. await emptyBtn.or(headerBtn).first().waitFor() then branch, or const useEmpty = await emptyBtn.count() > 0 after an explicit waitFor.

Quality: Hardcoded waitForTimeout(300) after adding condition row

📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/PersonaAIContextRules.spec.ts:234 📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/PersonaAIContextRules.spec.ts:273 📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/PersonaAIContextRules.spec.ts:320
Fixed page.waitForTimeout(300) sleeps after clicking add-context-condition are flaky and slow: on a loaded CI runner the row may not be interactive within 300ms, and on a fast run the sleep is wasted. Prefer waiting on a concrete signal (e.g. await expect(page.locator('.rule').first()).toBeVisible()) instead of an arbitrary delay.

Quality: Misleading comment on Fully rendered switch assertion

📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/PersonaAIContextRules.spec.ts:435-437
The comment at line 435 says "react-aria Switch: use .isChecked()" but the code below uses Playwright's toBeChecked()/toBeDisabled() matchers, not an .isChecked() call. This can confuse future maintainers. Reword the comment to reflect that toBeChecked() is used (or remove the reference to .isChecked()).

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