Skip to content

v1.4.0 — Arrow-function POM support & trace injection fix

Choose a tag to compare

@cport1 cport1 released this 15 Apr 21:51
· 12 commits to main since this release

What changed

This release addresses the issues reported by Sravya on PR #3347: hallucinated POM methods, broken inline class output, and hallucinated navigation routes.

1. Arrow-function locator extraction (POM scanner)

The scanner now recognizes locators defined as arrow functions inside object literals — the pattern used by the Sophos CustomDashboards POM and many other codebases:

elements = {
  getWidgets: (): Locator => this.page.locator('[id*="widget"]'),
  getEditButton: (): Locator => this.page.getByTestId('edit-btn'),
  nested: {
    getDashboardGrid: (): Locator => this.page.locator('scwx-grid'),
  },
};

Previously the scanner found the class name but returned 0 locators for this pattern, causing the LLM to hallucinate element methods like elements.getCaseFlowChart() that don't exist.

2. Trace injection no longer breaks class bodies

The test.use({ trace: ... }) post-processor now stops scanning for imports at the first non-import code line. Previously, when the LLM emitted stray import statements mid-file (e.g., inside an inline class), the post-processor would insert test.use() inside the class body, producing invalid TypeScript.

3. Route extraction from POM classes

The scanner now extracts navigation URLs from POM goto() methods:

  • this.page.goto('/dashboards/custom') → route: /dashboards/custom
  • this.page.goto(path ?? '/default') → route: /default

These routes are injected into the LLM prompt so it uses real navigation paths instead of guessing from component/file names (e.g., /case-flow-expand-mode which doesn't exist).

Also included (from v1.3.1)

  • Anti-hallucination prompts are now conditional — only injected when the scanner actually finds artifacts
  • README documents Project Structure Discovery configuration

Upgrading

No configuration changes required. If you have custom pom_patterns, the new arrow-function extraction works automatically.

For projects with non-standard POM naming, set pom_patterns in your workflow:

pom_patterns: '**/*.po.ts,**/pages/**/*.ts'