Context
Four sibling specs under tests/tests-automations/regression/core-components/ duplicate the same helpers:
prompt-template-component-regression.spec.ts
prompt-template-double-brackets-regression.spec.ts
prompt-template-invalid-patterns-regression.spec.ts
prompt-template-invalid-mustache-patterns-regression.spec.ts
Duplicated pieces (byte-identical or near-identical):
addPromptComponent(page) — bootstrap, click blank-flow, search/add Prompt Template, adjustScreenView, assert one node on canvas.
dynamicHandlesLocator(page) — CSS locator for the dynamic input handles ([data-testid^="handle-prompt template-shownode-"][data-testid$="-left"]).
errorToastLocator(page) — .error-build-message CSS locator (now duplicated in both invalid-patterns specs).
- Mustache-mode entry helper —
flipDoubleBrackets(page, true) in the double-brackets spec and enableMustacheMode(page) in the mustache invalid-patterns spec do the same job (click toggle_bool_use_double_brackets, wait for button_open_mustache_prompt_modal).
- Modal-fill helpers — four slightly different shapes:
setPromptTemplate(page, value) in the component spec (waits for textarea hidden after save).
setPromptTemplate(page, value, mode) in the double-brackets spec (parameterised on "fstring"/"mustache").
fillAndSavePromptTemplate(page, value) in the f-string invalid-patterns spec (does NOT wait for hide, since the modal stays open on error).
fillAndSaveMustacheTemplate(page, value) in the mustache invalid-patterns spec (mustache textarea + does NOT wait for hide).
This was flagged in the review of PR #220:
Three copies of the same helper across one feature folder is a smell. A tests/helpers/ui/prompt-template.ts module would centralize this — but do it in a small follow-up that touches all three specs together so the diff stays reviewable.
Per project convention, shared-helper extraction is its own PR — risk and impact must be evaluated up front (a regression in addPromptComponent would fail all four specs at once).
Scope
Extract a single helper module under tests/helpers/ui/prompt-template.ts that exposes:
addPromptComponent(page: Page): Promise<void>
dynamicHandlesLocator(page: Page): Locator
errorToastLocator(page: Page): Locator
setUseDoubleBrackets(page: Page, enabled: boolean): Promise<void> — unifies flipDoubleBrackets/enableMustacheMode; clicks the toggle and waits for the matching modal-open testid to mount.
fillPromptTemplate(page: Page, value: string, opts?: { mode?: "fstring" | "mustache"; waitForHide?: boolean }): Promise<void> — unifies the four variants. waitForHide defaults to true (success path); set to false when submitting invalid input that keeps the modal open. mode defaults to "fstring".
Refactor the four specs to import from the new module. Verify:
npm run typecheck clean
npm run lint clean
- All four specs still pass against a live Langflow instance
- No change to test behavior — same
test() count, same assertions, same tags
- HTML report renders the same
test.step() labels
Out of scope
- Adding or removing tests (this is a pure refactor)
- Changing the assertions or selectors
- Extracting helpers from other sibling specs (e.g.
chat-input-*, api-request-*, loop-component-*)
Deliverables
Context
Four sibling specs under
tests/tests-automations/regression/core-components/duplicate the same helpers:prompt-template-component-regression.spec.tsprompt-template-double-brackets-regression.spec.tsprompt-template-invalid-patterns-regression.spec.tsprompt-template-invalid-mustache-patterns-regression.spec.tsDuplicated pieces (byte-identical or near-identical):
addPromptComponent(page)— bootstrap, clickblank-flow, search/add Prompt Template,adjustScreenView, assert one node on canvas.dynamicHandlesLocator(page)— CSS locator for the dynamic input handles ([data-testid^="handle-prompt template-shownode-"][data-testid$="-left"]).errorToastLocator(page)—.error-build-messageCSS locator (now duplicated in both invalid-patterns specs).flipDoubleBrackets(page, true)in the double-brackets spec andenableMustacheMode(page)in the mustache invalid-patterns spec do the same job (clicktoggle_bool_use_double_brackets, wait forbutton_open_mustache_prompt_modal).setPromptTemplate(page, value)in the component spec (waits for textarea hidden after save).setPromptTemplate(page, value, mode)in the double-brackets spec (parameterised on"fstring"/"mustache").fillAndSavePromptTemplate(page, value)in the f-string invalid-patterns spec (does NOT wait for hide, since the modal stays open on error).fillAndSaveMustacheTemplate(page, value)in the mustache invalid-patterns spec (mustache textarea + does NOT wait for hide).This was flagged in the review of PR #220:
Per project convention, shared-helper extraction is its own PR — risk and impact must be evaluated up front (a regression in
addPromptComponentwould fail all four specs at once).Scope
Extract a single helper module under
tests/helpers/ui/prompt-template.tsthat exposes:addPromptComponent(page: Page): Promise<void>dynamicHandlesLocator(page: Page): LocatorerrorToastLocator(page: Page): LocatorsetUseDoubleBrackets(page: Page, enabled: boolean): Promise<void>— unifiesflipDoubleBrackets/enableMustacheMode; clicks the toggle and waits for the matching modal-open testid to mount.fillPromptTemplate(page: Page, value: string, opts?: { mode?: "fstring" | "mustache"; waitForHide?: boolean }): Promise<void>— unifies the four variants.waitForHidedefaults totrue(success path); set tofalsewhen submitting invalid input that keeps the modal open.modedefaults to"fstring".Refactor the four specs to import from the new module. Verify:
npm run typecheckcleannpm run lintcleantest()count, same assertions, same tagstest.step()labelsOut of scope
chat-input-*,api-request-*,loop-component-*)Deliverables
tests/helpers/ui/prompt-template.tswith the five exports above + JSDoctest()count, same assertions)