Unverified Commit abb5910d authored by Lemon-miaow's avatar Lemon-miaow
Browse files

fix(cli): setup re-run keeps its already-set-up framing after connect/storage reconfigure

parent 5450ec78
Loading
Loading
Loading
Loading
+1 −0
Changes for cmd/felis/tui_root.go: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -553,6 +553,7 @@ func (m *rootModel) showSummary() (tea.Model, tea.Cmd) {
		storageLabel:  m.result.storageDetail,
		routedHosts:   routed,
		localHint:     m.result.connectMethod == connectLocal,
		alreadySetUp:  m.result.alreadySetUp,
	})
}

+28 −0
Changes for cmd/felis/tui_root_test.go: 28 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -249,6 +249,34 @@ func TestRootReconfigureSMTP(t *testing.T) {
	}
}

// TestRootReconfigureStorageKeepsStatusFraming locks the same rule for the
// "change storage" path: on a re-run, completing it must land back on the
// alreadySetUp status framing (with the updated recap), not "Setup complete."
func TestRootReconfigureStorageKeepsStatusFraming(t *testing.T) {
	m := newTestRoot(true, consoleModeSetup, "")
	m = drive(t, m, preflightDoneMsg{})
	if _, ok := m.screen.(*summaryModel); !ok {
		t.Fatalf("re-run after preflight, screen = %T, want *summaryModel", m.screen)
	}

	m = drive(t, m, reconfigureStorageMsg{})
	if _, ok := m.screen.(*storageChooserModel); !ok {
		t.Fatalf("reconfigure-storage screen = %T, want *storageChooserModel", m.screen)
	}

	m = drive(t, m, storageResultMsg{method: storageLocal, detail: "local disk · /var/lib/felis/uploads"})
	sum, ok := m.screen.(*summaryModel)
	if !ok {
		t.Fatalf("after reconfigure-storage, screen = %T, want *summaryModel", m.screen)
	}
	if !sum.alreadySetUp {
		t.Fatalf("after reconfigure-storage, summary should keep the alreadySetUp framing")
	}
	if sum.storageLabel != "local disk · /var/lib/felis/uploads" {
		t.Fatalf("storageLabel = %q, want the updated recap", sum.storageLabel)
	}
}

func TestRootRerunLandsOnStatus(t *testing.T) {
	// adminExists at start of a setup run = re-run: preflight should skip straight
	// to the "manage in panel" status screen, never touching owner/connect.