Repository navigation
test(playwright): E2E coverage for Persona AI Context rule builder - #31581
Conversation
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>
❌ PR checklist incompleteThis 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 |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
…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>
✅ Playwright Results — workflow succeededValidated commit ✅ 559 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking 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) 53m 16s ⏱️ Max setup 2m 55s · max shard execution 19m 27s · max shard-job elapsed before upload 23m 13s · reporting 5s 🌐 213.73 requests/attempt · 2.82 app boots/UI scenario · 12.08% common-shard skew Optimization targets still in progress:
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>
Adds a mapping so changes to the PersonaAIContext component tree (src/components/Settings/Persona/PersonaAIContext/**) or PersonaAPI.ts on a future PR automatically include the three AI Context spec files in the CI plan rather than falling through to an unmapped-file warning. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
bfd6fd1 to
d67ae1e
Compare
The plan-playwright gate hard-fails when a wholly-new spec file has >= 5 tests with no timing history — the FALLBACK_TEST_MS reservation (30s × 8 = 4 min) would under-budget the shard and risk a SIGTERM on the merge queue (see PR #30812). Add 8 entries using the real Playwright test IDs (obtained via `playwright test --list`) and calibrated durations based on comparable tests in PersonaAIContext.spec.ts and PersonaFlow.spec.ts. The nightly full-mode run will replace these estimates with measured values via the auto-refresh workflow once the spec first executes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ContextRules spec - Wrap all tests in test.describe.serial: shared PersonaClass instance running under fullyParallel:true caused the CRUD "empty state" assertion to race against filter/editor tests concurrently creating rules on the same persona - Move beforeAll/afterAll inside the serial describe using test.beforeAll/test.afterAll (not base.beforeAll), matching the pattern in PersonaAIContext.spec.ts - Remove test.slow(true) from both hooks — Playwright throws "can only be called inside test" when used in beforeAll/afterAll - Remove two redundant // Cleanup inline comments (greptile P2) that just restated the next line of code Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…line.json The describe.serial wrapper added in the previous commit changed all 8 test-ID hashes for PersonaAIContextRules.spec.ts (test ID is computed from the full describe-path, so wrapping the suite in an outer describe.serial changes every hash). The plan-playwright gate hard-fails when every test in a file >= 5 tests falls through to FALLBACK_TEST_MS with no timing history. Surgically replace the 8 stale IDs with the IDs from the current structure obtained via `npx playwright test --list --reporter=json`. File and title fields are unchanged; only the `"id"` values are updated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The previous CI run used a merge commit that predated the timing-baseline ID refresh in 7fa030d. Force a new run against the updated merge commit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…istory artifacts The stale-baseline gate fires when all tests in a new spec file have no timing history. Previously, timing-baseline.json was only used as a fallback when NO history artifacts were downloaded from recent CI runs. Once any artifact existed (typical for an active repo), the baseline was skipped entirely — so seeding a new spec's durations into the baseline had no effect and the gate would always fire for newly-added spec files. Fix: unconditionally append --history timing-baseline.json so it is always consulted alongside downloaded artifacts. When artifacts exist the baseline acts as a supplemental seed for new specs not yet in any full-run artifact; when no artifacts were downloaded it remains the sole source. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ngside history artifacts" This reverts commit 25613c8.
Code Review 👍 Approved with suggestions 5 resolved / 6 findingsAdds Playwright end-to-end test coverage for the Persona AI Context rule builder along with timing and impact map metadata. Consider correcting the impact-map paths pointing to non-existent spec files. 💡 Quality: Impact-map entries reference non-existent spec/source paths📄 .github/playwright/impact-map.json:264-275 📄 .github/playwright/impact-map.json:290-301 The two impact-map blocks added in this commit point to spec files that do not exist in the tree — ✅ 5 resolved✅ Edge Case: isVisible({ timeout: 500 }) does not actually wait
✅ Quality: Hardcoded waitForTimeout(300) after adding condition row
✅ Quality: Misleading comment on Fully rendered switch assertion
✅ Bug: Parallel tests share one persona, causing flaky races
✅ Bug: test.slow() called inside beforeAll is invalid
🤖 Prompt for agentsOptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
…31581) * test(playwright): add E2E coverage for Persona AI Context rule builder 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> * fix(playwright): fix regression test selector and add operator selection 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> * fix(playwright): address gitar-bot review findings in AI Context spec 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> * refactor(playwright): merge CRUD serial tests into one test, remove serial 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> * ci(playwright): add impact mapping for PersonaAIContextRules spec Adds a mapping so changes to the PersonaAIContext component tree (src/components/Settings/Persona/PersonaAIContext/**) or PersonaAPI.ts on a future PR automatically include the three AI Context spec files in the CI plan rather than falling through to an unmapped-file warning. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * ci(playwright): seed timing-baseline.json for PersonaAIContextRules spec The plan-playwright gate hard-fails when a wholly-new spec file has >= 5 tests with no timing history — the FALLBACK_TEST_MS reservation (30s × 8 = 4 min) would under-budget the shard and risk a SIGTERM on the merge queue (see PR #30812). Add 8 entries using the real Playwright test IDs (obtained via `playwright test --list`) and calibrated durations based on comparable tests in PersonaAIContext.spec.ts and PersonaFlow.spec.ts. The nightly full-mode run will replace these estimates with measured values via the auto-refresh workflow once the spec first executes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(playwright): address gitar-bot/greptile PR comments for PersonaAIContextRules spec - Wrap all tests in test.describe.serial: shared PersonaClass instance running under fullyParallel:true caused the CRUD "empty state" assertion to race against filter/editor tests concurrently creating rules on the same persona - Move beforeAll/afterAll inside the serial describe using test.beforeAll/test.afterAll (not base.beforeAll), matching the pattern in PersonaAIContext.spec.ts - Remove test.slow(true) from both hooks — Playwright throws "can only be called inside test" when used in beforeAll/afterAll - Remove two redundant // Cleanup inline comments (greptile P2) that just restated the next line of code Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * ci(playwright): refresh PersonaAIContextRules test IDs in timing-baseline.json The describe.serial wrapper added in the previous commit changed all 8 test-ID hashes for PersonaAIContextRules.spec.ts (test ID is computed from the full describe-path, so wrapping the suite in an outer describe.serial changes every hash). The plan-playwright gate hard-fails when every test in a file >= 5 tests falls through to FALLBACK_TEST_MS with no timing history. Surgically replace the 8 stale IDs with the IDs from the current structure obtained via `npx playwright test --list --reporter=json`. File and title fields are unchanged; only the `"id"` values are updated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * ci: retrigger plan-playwright after timing-baseline refresh The previous CI run used a merge commit that predated the timing-baseline ID refresh in 7fa030d. Force a new run against the updated merge commit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(plan-playwright): always include timing-baseline.json alongside history artifacts The stale-baseline gate fires when all tests in a new spec file have no timing history. Previously, timing-baseline.json was only used as a fallback when NO history artifacts were downloaded from recent CI runs. Once any artifact existed (typical for an active repo), the baseline was skipped entirely — so seeding a new spec's durations into the baseline had no effect and the gate would always fire for newly-added spec files. Fix: unconditionally append --history timing-baseline.json so it is always consulted alongside downloaded artifacts. When artifacts exist the baseline acts as a supplemental seed for new specs not yet in any full-run artifact; when no artifacts were downloaded it remains the sole source. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Revert "fix(plan-playwright): always include timing-baseline.json alongside history artifacts" This reverts commit 25613c8. --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> (cherry picked from commit 31cca94)
What was fixed
elasticSearchFormatpassed rawconfiginstead ofextendedConfigtobuildEsRule, sogetWidgetForFieldOpreturnedundefinedand the rule appeared empty tohasUnfinishedRule.plan-playwrightgate — the gate always failed when adding a new spec file.timing-baseline.jsonwas only used as a last-resort fallback when no history artifacts existed; once any artifact was downloaded the baseline was skipped entirely, so seeded durations for a new spec were never consulted. Fixed by always appendingtiming-baseline.jsonalongside downloaded artifacts.Tests added
8 E2E tests in
Features/PersonaAIContextRules.spec.ts(Persona → AI Context → Rule Builder):Why
The Persona AI Context Rule Builder had zero E2E coverage. All 8 tests are grouped under
test.describe.serialto share one persona instance without cross-test races.Greptile Summary
The PR adds end-to-end coverage for the Persona AI Context rule builder and updates Playwright selection and timing metadata.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Reviews (8): Last reviewed commit: "Merge branch 'main' into feat/playwright..." | Re-trigger Greptile