TEST-INFRA: [test-architecture] Fix AmbiguousStep error in Behave steps #1847

Open
opened 2026-04-02 23:57:26 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/test-arch-ambiguous-step-rendered-text
  • Commit Message: fix(tests): resolve AmbiguousStep collision for rendered-text step in tui_thought_block_steps and tui_first_run_steps
  • Milestone: v3.2.0
  • Parent Epic: #739

Background and Context

The unit_tests nox session is failing with a behave.step_registry.AmbiguousStep error, which prevents all unit tests from running. This is a blocking quality gate failure discovered during test infrastructure review.

Per CONTRIBUTING.md, the BDD test organisation guidelines require that step definitions are not duplicated across files. Steps used across multiple features must be consolidated into a shared, purpose-driven module.

Current Behavior

The following step definition is duplicated across two separate step files:

@then('the rendered text should contain "{text}"')

It is defined in both:

  • features/steps/tui_thought_block_steps.py
  • features/steps/tui_first_run_steps.py

When Behave loads all step modules simultaneously, it raises:

behave.step_registry.AmbiguousStep: @then('the rendered text should contain "{text}"') has already been defined in
  existing step @then('the rendered text should contain "{text}"') at features/steps/tui_first_run_steps.py:236

This causes nox -e unit_tests to crash immediately — zero tests run.

Expected Behavior

Each step pattern must be registered exactly once. The step definitions must be refactored so that each file uses a unique, domain-prefixed step pattern, or the shared step is moved to a common shared steps module. nox -e unit_tests must run to completion with no AmbiguousStep errors.

Acceptance Criteria

  • The @then('the rendered text should contain "{text}"') step pattern is no longer duplicated across step files
  • All .feature files that reference the old step pattern are updated to use the new domain-specific pattern
  • nox -e unit_tests runs to completion with no AmbiguousStep crash
  • nox -e coverage_report passes with coverage ≥ 97%

Supporting Information

  • Related broader issue: #1806 (553 ambiguous step patterns across the codebase)
  • Related UAT-filed issue: #1791 (same root cause, filed from UAT perspective)
  • CONTRIBUTING.md BDD Test Organisation Guidelines: "Group new steps with related ones" and "Keep shared steps in purpose-driven modules"

Subtasks

  • Identify the exact line numbers of the duplicate step in tui_thought_block_steps.py and tui_first_run_steps.py
  • Rename the step in tui_thought_block_steps.py to a domain-prefixed pattern (e.g., @then('the thought block rendered text should contain "{text}"'))
  • Update all .feature files referencing the old step pattern in thought-block scenarios to use the new pattern
  • Evaluate whether the step in tui_first_run_steps.py also needs a domain prefix; apply one if so
  • Update all .feature files referencing the old step pattern in first-run scenarios if renamed
  • Run behave --dry-run to confirm zero AmbiguousStep errors for this pattern
  • Run nox -e unit_tests to confirm the quality gate passes
  • Run full nox suite and confirm all sessions pass
  • Verify coverage >= 97% via nox -s coverage_report

Definition of Done

  • The duplicate @then('the rendered text should contain "{text}"') step pattern is eliminated
  • All affected .feature files updated to use the renamed step patterns
  • nox -e unit_tests runs to completion with no AmbiguousStep crash
  • All nox stages pass
  • Coverage >= 97%
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done

Automated by CleverAgents Bot
Supervisor: Test Infrastructure | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/test-arch-ambiguous-step-rendered-text` - **Commit Message**: `fix(tests): resolve AmbiguousStep collision for rendered-text step in tui_thought_block_steps and tui_first_run_steps` - **Milestone**: v3.2.0 - **Parent Epic**: #739 ## Background and Context The `unit_tests` nox session is failing with a `behave.step_registry.AmbiguousStep` error, which prevents **all** unit tests from running. This is a blocking quality gate failure discovered during test infrastructure review. Per `CONTRIBUTING.md`, the BDD test organisation guidelines require that step definitions are not duplicated across files. Steps used across multiple features must be consolidated into a shared, purpose-driven module. ## Current Behavior The following step definition is duplicated across two separate step files: ``` @then('the rendered text should contain "{text}"') ``` It is defined in both: - `features/steps/tui_thought_block_steps.py` - `features/steps/tui_first_run_steps.py` When Behave loads all step modules simultaneously, it raises: ``` behave.step_registry.AmbiguousStep: @then('the rendered text should contain "{text}"') has already been defined in existing step @then('the rendered text should contain "{text}"') at features/steps/tui_first_run_steps.py:236 ``` This causes `nox -e unit_tests` to crash immediately — zero tests run. ## Expected Behavior Each step pattern must be registered exactly once. The step definitions must be refactored so that each file uses a unique, domain-prefixed step pattern, or the shared step is moved to a common shared steps module. `nox -e unit_tests` must run to completion with no `AmbiguousStep` errors. ## Acceptance Criteria - [ ] The `@then('the rendered text should contain "{text}"')` step pattern is no longer duplicated across step files - [ ] All `.feature` files that reference the old step pattern are updated to use the new domain-specific pattern - [ ] `nox -e unit_tests` runs to completion with no `AmbiguousStep` crash - [ ] `nox -e coverage_report` passes with coverage ≥ 97% ## Supporting Information - Related broader issue: #1806 (553 ambiguous step patterns across the codebase) - Related UAT-filed issue: #1791 (same root cause, filed from UAT perspective) - `CONTRIBUTING.md` BDD Test Organisation Guidelines: "Group new steps with related ones" and "Keep shared steps in purpose-driven modules" ## Subtasks - [ ] Identify the exact line numbers of the duplicate step in `tui_thought_block_steps.py` and `tui_first_run_steps.py` - [ ] Rename the step in `tui_thought_block_steps.py` to a domain-prefixed pattern (e.g., `@then('the thought block rendered text should contain "{text}"')`) - [ ] Update all `.feature` files referencing the old step pattern in thought-block scenarios to use the new pattern - [ ] Evaluate whether the step in `tui_first_run_steps.py` also needs a domain prefix; apply one if so - [ ] Update all `.feature` files referencing the old step pattern in first-run scenarios if renamed - [ ] Run `behave --dry-run` to confirm zero `AmbiguousStep` errors for this pattern - [ ] Run `nox -e unit_tests` to confirm the quality gate passes - [ ] Run full `nox` suite and confirm all sessions pass - [ ] Verify coverage >= 97% via `nox -s coverage_report` ## Definition of Done - [ ] The duplicate `@then('the rendered text should contain "{text}"')` step pattern is eliminated - [ ] All affected `.feature` files updated to use the renamed step patterns - [ ] `nox -e unit_tests` runs to completion with no `AmbiguousStep` crash - [ ] All nox stages pass - [ ] Coverage >= 97% - [ ] A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation - [ ] The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly - [ ] The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done --- **Automated by CleverAgents Bot** Supervisor: Test Infrastructure | Agent: ca-new-issue-creator
freemo added this to the v3.2.0 milestone 2026-04-02 23:57:50 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: MoSCoW/Could Have — CI/test infrastructure improvement.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: MoSCoW/Could Have — CI/test infrastructure improvement. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#1847
No description provided.