test: add TDD bug-capture test for #1141 — session create persistence (#1144)
CI / build (push) Successful in 16s
CI / helm (push) Successful in 28s
CI / lint (push) Successful in 3m20s
CI / quality (push) Successful in 3m53s
CI / security (push) Successful in 4m9s
CI / typecheck (push) Successful in 4m15s
CI / benchmark-regression (push) Has been skipped
CI / integration_tests (push) Successful in 6m57s
CI / unit_tests (push) Successful in 7m3s
CI / docker (push) Successful in 1m30s
CI / e2e_tests (push) Successful in 11m37s
CI / coverage (push) Successful in 11m27s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Successful in 27m7s
CI / build (push) Successful in 16s
CI / helm (push) Successful in 28s
CI / lint (push) Successful in 3m20s
CI / quality (push) Successful in 3m53s
CI / security (push) Successful in 4m9s
CI / typecheck (push) Successful in 4m15s
CI / benchmark-regression (push) Has been skipped
CI / integration_tests (push) Successful in 6m57s
CI / unit_tests (push) Successful in 7m3s
CI / docker (push) Successful in 1m30s
CI / e2e_tests (push) Successful in 11m37s
CI / coverage (push) Successful in 11m27s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Successful in 27m7s
## Summary Adds TDD bug-capture coverage for bug #1141 (`session create` -> `session list` lifecycle) on metadata branch `tdd/m3-session-create-persist`. ### What changed - Added Behave bug-capture feature: `features/tdd_session_create_persist.feature` - Required tags: `@tdd_bug @tdd_bug_1141 @tdd_expected_fail` - Scenario path: `init --force --yes` -> `session list --format json` -> `session create` -> `session list --format json` - Added Behave step definitions: `features/steps/tdd_session_create_persist_steps.py` - Uses root CLI app (`cleveragents.cli.main:app`) for realistic command routing - Asserts expected list totals; underlying assertion intentionally fails while bug is present - Added Robot E2E bug-capture test: `robot/e2e/e2e_session_create_persist.robot` - Required tags: `E2E`, `tdd_expected_fail`, `tdd_bug`, `tdd_bug_1141` - Includes explicit in-file note to remove `tdd_expected_fail` when #1141 is fixed - Updated changelog (`CHANGELOG.md`, Unreleased) ### Notes - The issue subtask referenced `robot/e2e/e2e_session_lifecycle.robot`, which is not present on current `master`; equivalent E2E coverage is implemented in `robot/e2e/e2e_session_create_persist.robot`. - The branch was force-updated to remove stale merge-based history and keep an atomic, rebase-clean commit for this issue. ## Quality gates | Gate | Result | |---|---| | `nox -s lint` | ✅ pass | | `nox -s typecheck` | ✅ pass | | `nox -s unit_tests -- features/tdd_session_create_persist.feature` | ✅ pass (TDD inversion active; underlying assert fails) | | `nox -s integration_tests -- robot/e2e/e2e_session_create_persist.robot` | ✅ pass | | `nox -s e2e_tests` | ✅ pass | | `nox -s coverage_report` | ✅ pass (97.66173849218832%) | | `nox` (full default suite) | ✅ pass | ## Related issue Closes #1142 Reviewed-on: #1144 Reviewed-by: Jeffrey Phillips Freeman <jeffrey.freeman@cleverthis.com> Co-authored-by: Brent Edwards <brent.edwards@cleverthis.com> Co-committed-by: Brent Edwards <brent.edwards@cleverthis.com>
This commit was merged in pull request #1144.
This commit is contained in:
@@ -2,6 +2,12 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Added TDD bug-capture tests for bug #1141 — session create does not persist
|
||||
into subsequent session list output. Added a Behave scenario and Robot E2E
|
||||
test with required tags (`@tdd_bug`, `@tdd_bug_1141`, `@tdd_expected_fail` /
|
||||
`tdd_bug`, `tdd_bug_1141`, `tdd_expected_fail`) to assert create→list should
|
||||
show one session. The underlying assertion currently fails and is intentionally
|
||||
inverted until bug #1141 is fixed. (#1142)
|
||||
- Implemented `--mount` flag on `resource add container-instance`. Supports
|
||||
resource-reference mounts (`--mount local/api-repo:/workspace`) and
|
||||
host-path mounts (`--mount /var/config:/config:ro`). Multiple `--mount`
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
"""Step definitions for TDD Bug #1141 — session create does not persist.
|
||||
|
||||
Steps exercise the create-then-list round-trip through the real DI path.
|
||||
All step names use the ``tdd1141`` prefix to avoid ``AmbiguousStep``
|
||||
collisions with existing session create/list steps.
|
||||
|
||||
The shared ``Given a CLI runner using the real session DI path`` step
|
||||
(from ``tdd_session_shared_steps.py``) handles setup and cleanup:
|
||||
temp database, DI reset, structlog suppression, and cleanup registration.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
from behave import then, when
|
||||
from behave.runner import Context
|
||||
|
||||
from cleveragents.cli.main import app as main_app
|
||||
|
||||
|
||||
@when("I tdd1141 invoke init with force yes")
|
||||
def step_tdd1141_invoke_init(context: Context) -> None:
|
||||
"""Invoke ``init --force --yes`` via the root CLI app."""
|
||||
context.tdd1141_init_result = context.runner.invoke(
|
||||
main_app, ["init", "--force", "--yes"]
|
||||
)
|
||||
|
||||
|
||||
@then("the tdd1141 init should exit successfully")
|
||||
def step_tdd1141_init_exits_ok(context: Context) -> None:
|
||||
"""Assert init exits with code 0."""
|
||||
result = context.tdd1141_init_result
|
||||
assert result.exit_code == 0, (
|
||||
f"Expected init exit code 0, got {result.exit_code}.\nOutput:\n{result.output}"
|
||||
)
|
||||
|
||||
|
||||
@when("I tdd1141 invoke session create")
|
||||
def step_tdd1141_invoke_create(context: Context) -> None:
|
||||
"""Invoke ``session create`` through the root CLI app."""
|
||||
context.tdd1141_create_result = context.runner.invoke(
|
||||
main_app, ["session", "create"]
|
||||
)
|
||||
|
||||
|
||||
@then("the tdd1141 session create should exit successfully")
|
||||
def step_tdd1141_create_exits_ok(context: Context) -> None:
|
||||
"""Assert session create exits with code 0."""
|
||||
result = context.tdd1141_create_result
|
||||
assert result.exit_code == 0, (
|
||||
f"Expected session create exit code 0, got {result.exit_code}.\n"
|
||||
f"Output:\n{result.output}"
|
||||
)
|
||||
|
||||
|
||||
@when("I tdd1141 invoke session list with format json")
|
||||
def step_tdd1141_invoke_list_json(context: Context) -> None:
|
||||
"""Invoke ``session list --format json`` through the root CLI app."""
|
||||
context.tdd1141_list_result = context.runner.invoke(
|
||||
main_app, ["session", "list", "--format", "json"]
|
||||
)
|
||||
|
||||
|
||||
@then("the tdd1141 session list should exit successfully")
|
||||
def step_tdd1141_list_exits_ok(context: Context) -> None:
|
||||
"""Assert session list exits with code 0."""
|
||||
result = context.tdd1141_list_result
|
||||
assert result.exit_code == 0, (
|
||||
f"Expected session list exit code 0, got {result.exit_code}.\n"
|
||||
f"Output:\n{result.output}"
|
||||
)
|
||||
|
||||
|
||||
@then("the tdd1141 session list output should report total {count:d}")
|
||||
def step_tdd1141_list_contains_count(context: Context, count: int) -> None:
|
||||
"""Assert the JSON output reports the expected total session count."""
|
||||
output = context.tdd1141_list_result.output
|
||||
try:
|
||||
data = json.loads(output)
|
||||
except json.JSONDecodeError as exc:
|
||||
raise AssertionError(
|
||||
f"Session list output is not valid JSON:\n{output}"
|
||||
) from exc
|
||||
|
||||
actual = data.get("total")
|
||||
assert actual == count, (
|
||||
f"Expected 'total': {count} in session list output, got {actual!r}.\n"
|
||||
f"Full output:\n{output}"
|
||||
)
|
||||
@@ -0,0 +1,24 @@
|
||||
@tdd_expected_fail @tdd_issue @tdd_issue_1141
|
||||
Feature: TDD Bug #1141 — session create does not persist for session list
|
||||
As a developer
|
||||
I want to verify that a session created via `agents session create`
|
||||
appears in a subsequent `agents session list`
|
||||
So that the persistence bug is captured and will be caught by a regression test
|
||||
|
||||
The bug: `agents session create` succeeds (exit code 0) but the created
|
||||
session does not appear when `agents session list` is invoked immediately
|
||||
after. This test captures bug #1141 and intentionally keeps
|
||||
`@tdd_expected_fail` so CI passes while the bug remains unfixed.
|
||||
|
||||
Scenario: Init then create should make list total increase from 0 to 1
|
||||
Given a CLI runner using the real session DI path
|
||||
When I tdd1141 invoke init with force yes
|
||||
Then the tdd1141 init should exit successfully
|
||||
When I tdd1141 invoke session list with format json
|
||||
Then the tdd1141 session list should exit successfully
|
||||
And the tdd1141 session list output should report total 0
|
||||
When I tdd1141 invoke session create
|
||||
Then the tdd1141 session create should exit successfully
|
||||
When I tdd1141 invoke session list with format json
|
||||
Then the tdd1141 session list should exit successfully
|
||||
And the tdd1141 session list output should report total 1
|
||||
@@ -0,0 +1,20 @@
|
||||
*** Settings ***
|
||||
Documentation TDD Bug #1141 — session create does not persist session
|
||||
... for subsequent list. This test captures the bug described
|
||||
... in #1141. The tdd_expected_fail tag inverts the result so
|
||||
... CI passes while the bug is unfixed. Remove the tag when
|
||||
... the fix is merged.
|
||||
Resource common_e2e.resource
|
||||
Suite Setup E2E Suite Setup
|
||||
Suite Teardown E2E Suite Teardown
|
||||
|
||||
*** Test Cases ***
|
||||
Session Create Then List Shows Session
|
||||
[Documentation] Create a session and verify it appears in session list.
|
||||
[Tags] E2E tdd_expected_fail tdd_issue tdd_issue_1141
|
||||
Run CleverAgents Command init --force --yes
|
||||
${r1}= Run CleverAgents Command session list --format json
|
||||
Should Contain ${r1.stdout} "total": 0
|
||||
Run CleverAgents Command session create --format plain
|
||||
${r2}= Run CleverAgents Command session list --format json
|
||||
Should Contain ${r2.stdout} "total": 1
|
||||
Reference in New Issue
Block a user