From bc21a317becd7b1774af20d6442efde2126aabd3 Mon Sep 17 00:00:00 2001 From: CleverThis Date: Tue, 5 May 2026 00:21:37 +0000 Subject: [PATCH] fix(tui): correct cycle_persona test fixture to use non-cycleable default persona The step_register_cycleable_personas fixture was using the first cycleable persona (alpha, cycle_order=1) as the registry default. When cycle_persona was called with no active session, _resolve_default_name() resolved to alpha (which IS in the cycleable list at index 0), causing the implementation to advance to beta instead of starting from alpha as the test expected. Fix: use a dedicated non-cycleable default persona (cycle_order=0) so that _resolve_default_name() returns default (not in the cycleable list), making current_idx=-1 and cycling correctly starts from index 0 (alpha). This resolves the unit_tests CI failure introduced in the previous commit. --- features/steps/tui_persona_state_coverage_steps.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/features/steps/tui_persona_state_coverage_steps.py b/features/steps/tui_persona_state_coverage_steps.py index 381cea7d4..bc0fd4641 100644 --- a/features/steps/tui_persona_state_coverage_steps.py +++ b/features/steps/tui_persona_state_coverage_steps.py @@ -380,18 +380,27 @@ def step_verify_cycle_persona_result(context, expected): @given('cycleable personas "{names_csv}" are registered for session "{session_id}"') def step_register_cycleable_personas(context, names_csv, session_id): - """Register multiple cycleable personas with ascending cycle_order values.""" + """Register multiple cycleable personas with ascending cycle_order values. + + A non-cycleable "default" persona is used as the registry default so that + when no active persona has been set for the session, ``_resolve_default_name`` + returns "default" (not in the cycleable list). This means the first call to + ``cycle_persona`` starts from the beginning of the cycleable list (index 0). + """ names = [n.strip() for n in names_csv.split(",")] registry = MagicMock() personas = [ Persona(name=name, actor="ns/actor", cycle_order=idx + 1) for idx, name in enumerate(names) ] + # Non-cycleable default persona — ensures _resolve_default_name() returns a + # name that is NOT in the cycleable list, so cycling starts from index 0. + default_persona = Persona(name="default", actor="ns/actor", cycle_order=0) registry.list_personas.return_value = personas registry.get.side_effect = lambda name: next( (p for p in personas if p.name == name), None ) - registry.ensure_default.return_value = personas[0] + registry.ensure_default.return_value = default_persona registry.get_last_persona.return_value = None registry.set_last_persona = MagicMock() context.state = PersonaState(registry=registry)