import Foundation import Testing @testable import EquipoActivity @testable import EquipoKit /// A step Design makes is Engineering's kind with a maker (wire.Maker): /// the apps name it Design, never Engineering; a plain step keeps its kind. @MainActor struct MakerTests { static func step(maker: String) -> String { """ {"id":"s1","specialist":"engineering","state":"running","reason":"","summary":"","headline":"","verdict":"","review_label":"","checks":"","gate":"","exit_code":null,"started_at":null,"finished_at":null\(maker)} """ } @Test func aDesignStepIsDesign() throws { let step = try EquipoJSON.decoder.decode(ThinStep.self, from: Data(Self.step(maker: #","maker":{"id":"sp1","profile":"design-v1"}"#).utf8)) #expect(step.maker == ThinMaker(id: "sp1", profile: "design-v1")) #expect(step.who == "design") #expect(Specialist(category: step.who) == .design) } @Test func aPlainStepKeepsItsKind() throws { let step = try EquipoJSON.decoder.decode(ThinStep.self, from: Data(Self.step(maker: "").utf8)) #expect(step.maker == nil) #expect(Specialist(category: step.who) == .engineering) #expect(ThinMaker(id: "sp2", profile: "research-v1").category == "research") } /// Design's first attempt failed: no running or finished step, so the /// card names the task's maker, not Engineering. @Test func aFailedFirstDesignAttemptIsStillDesign() throws { let failed = Self.step(maker: #","maker":{"id":"sp1","profile":"design-v1"}"#).replacingOccurrences(of: #""state":"running""#, with: #""state":"failed""#) let json = """ {"id":"tk1","revision":3,"project_id":"p_1","project":"Shop","title":"Overhaul the shop design","brief":"","stage":"in_progress","branch":"","url":"","candidate_sha":"","checks":"","checks_reason":"","verdict":"","review_label":"","needs_you":"","creator":"paul@example.com","created_at":"2026-11-24T09:00:00Z","updated_at":"2026-11-24T09:00:00Z","maker":{"id":"sp1","profile":"design-v1"},"steps":[\(failed)]} """ let task = try EquipoJSON.decoder.decode(ThinTask.self, from: Data(json.utf8)) #expect(TaskReport(task, needsYou: false).specialist == .design) } }