import SwiftData import Testing @testable import Andromida struct RitualStoreTests { @MainActor @Test func quickRitualStartsIncomplete() throws { let store = makeStore() store.createQuickRitual() #expect(store.activeRitual != nil) #expect(abs(store.activeRitualProgress) < 0.0001) } @MainActor @Test func toggleHabitCompletionMarksComplete() throws { let store = makeStore() store.createQuickRitual() guard let habit = store.activeRitual?.habits.first else { throw TestError.missingHabit } store.toggleHabitCompletion(habit) #expect(store.isHabitCompletedToday(habit) == true) } } private func makeStore() -> RitualStore { let schema = Schema([Ritual.self, Habit.self]) let configuration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: true) let container: ModelContainer do { container = try ModelContainer(for: schema, configurations: [configuration]) } catch { fatalError("Test container failed: \(error)") } return RitualStore(modelContext: container.mainContext, seedService: EmptySeedService()) } private struct EmptySeedService: RitualSeedProviding { func makeSeedRituals(startDate: Date) -> [Ritual] { [] } } private enum TestError: Error { case missingHabit }