Skip to content

test(core-components): cover use_double_brackets toggle in prompt template - #218

Merged
Victor-w-Madeira merged 3 commits into
mainfrom
feature/issue-213-prompt-template-double-brackets
May 11, 2026
Merged

test(core-components): cover use_double_brackets toggle in prompt template#218
Victor-w-Madeira merged 3 commits into
mainfrom
feature/issue-213-prompt-template-double-brackets

Conversation

@Victor-w-Madeira

Copy link
Copy Markdown
Collaborator

Summary

  • Adds prompt-template-double-brackets-regression with 5 @stable tests exercising the use_double_brackets toggle and the mustache code path on the Prompt Template component.
  • Cross-links the new spec from the existing prompt-template-component-regression.md doc and extends the §3.2 entries in QA-CHECKLIST.md.
  • All 5 tests pass locally against nightly (23s end-to-end); typecheck + ESLint pass with 0 errors and no new warnings.

Scope of coverage

# Test Validates
1 Toggle is exposed in the InspectionPanel with its upstream display name toggle_bool_use_double_brackets is visible after add; "Use Double Brackets" display name renders
2 Default toggle state is OFF; f-string mode extracts {var} and treats {{var}} as literal Saving Hello {single} and {{double}}! yields exactly one handle (single)
3 Enabling toggle switches parser to mustache mode; {{var}} creates handle and {var} is ignored Toggle ON → save same template → only double handle
4 Disabling toggle reverts to f-string mode and variables are re-extracted under the new parser Toggle ON → save {{name}} → toggle OFF → re-save → name handle drops → save {var}var handle appears
5 use_double_brackets value persists in the autosaved flow GET /api/v1/flows/{id} returns template.use_double_brackets.value === true after toggle

Notes on scope adjustments from issue #213

Two of the issue's original framings were revised during implementation to match how the UI actually behaves:

  • The info text and the "gated behind advanced options" framing for test 1 do not hold in practice — advanced=True only filters the field from the on-canvas node body via isCanvasVisible(); the InspectionPanel renders the bool toggle directly. The test instead asserts the display name (BoolInput(display_name=...)) is visible. The info string collapses into a hover-tooltip icon when the panel is narrow and is not asserted.
  • Test 4 was reframed: empirically the rendered handle set is not reconciled by the toggle alone — update_build_config runs, but the dynamic handles linger until the next save. The test verifies the contract end-to-end (toggle + save) rather than asserting toggle-alone re-extraction.

Both adjustments are documented in docs/core-components/prompt-template-double-brackets-regression.md under Notes.

Test plan

  • npm run typecheck — 0 errors
  • npm run lint — 0 errors, no new warnings from the new spec
  • npx playwright test tests/tests-automations/regression/core-components/prompt-template-double-brackets-regression.spec.ts — 5/5 pass against langflowai/langflow-nightly:latest
  • Forced-failure smoke check on test 1 confirms the assertion catches regressions (not always-pass)

Closes #213

…plate

Adds prompt-template-double-brackets-regression with 5 @stable tests
exercising the use_double_brackets toggle and the mustache code path
(InspectionPanel exposure, default f-string mode, toggle-on switch to
mustache, toggle-off revert with re-extraction on next save, and backend
persistence via GET /api/v1/flows/{id}). Cross-links from the existing
prompt-template spec doc and extends the §3.2 QA checklist.
- Scope display-name assertion with .first() to avoid Playwright strict-mode
  failure if "Use Double Brackets" ever appears elsewhere on the page.
- Add baseline check in test 5: poll the saved flow for
  use_double_brackets.value === false before toggling, so the test proves
  the round-trip, not just the final state.
- Surface test 4's mode-swap as an explicit test-level expect() on the
  modal-open testid pair, so the HTML report shows a real assertion in the
  "swaps back" step rather than only the helper's internal wait.
- Hoist readUseDoubleBrackets() to module scope to keep the response-status
  guard out of the test body (avoids playwright/no-conditional-in-test).
- Reword the spec doc's "core contracts" paragraph: drop the unconditional
  "real-time re-extraction" claim that no longer matches test 4's contract
  (re-extraction is verified on the next save, not on the toggle alone).

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.

Pull request overview

This PR adds end-to-end Playwright coverage for the Prompt Template component’s use_double_brackets toggle, ensuring both the default f-string parsing path and the mustache parsing path are exercised and documented within the langflow-e2e regression suite.

Changes:

  • Adds a new @stable regression spec covering toggle visibility, parser switching behavior, handle extraction semantics, and persisted use_double_brackets state via GET /api/v1/flows/{id}.
  • Updates QA documentation to cross-link the new coverage and marks the new scenarios as validated in the checklist.
  • Adds a dedicated regression doc describing the new spec’s intent, steps, and upstream dependencies.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/tests-automations/regression/core-components/prompt-template-double-brackets-regression.spec.ts Adds 5 serial @stable Playwright tests covering use_double_brackets behavior end-to-end, including backend persistence polling.
QA-CHECKLIST.md Adds five new §3.2 checklist entries pointing to the new spec.
docs/core-components/prompt-template-double-brackets-regression.md New documentation describing the new regression spec’s scenarios, steps, and dependencies.
docs/core-components/prompt-template-component-regression.md Cross-links the new spec from the existing Prompt Template regression doc.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +126 to +139
// `BoolInput(..., display_name="Use Double Brackets", ...)` declaration —
// asserting it catches an accidental rename at the source. Scoped to the
// toggle's enclosing field row so an unrelated occurrence of the string
// elsewhere on the page (a tooltip, a help string) cannot satisfy or
// break the assertion via Playwright strict mode. The `info` text is
// intentionally not asserted — the InspectionPanel collapses it into a
// hover-tooltip icon when the panel is narrow.
// `.first()` avoids Playwright strict-mode failures if "Use Double
// Brackets" ever shows up elsewhere (e.g. a future tooltip or help
// string). The toggle's existence was already asserted in the previous
// step, so this assertion is solely about the label string.
await expect(
page.getByText("Use Double Brackets").first(),
).toBeVisible();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in commit 9a2e05f. The bare .first() was indeed not a real scope — the comment claimed scoping while the implementation didn't deliver it. The fix anchors the assertion on the toggle via an XPath ancestor walk:

const labelOwner = page
  .getByTestId("toggle_bool_use_double_brackets")
  .locator("xpath=ancestor::*[contains(., 'Use Double Brackets')][1]");
await expect(labelOwner).toBeVisible();

If the label is renamed and no ancestor of the toggle has the text in its subtree, the locator resolves to zero elements and toBeVisible() fails — which is the regression we want to catch. Force-fail confirmed (substituted a placeholder string and the assertion failed cleanly with element(s) not found).

…opilot)

Replaces `getByText("Use Double Brackets").first()` with an XPath ancestor
walk from the toggle element. The previous version would have passed if
"Use Double Brackets" appeared anywhere else on the page (a future tooltip,
help text, or stale element kept after the label was removed); the new
version resolves to zero elements and fails when the label-toggle wiring
regresses, which is what the test exists to detect.

Verified by force-fail: the toggle has no ancestor whose subtree contains
a placeholder string, so the locator returns nothing and toBeVisible fails
cleanly.
@Victor-w-Madeira
Victor-w-Madeira merged commit a28152d into main May 11, 2026
2 checks passed
@Victor-w-Madeira
Victor-w-Madeira deleted the feature/issue-213-prompt-template-double-brackets branch May 11, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(core-components): cover use_double_brackets toggle in prompt template

2 participants