Restructure into a three-tab app with Progress, goals, and Meditation
The UX redesign's first landing (spec in UX-REDESIGN.md): ContentView becomes a Today / Progress / Settings TabView, "Routine" replaces "Split" in every user-facing string and view name (code-level types keep their names), and workout starting moves to shared WorkoutStarter / StartedWorkoutNavigator plumbing. - New Progress tab: weekly goal streaks, workout trends, per-exercise weight progression, achievements, and the full history list (WorkoutLogsView -> WorkoutHistoryView). - Goals: stable categories workouts roll up to, managed from Settings. - New Meditation exercise + starter routine; timed sits record to Apple Health as Mind & Body sessions. Claude-Session: https://claude.ai/code/session_012qw2itfzKyEJ1HpsFt8Ex4
This commit is contained in:
@@ -5,7 +5,7 @@ import IndieSync
|
||||
|
||||
/// Locks the decision table of `SeedReconcilePlanner` — the safety-critical logic that
|
||||
/// upgrades stale starter-seed revisions and adds newly-shipped seeds on an existing
|
||||
/// install without ever duplicating a user's split, resurrecting a deleted seed, or
|
||||
/// install without ever duplicating a user's routine, resurrecting a deleted seed, or
|
||||
/// downgrade-rewriting a newer app version's file. All fixtures are plain structs so
|
||||
/// every assertion is a pure, deterministic function of the inputs.
|
||||
struct SeedReconcilePlannerTests {
|
||||
@@ -21,15 +21,15 @@ struct SeedReconcilePlannerTests {
|
||||
)
|
||||
}
|
||||
|
||||
/// A seed-shaped split at the current schema version, with a fixed frozen date so
|
||||
/// A seed-shaped routine at the current schema version, with a fixed frozen date so
|
||||
/// two builds of "the same" content compare equal.
|
||||
private func seed(
|
||||
id: String = "01DXF6DT0038BDC2WC3EVX8ZJ5",
|
||||
name: String = "Upper Body",
|
||||
schemaVersion: Int = SplitDocument.currentSchemaVersion,
|
||||
schemaVersion: Int = RoutineDocument.currentSchemaVersion,
|
||||
exercises: [ExerciseDocument]? = nil
|
||||
) -> SplitDocument {
|
||||
SplitDocument(
|
||||
) -> RoutineDocument {
|
||||
RoutineDocument(
|
||||
schemaVersion: schemaVersion, id: id, name: name, color: "indigo",
|
||||
systemImage: "dumbbell.fill", order: 0,
|
||||
createdAt: Date(timeIntervalSince1970: 0), updatedAt: Date(timeIntervalSince1970: 0),
|
||||
@@ -49,7 +49,7 @@ struct SeedReconcilePlannerTests {
|
||||
live.schemaVersion = 1 // older wrapper, same content
|
||||
let input = SeedReconcileInput(seedID: bundle.id, seedDoc: bundle, liveDoc: live, hasStub: false)
|
||||
|
||||
#expect(SeedReconcilePlanner.decision(for: input, liveSplitNames: []) == .skip(.upToDate))
|
||||
#expect(SeedReconcilePlanner.decision(for: input, liveRoutineNames: []) == .skip(.upToDate))
|
||||
}
|
||||
|
||||
/// The bundle seed gained an exercise since this install wrote its file — a real
|
||||
@@ -61,7 +61,7 @@ struct SeedReconcilePlannerTests {
|
||||
live.schemaVersion = 1
|
||||
let input = SeedReconcileInput(seedID: bundle.id, seedDoc: bundle, liveDoc: live, hasStub: false)
|
||||
|
||||
#expect(SeedReconcilePlanner.decision(for: input, liveSplitNames: []) == .upgrade)
|
||||
#expect(SeedReconcilePlanner.decision(for: input, liveRoutineNames: []) == .upgrade)
|
||||
}
|
||||
|
||||
/// A weight tweak alone is enough of a content change to upgrade.
|
||||
@@ -70,7 +70,7 @@ struct SeedReconcilePlannerTests {
|
||||
let live = seed(exercises: [exercise(name: "Bench Press", weight: 115)])
|
||||
let input = SeedReconcileInput(seedID: bundle.id, seedDoc: bundle, liveDoc: live, hasStub: false)
|
||||
|
||||
#expect(SeedReconcilePlanner.decision(for: input, liveSplitNames: []) == .upgrade)
|
||||
#expect(SeedReconcilePlanner.decision(for: input, liveRoutineNames: []) == .upgrade)
|
||||
}
|
||||
|
||||
/// A live file written by a NEWER app version (schemaVersion above current) is
|
||||
@@ -78,11 +78,11 @@ struct SeedReconcilePlannerTests {
|
||||
@Test func newerSchemaFileIsQuarantined() {
|
||||
let bundle = seed()
|
||||
var live = seed(exercises: [exercise(name: "Something New")])
|
||||
live.schemaVersion = SplitDocument.currentSchemaVersion + 1
|
||||
live.schemaVersion = RoutineDocument.currentSchemaVersion + 1
|
||||
#expect(!live.isReadable) // guards the premise
|
||||
let input = SeedReconcileInput(seedID: bundle.id, seedDoc: bundle, liveDoc: live, hasStub: false)
|
||||
|
||||
#expect(SeedReconcilePlanner.decision(for: input, liveSplitNames: []) == .skip(.quarantined))
|
||||
#expect(SeedReconcilePlanner.decision(for: input, liveRoutineNames: []) == .skip(.quarantined))
|
||||
}
|
||||
|
||||
// MARK: - No live file
|
||||
@@ -92,25 +92,25 @@ struct SeedReconcilePlannerTests {
|
||||
let bundle = seed()
|
||||
let input = SeedReconcileInput(seedID: bundle.id, seedDoc: bundle, liveDoc: nil, hasStub: true)
|
||||
|
||||
#expect(SeedReconcilePlanner.decision(for: input, liveSplitNames: []) == .skip(.vetoed))
|
||||
#expect(SeedReconcilePlanner.decision(for: input, liveRoutineNames: []) == .skip(.vetoed))
|
||||
}
|
||||
|
||||
/// No live file, no stub, but a live split (a legacy runtime-built or user-cloned
|
||||
/// No live file, no stub, but a live routine (a legacy runtime-built or user-cloned
|
||||
/// "Upper Body") already uses the seed's name → writing it would duplicate by name.
|
||||
@Test func nameCollisionSkips() {
|
||||
let bundle = seed(name: "Upper Body")
|
||||
let input = SeedReconcileInput(seedID: bundle.id, seedDoc: bundle, liveDoc: nil, hasStub: false)
|
||||
|
||||
#expect(SeedReconcilePlanner.decision(for: input, liveSplitNames: ["Upper Body", "Core"]) == .skip(.nameCollision))
|
||||
#expect(SeedReconcilePlanner.decision(for: input, liveRoutineNames: ["Upper Body", "Core"]) == .skip(.nameCollision))
|
||||
}
|
||||
|
||||
/// No live file, no stub, no same-name split → a genuinely missing seed (newly
|
||||
/// No live file, no stub, no same-name routine → a genuinely missing seed (newly
|
||||
/// shipped, or a pre-fixed-ULID install) gets written.
|
||||
@Test func missingSeedIsWritten() {
|
||||
let bundle = seed(name: "Bodyweight Core")
|
||||
let input = SeedReconcileInput(seedID: bundle.id, seedDoc: bundle, liveDoc: nil, hasStub: false)
|
||||
|
||||
#expect(SeedReconcilePlanner.decision(for: input, liveSplitNames: ["Upper Body", "Core"]) == .write)
|
||||
#expect(SeedReconcilePlanner.decision(for: input, liveRoutineNames: ["Upper Body", "Core"]) == .write)
|
||||
}
|
||||
|
||||
/// A stub present but the same name also live: the veto is checked first, so it
|
||||
@@ -119,7 +119,7 @@ struct SeedReconcilePlannerTests {
|
||||
let bundle = seed(name: "Upper Body")
|
||||
let input = SeedReconcileInput(seedID: bundle.id, seedDoc: bundle, liveDoc: nil, hasStub: true)
|
||||
|
||||
#expect(SeedReconcilePlanner.decision(for: input, liveSplitNames: ["Upper Body"]) == .skip(.vetoed))
|
||||
#expect(SeedReconcilePlanner.decision(for: input, liveRoutineNames: ["Upper Body"]) == .skip(.vetoed))
|
||||
}
|
||||
|
||||
// MARK: - Restore
|
||||
@@ -128,10 +128,10 @@ struct SeedReconcilePlannerTests {
|
||||
/// the presence of a veto stub is irrelevant (restore lifts it).
|
||||
@Test func shouldRestoreOnlyWhenAbsentAndNameFree() {
|
||||
// Absent, name free → restore (whether or not a stub exists).
|
||||
#expect(SeedReconcilePlanner.shouldRestore(hasLiveFile: false, seedName: "Upper Body", liveSplitNames: []))
|
||||
#expect(SeedReconcilePlanner.shouldRestore(hasLiveFile: false, seedName: "Upper Body", liveRoutineNames: []))
|
||||
// Live file already present → reconcile handles any upgrade; restore leaves it.
|
||||
#expect(!SeedReconcilePlanner.shouldRestore(hasLiveFile: true, seedName: "Upper Body", liveSplitNames: []))
|
||||
// A live same-name split exists → don't duplicate it.
|
||||
#expect(!SeedReconcilePlanner.shouldRestore(hasLiveFile: false, seedName: "Upper Body", liveSplitNames: ["Upper Body"]))
|
||||
#expect(!SeedReconcilePlanner.shouldRestore(hasLiveFile: true, seedName: "Upper Body", liveRoutineNames: []))
|
||||
// A live same-name routine exists → don't duplicate it.
|
||||
#expect(!SeedReconcilePlanner.shouldRestore(hasLiveFile: false, seedName: "Upper Body", liveRoutineNames: ["Upper Body"]))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user