test: dedupe DefaultSessionReducerTest into one file
Two copies had drifted — the core:sessions one and the testing:projections one — and one had rotted into asserting the ACTIVE-forever bug as correct. Port the unique boundProfile + freestyle-planning cases into the comprehensive projections copy and delete the core:sessions duplicate.
This commit is contained in:
@@ -11,8 +11,10 @@ import com.correx.core.events.types.SessionId
|
||||
import com.correx.core.events.types.StageId
|
||||
import com.correx.core.events.types.TransitionId
|
||||
import com.correx.core.events.events.AgentInstructionsBoundEvent
|
||||
import com.correx.core.events.events.OperatorProfileBoundEvent
|
||||
import com.correx.core.events.events.ProjectProfileBoundEvent
|
||||
import com.correx.core.sessions.BoundAgentInstructions
|
||||
import com.correx.core.sessions.BoundProfile
|
||||
import com.correx.core.sessions.BoundProjectProfile
|
||||
import com.correx.core.sessions.BoundWorkspace
|
||||
import com.correx.core.sessions.DefaultSessionReducer
|
||||
@@ -378,6 +380,72 @@ class DefaultSessionReducerTest {
|
||||
status = SessionStatus.CREATED
|
||||
)
|
||||
|
||||
@Test
|
||||
fun `OperatorProfileBoundEvent populates boundProfile`() {
|
||||
val result = reducer.reduce(
|
||||
state = activeState(),
|
||||
event = stored(
|
||||
sessionId = sessionId,
|
||||
payload = OperatorProfileBoundEvent(
|
||||
sessionId = sessionId,
|
||||
about = "Expert Kotlin engineer",
|
||||
approvalMode = "auto",
|
||||
preferredModels = listOf("model-x"),
|
||||
conventions = listOf("no var"),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
val profile = result.boundProfile
|
||||
assertEquals("Expert Kotlin engineer", profile?.about)
|
||||
assertEquals("auto", profile?.approvalMode)
|
||||
assertEquals(listOf("model-x"), profile?.preferredModels)
|
||||
assertEquals(listOf("no var"), profile?.conventions)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `unrelated event leaves boundProfile unchanged`() {
|
||||
val state = activeState().copy(
|
||||
boundProfile = BoundProfile(
|
||||
about = "original",
|
||||
approvalMode = "",
|
||||
preferredModels = emptyList(),
|
||||
conventions = emptyList(),
|
||||
),
|
||||
)
|
||||
val result = reducer.reduce(
|
||||
state = state,
|
||||
event = stored(
|
||||
sessionId = sessionId,
|
||||
payload = SessionWorkspaceBoundEvent(
|
||||
sessionId = sessionId,
|
||||
workspaceRoot = "/ws",
|
||||
allowedPaths = listOf("/ws"),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
assertEquals("original", result.boundProfile?.about)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `WorkflowCompletedEvent for freestyle planning stays ACTIVE (hands off to execution)`() {
|
||||
val result = reducer.reduce(
|
||||
state = activeState(),
|
||||
event = stored(
|
||||
sessionId = sessionId,
|
||||
payload = WorkflowCompletedEvent(
|
||||
sessionId,
|
||||
terminalStageId = StageId("architect"),
|
||||
totalStages = 2,
|
||||
workflowId = "freestyle_planning",
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
assertEquals(SessionStatus.ACTIVE, result.status)
|
||||
}
|
||||
|
||||
private fun activeState() =
|
||||
SessionState(
|
||||
status = SessionStatus.ACTIVE
|
||||
|
||||
Reference in New Issue
Block a user