Branchwell

Inkspring / app · inkspring.ai / native-mac / Tests / InkspringTests / PostResultNoticeTests.swift

Raw 1.2 KB on 8f75dd7d901e2186ca9d9e1cf2f061105c02ae42
1import Testing
2@testable import Inkspring
3
4@Test func postNowUsesThePublishedReceiptAndScheduledPostsKeepTheirTime() throws {
5 var draft = WorkspaceRecord.new("draft")
6 draft["platform"] = "linkedin"
7 draft["content"] = "Read the manifesto."
8 #expect(draft.offersPostNow)
9
10 draft.fields["schedule"] = ["status": "posting"]
11 #expect(ScheduleListing.section(for: draft) == nil)
12 #expect(!draft.offersPostNow)
13 #expect(PostResultNotice(draft) == nil)
14
15 var receipt = WorkspaceRecord.new("publication")
16 receipt["draftId"] = draft.id
17 receipt["platform"] = "linkedin"
18 receipt["status"] = "uncertain"
19 #expect(PostResultNotice(receipt) == nil)
20 receipt["status"] = "published"
21 let published = try #require(PostResultNotice(receipt))
22 #expect(published.draftID == draft.id)
23 #expect(published.message == "Published on LinkedIn")
24
25 draft.fields["schedule"] = ["status": "queued", "slotAt": "2026-11-22T20:00:00Z"]
26 let scheduled = try #require(PostResultNotice(draft))
27 #expect(scheduled.draftID == draft.id)
28 #expect(scheduled.message == "Post scheduled")
29 draft.fields["schedule"] = ["status": "posting", "slotAt": "2026-11-22T20:00:00Z"]
30 #expect(ScheduleListing.section(for: draft) == .scheduled)
31}