import Foundation import UIKit struct MockBlueskyService: BlueskyService { var subscribedFeeds: [CustomFeed] = [ CustomFeed(id: "at://did:plc:demo/app.bsky.feed.generator/nature", name: "Nature", avatarURL: nil), CustomFeed(id: "at://did:plc:demo/app.bsky.feed.generator/art", name: "Art", avatarURL: nil) ] var failsLoadingFeeds = false var customFeedUnavailable = false var failsPublishing = false var failsDeleting = ProcessInfo.processInfo.arguments.contains("-ui-testing-delete-failure") var failsSavingPosts = false var failsMarkingNotificationsRead = false var requiresAuthFactorToken = false var restoresAccount = false var threadResponseDelayNanoseconds: UInt64 = 0 var replyBranchesEnabled = ProcessInfo.processInfo.arguments.contains("-ui-testing-reply-branches") var threadReplyOrder: [String] = [] var failsFirstAuthorFeedLoad = false var failsAuthorFeedLoadAtCall: Int? var authorFeedResponseDelayNanoseconds: UInt64 = 0 final class LoadState { var mentionLookupCount = 0 var preferenceLoadCount = 0 var authorFeedLoadCount = 0 var followingFirstPageLoadCount = 0 var notificationsSeenAt: [Date] = [] var authorFeedActorIDs: [String] = [] var authorFeedCursors: [String?] = [] var likes: [String: Bool] = [:] var reposts: [String: Bool] = [:] var savedPosts: [Post] = [] var editedProfile: EditableProfile? var profileSaveAttempts = 0 var didFailProfileConnectionsPage = false } let loadState = LoadState() let draftStorage: MockDraftStorage var notificationsSeenAt: [Date] { loadState.notificationsSeenAt } var authorFeedLoadCount: Int { loadState.authorFeedLoadCount } var authorFeedActorIDs: [String] { loadState.authorFeedActorIDs } var authorFeedCursors: [String?] { loadState.authorFeedCursors } init( failsPublishing: Bool = false, requiresAuthFactorToken: Bool = false, restoresAccount: Bool = false, threadResponseDelayNanoseconds: UInt64 = 0, replyBranchesEnabled: Bool = ProcessInfo.processInfo.arguments.contains("-ui-testing-reply-branches"), threadReplyOrder: [String] = [], failsFirstAuthorFeedLoad: Bool = false, failsAuthorFeedLoadAtCall: Int? = nil, authorFeedResponseDelayNanoseconds: UInt64 = 0, draftDefaults: UserDefaults? = nil ) { self.failsPublishing = failsPublishing self.requiresAuthFactorToken = requiresAuthFactorToken self.restoresAccount = restoresAccount self.threadResponseDelayNanoseconds = threadResponseDelayNanoseconds self.replyBranchesEnabled = replyBranchesEnabled self.threadReplyOrder = threadReplyOrder self.failsFirstAuthorFeedLoad = failsFirstAuthorFeedLoad self.failsAuthorFeedLoadAtCall = failsAuthorFeedLoadAtCall self.authorFeedResponseDelayNanoseconds = authorFeedResponseDelayNanoseconds self.draftStorage = MockDraftStorage(defaults: draftDefaults) } let account = Account(handle: "demo.bsky.social", displayName: "Demo Account", id: "demo") let authors = [ Post.Author(id: "mae", name: "Mae Rivers", handle: "mae.example"), Post.Author(id: "alex", name: "Alex Kim", handle: "alex.example"), Post.Author(id: "sam", name: "Sam Lee", handle: "sam.example") ] let profiles = [ Profile( author: Post.Author(id: "mae", name: "Mae Rivers", handle: "mae.example"), bio: "Writer, walker, and amateur cloud spotter. Sharing small things worth noticing.", location: "Portland, OR", website: URL(string: "https://mae.example"), followerCount: 1284, followingCount: 386, isFollowedBy: true, links: [ Profile.Link(id: "photos", title: "My Photos!", url: URL(string: "https://photos.example")!), Profile.Link(id: "github", title: "GitHub", url: URL(string: "https://github.com/example")!), Profile.Link(id: "post", title: "A post", url: URL(string: "https://oldsky.app/post?uri=post-1")!) ]), Profile( author: Post.Author(id: "alex", name: "Alex Kim", handle: "alex.example"), bio: "Designer who likes clear type, quiet mornings, and useful little tools.", location: "Seattle, WA", website: nil, followerCount: 847, followingCount: 512), Profile( author: Post.Author(id: "sam", name: "Sam Lee", handle: "sam.example"), bio: "Learning to cook one seasonal recipe at a time.", location: nil, website: URL(string: "https://sam.example"), followerCount: 2301, followingCount: 701) ] }