Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions cmd/entire/cli/integration_test/issue_411_ended_idle_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//go:build integration

package integration

import (
"testing"

"github.com/entireio/cli/cmd/entire/cli/session"
"github.com/stretchr/testify/require"
)

// TestIssue411_EndedToIdle_PrepareCommitMsgAddsTrailer is the natural

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not reference issue numbers in the code? I reckon it would be better if we described what this is testing, instead of referencing the issue that describes what the test covers.
Thaaanks!

// reproduction for https://github.com/entireio/cli/issues/411:
// session-end (ENDED) → session-start (ENDED→IDLE) → new turn → git commit.
// prepare-commit-msg must still attach Entire-Checkpoint.
func TestIssue411_EndedToIdle_PrepareCommitMsgAddsTrailer(t *testing.T) {
t.Parallel()

env := NewFeatureBranchEnv(t)
sess := env.NewSession()

require.NoError(t, env.SimulateUserPromptSubmitWithPromptAndTranscriptPath(
sess.ID, "Initial work", sess.TranscriptPath))
env.WriteFile("first.go", "package main\n")
sess.CreateTranscript("Initial work", []FileChange{
{Path: "first.go", Content: "package main\n"},
})
require.NoError(t, env.SimulateStop(sess.ID, sess.TranscriptPath))

state, err := env.GetSessionState(sess.ID)
require.NoError(t, err)
require.NotNil(t, state)
require.Equal(t, session.PhaseIdle, state.Phase)
Comment thread
Copilot marked this conversation as resolved.

require.NoError(t, env.SimulateSessionEnd(sess.ID))
state, err = env.GetSessionState(sess.ID)
require.NoError(t, err)
require.NotNil(t, state)
require.Equal(t, session.PhaseEnded, state.Phase)
Comment thread
Copilot marked this conversation as resolved.

// Reported trigger: SessionStart after ENDED (ended → idle).
out := env.SimulateSessionStartWithOutput(sess.ID)
require.NoError(t, out.Err)
state, err = env.GetSessionState(sess.ID)
require.NoError(t, err)
require.NotNil(t, state)
require.Equal(t, session.PhaseIdle, state.Phase)
require.Nil(t, state.EndedAt)
Comment thread
Copilot marked this conversation as resolved.

require.NoError(t, env.SimulateUserPromptSubmitWithPromptAndTranscriptPath(
sess.ID, "Work after restart", sess.TranscriptPath))
env.WriteFile("second.go", "package main\n\nfunc Second() {}\n")
sess.CreateTranscript("Work after restart", []FileChange{
{Path: "second.go", Content: "package main\n\nfunc Second() {}\n"},
})
require.NoError(t, env.SimulateStop(sess.ID, sess.TranscriptPath))

env.GitCommitWithShadowHooks("Add second after ended→idle restart", "second.go")
cpID := env.GetCheckpointIDFromCommitMessage(env.GetHeadHash())
require.NotEmpty(t, cpID,
"prepare-commit-msg must add Entire-Checkpoint after ended→idle session restart (#411)")
}
Loading