Something went wrong. Try again.
A slopfork of Sam Henri Gold's Twitter client, reskinned like Tweetie 2 / Twitter for iPhone circa 2012. Personal use.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125import ComposableArchitectureimport Foundationimport Testing
@testable import Models@testable import Routing@testable import TabStackFeature@testable import WebFeature
@MainActorstruct WebPanelTests { let url = URL(string: "https://www.pointfree.co/episodes")!
@Test func webLinkOpensAPanelBesideTheColumns() async { var state = TabStack.State.home state.canShowColumns = true let store = TestStore(initialState: state) { TabStack() }
await store.send(.root(.feeds(.delegate(.open(.web(url)))))) { $0.path = StackState([.web(WebFeature.State(url: self.url))]) } }
@Test func webLinkOnOneStackOpensSafari() async { let store = TestStore(initialState: TabStack.State.home) { TabStack() }
await store.send(.root(.feeds(.delegate(.open(.web(url)))))) { $0.safari = TabStack.SafariPage(url: self.url) } await store.send(.safariDismissed) { $0.safari = nil } }
@Test func columnAvailabilityFollowsTheDisplay() async { let store = TestStore(initialState: TabStack.State.home) { TabStack() }
await store.send(.columnAvailabilityChanged(true)) { $0.canShowColumns = true } }
@Test func openingTheSamePageAgainFocusesItsPanel() async { var state = TabStack.State.home state.canShowColumns = true state.path.append(.web(WebFeature.State(url: url))) state.path.append(Route.thread(Tweet.mocks[0]).pathState) let store = TestStore(initialState: state) { TabStack() } let sameURL = URL(string: "https://WWW.pointfree.co/episodes/#top")!
await store.send(.root(.feeds(.delegate(.open(.web(sameURL)))))) { $0.path.removeLast() } }
@Test func postLinkInsideAPanelOpensAColumnAfterIt() async { var state = TabStack.State.home state.canShowColumns = true state.path.append(.web(WebFeature.State(url: url))) let store = TestStore(initialState: state) { TabStack() }
await store.send(.path(.element(id: 0, action: .web(.inAppLinkTapped(.threadID("12345")))))) await store.receive(\.path[id: 0].web.delegate) { $0.path[id: 1] = Route.threadID("12345").pathState } }
@Test func panelRemembersWhereTheReaderGot() async { let store = TestStore(initialState: WebFeature.State(url: url)) { WebFeature() } let next = URL(string: "https://www.pointfree.co/collections")!
await store.send(.pageChanged(url: next, title: "Collections")) { $0.currentURL = next $0.title = "Collections" } #expect(store.state.shows(next)) #expect(store.state.shows(url)) #expect(store.state.pageURL == next) }
@Test func openInSafariOpensTheCurrentPage() async { let opened = LockIsolated<[URL]>([]) var state = WebFeature.State(url: url) let next = URL(string: "https://www.pointfree.co/collections")! state.currentURL = next let store = TestStore(initialState: state) { WebFeature() } withDependencies: { $0.openURL = OpenURLEffect { url in opened.withValue { $0.append(url) } return true } }
await store.send(.openInSafariButtonTapped) await store.finish() #expect(opened.value == [next]) }
@Test func windowRootedAtAPage() { let state = TabStack.State.window(.web(url)) #expect(state.root.web?.url == url) }}