1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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)
]
}