test(enable): update import-offer integration tests for non-interactive behavior · Entire

test(enable): update import-offer integration tests for non-interactive behavior

9c707bf→main · computermode·1w ago·1 file·+29 added/-8 removed

The offer no longer auto-imports in a non-interactive enable without --yes. Update the integration tests accordingly:

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

Sessions

01KWWH7M069H3SETEESW3DVBE8 View transcript

Changes

1

28 unmodified lines

29
30
31
32
32
33
34
35
2 unmodified lines

38
39
40
41
42
43
41
42
43
44
45
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
11 unmodified lines

87
88
89
69
70
90
91
92
93
94
74
95
96
97
98

28 unmodified lines

return env
}

func TestEnableOffersImport_FirstRunAutoImports(t *testing.T) {
func TestEnableOffersImport_FirstRunAutoImportsWithYes(t *testing.T) {
    t.Parallel()
    env := freshRepoEnv(t)

2 unmodified lines

filepath.Join(env.ClaudeProjectDir, "sess1.jsonl"),
        []byte(claudeImportFixture), 0o644))

// First-time enable in a non-interactive (no-TTY) subprocess auto-imports the
    // selected agent's discoverable history.
    out := env.RunCLI("enable", "--agent", "claude-code", "--telemetry=false")
    // --yes ("accept all defaults") auto-imports the selected agent's
    // discoverable history on first-time enable, even non-interactively.
    out := env.RunCLI("enable", "--agent", "claude-code", "--yes", "--telemetry=false")
    require.Contains(t, out, "Ready.", "enable should complete; got: %s", out)
    require.Contains(t, out, "Imported 2 turn(s)", "first-time enable should import discovered history; got: %s", out)
    require.Contains(t, out, "Imported 2 turn(s)", "first-time enable --yes should import discovered history; got: %s", out)

// The imported turns are real checkpoints on the v1 metadata branch.
    require.Contains(t, env.RunCLI("checkpoint", "list"), "[imported]",
        "imported checkpoints should be listed")
}

func TestEnableOffersImport_NonInteractiveWithoutYesHints(t *testing.T) {
    t.Parallel()
    env := freshRepoEnv(t)

// Pre-existing Claude history for this repo.
    require.NoError(t, os.WriteFile(
        filepath.Join(env.ClaudeProjectDir, "sess1.jsonl"),
        []byte(claudeImportFixture), 0o644))

// A non-interactive (no-TTY) enable without --yes must NOT silently import;
    // it points at the manual command instead.
    out := env.RunCLI("enable", "--agent", "claude-code", "--telemetry=false")
    require.Contains(t, out, "Ready.", "enable should complete; got: %s", out)
    require.NotContains(t, out, "Imported", "non-interactive enable without --yes must not auto-import; got: %s", out)
    require.Contains(t, out, "entire import", "should point at the manual import command; got: %s", out)

// Nothing was written to the checkpoint metadata branch.
    require.NotContains(t, env.RunCLI("checkpoint", "list"), "[imported]",
        "no checkpoints should be imported without --yes")
}

func TestEnableOffersImport_NoHistoryIsSilent(t *testing.T) {
    t.Parallel()
    env := freshRepoEnv(t)
11 unmodified lines

filepath.Join(env.ClaudeProjectDir, "sess1.jsonl"),
        []byte(claudeImportFixture), 0o644))

// First enable imports.
    first := env.RunCLI("enable", "--agent", "claude-code", "--telemetry=false")
    // First enable imports (--yes accepts the import).
    first := env.RunCLI("enable", "--agent", "claude-code", "--yes", "--telemetry=false")
    require.Contains(t, first, "Imported 2 turn(s)", "first enable should import; got: %s", first)

// Re-enable must not re-offer or re-import, even though history is still present.
    second := env.RunCLI("enable", "--agent", "claude-code", "--telemetry=false")
    second := env.RunCLI("enable", "--agent", "claude-code", "--yes", "--telemetry=false")
    require.NotContains(t, second, "Imported", "re-enable must not offer import again; got: %s", second)
    require.False(t, strings.Contains(second, "already imported"),
        "re-enable must not run import at all; got: %s", second)
}

Mcmd/entire/cli/integration_test/enable_import_test.go +29/-8