Repository Public
1// SP Notes iOS2// File: Tests/SystemIntegrationTests.swift3// Description: System integrations without the system: deep-link parsing and routing, the share hand-off turned into notes,4// the logic behind the App Intents (create, append, search), the sample workspace, the widgets' read-only data5// access next to a live writer, the Spotlight indexing rules. (Widget renderings: `WidgetSnapshotTests.swift`.)6//7// Author: Simon-Pierre Boucher8// Contact: contact@spboucher.ai9import BackgroundTasks10import CoreSpotlight11import Foundation12import SwiftUI13import Testing14import UIKit15import WidgetKit16import SPNotesCore17@testable import SPNotes1819@MainActor20private func makeModel() throws -> (AppModel, URL) {21 let directory = FileManager.default.temporaryDirectory.appendingPathComponent("spnotes-system-\(UUID().uuidString)", isDirectory: true)22 let configuration = AppConfiguration(api: .production(appVersion: "1.0.0"), dataDirectory: directory, inMemoryStore: true)23 return (try AppModel(configuration: configuration), directory)24}2526// MARK: deep links2728struct DeepLinkTests {29 private func link(_ text: String) -> DeepLink? { URL(string: text).flatMap(DeepLink.init(url:)) }3031 @Test func parsesNoteLinks() {32 let id = "0b7f6c0e-3f0a-4d5e-9b0a-111111111111"33 #expect(link("spnotes://note/\(id)") == .note(id))34 #expect(link("spnotes:///note/\(id)") == .note(id))35 #expect(link("spnotes:note/\(id)") == .note(id))36 #expect(link("SPNOTES://note/\(id.uppercased())") == .note(id))37 }3839 @Test func parsesNewAndSearchLinks() {40 #expect(link("spnotes://new") == .new(kind: .note, text: nil))41 #expect(link("spnotes://new?kind=tasks") == .new(kind: .tasks, text: nil))42 #expect(link("spnotes://new?text=Acheter%20du%20lait") == .new(kind: .note, text: "Acheter du lait"))43 #expect(link("spnotes://search?q=soupe%20%C3%A0%20l%27oignon") == .search("soupe à l'oignon"))44 #expect(link("spnotes://search") == .search(""))45 }4647 @Test func refusesEverythingElse() {48 for text in ["https://note.spboucher.ai/note/abc", "spnotes://", "spnotes://note", "spnotes://note/", "spnotes://note/abc/def",49 "spnotes://note/..%2F..%2Fetc", "spnotes://note/not_an_id!", "spnotes://new?kind=bogus", "spnotes://new/extra",50 "spnotes://delete/0b7f6c0e", "spnotes://note/\(String(repeating: "a", count: 80))"] {51 #expect(link(text) == nil, "accepted \(text)")52 }53 }5455 @Test func urlsRoundTrip() {56 let links: [DeepLink] = [.note("0b7f6c0e-3f0a-4d5e-9b0a-111111111111"), .newNote, .new(kind: .tasks, text: nil),57 .new(kind: .note, text: "Idée & suite ?"), .search("été à Québec"), .search("")]58 for link in links { #expect(DeepLink(url: link.url) == link) }59 #expect(DeepLink.newNote.url.absoluteString == "spnotes://new")60 #expect(DeepLink.new(kind: .tasks, text: nil).url.absoluteString == "spnotes://new?kind=tasks")61 #expect(DeepLink.note("abc-123").url.absoluteString == "spnotes://note/abc-123")62 }6364 @MainActor @Test func linksBecomeRoutes() async throws {65 let (app, _) = try makeModel()66 #expect(app.open(url: URL(string: "spnotes://note/abc-123")!))67 #expect(app.pendingRoute == .note("abc-123"))68 #expect(app.open(url: URL(string: "spnotes://search?q=budget")!))69 #expect(app.pendingRoute == .search("budget"))70 #expect(app.open(url: URL(string: "spnotes://new")!))71 #expect(app.pendingRoute == .newNote)72 app.pendingRoute = nil73 #expect(!app.open(url: URL(string: "spnotes://nothing")!))74 #expect(!app.open(url: URL(string: "https://example.org")!))75 #expect(app.pendingRoute == nil)76 }7778 @MainActor @Test func taskListLinkCreatesANoteAndOpensIt() async throws {79 let (app, _) = try makeModel()80 app.open(.new(kind: .tasks, text: nil))81 for _ in 0..<200 where app.pendingRoute == nil { try await Task.sleep(for: .milliseconds(10)) }82 guard case .note(let id, _) = app.pendingRoute else { Issue.record("no route: \(String(describing: app.pendingRoute))"); return }83 let page = try #require(try await app.store.page(id: id))84 let document = try NoteDocument(json: page.content)85 #expect(document.listKind(at: 0) == .task)86 #expect(document.schemaViolations().isEmpty)87 }8889 @Test func activitiesAndNotificationsGiveTheNote() {90 let id = "0b7f6c0e-3f0a-4d5e-9b0a-111111111111"91 let handoff = NSUserActivity(activityType: NoteActivity.type)92 NoteActivity.fill(handoff, noteId: id, title: "Titre")93 #expect(NoteActivity.noteId(from: handoff) == id)94 #expect(handoff.isEligibleForHandoff)95 let spotlight = NSUserActivity(activityType: CSSearchableItemActionType)96 spotlight.userInfo = [CSSearchableItemActivityIdentifier: id.uppercased()]97 #expect(NoteActivity.noteId(from: spotlight) == id)98 let foreign = NSUserActivity(activityType: "com.example.other")99 foreign.userInfo = [NoteActivity.noteIdKey: id]100 #expect(NoteActivity.noteId(from: foreign) == nil)101 let query = NSUserActivity(activityType: CSQueryContinuationActionType)102 query.userInfo = [CSSearchQueryString: "lisbonne"]103 #expect(NoteActivity.searchQuery(from: query) == "lisbonne")104 }105106 @MainActor @Test func reminderNotificationsCarryTheNote() {107 #expect(AppDelegate.noteId(in: [ReminderScheduler.noteIdKey: "ABC-123"]) == "abc-123")108 #expect(AppDelegate.noteId(in: [ReminderScheduler.noteIdKey: "../etc"]) == nil)109 #expect(AppDelegate.noteId(in: [:]) == nil)110 }111}112113// MARK: share extension hand-off114115@MainActor116struct SharedInboxImportTests {117 @Test func sharedTextLinkAndFilesBecomeInboxCaptures() async throws {118 let (app, directory) = try makeModel()119 let inbox = SharedInbox(container: directory)120 let sources = FileManager.default.temporaryDirectory.appendingPathComponent("share-src-\(UUID().uuidString)", isDirectory: true)121 try FileManager.default.createDirectory(at: sources, withIntermediateDirectories: true)122 let pdf = sources.appendingPathComponent("Rapport annuel.pdf"), text = sources.appendingPathComponent("notes.txt")123 try Data("%PDF-1.4 faux contenu".utf8).write(to: pdf)124 try Data("un fichier texte".utf8).write(to: text)125126 try inbox.save(SharedItem(createdAt: Date(timeIntervalSince1970: 1_000), title: nil, text: "Une idée notée depuis une autre app."), files: [])127 try inbox.save(SharedItem(createdAt: Date(timeIntervalSince1970: 2_000), title: "Guide iPadOS", text: "À lire ce soir.", url: "https://support.apple.com/fr-ca/guide/ipad"), files: [])128 try inbox.save(SharedItem(createdAt: Date(timeIntervalSince1970: 3_000), title: "Documents du dossier"), files: [(name: "Rapport annuel.pdf", source: pdf), (name: "notes.txt", source: text)])129 #expect(inbox.pending().count == 3)130131 await app.importSharedItems()132133 #expect(app.banner == nil)134 #expect(inbox.pending().isEmpty)135 let notes = try await app.store.summaries(list: .all)136 #expect(notes.count == 3)137138 let plain = try #require(notes.first { $0.preview.contains("Une idée notée") })139 // 2.0: a shared item is an inbox capture; without a title it takes its first line (1.0: « Untitled », filed in notes)140 #expect(plain.title == "Une idée notée depuis une autre app.")141 #expect(try await app.store.summaries(list: .inbox).count == 3)142143 let linked = try #require(notes.first { $0.title == "Guide iPadOS" })144 let linkedPage = try #require(try await app.store.page(id: linked.id))145 #expect(linkedPage.plainText.contains("https://support.apple.com/fr-ca/guide/ipad"))146 #expect(linkedPage.plainText.contains("À lire ce soir."))147 #expect(String(decoding: linkedPage.content, as: UTF8.self).contains(#""href":"https://support.apple.com/fr-ca/guide/ipad""#))148149 let filed = try #require(notes.first { $0.title == "Documents du dossier" })150 let attachments = try await app.store.attachments(pageId: filed.id)151 #expect(Set(attachments.map(\.filename)) == ["Rapport annuel.pdf", "notes.txt"])152 for attachment in attachments {153 let path = try #require(attachment.localPath)154 #expect(app.files.exists(relativePath: path))155 #expect(attachment.state == .pendingUpload)156 }157 let filedDocument = try NoteDocument(json: try #require(try await app.store.page(id: filed.id)).content)158 #expect(filedDocument.lines.filter { $0.type == NodeType.fileBlock }.count == 2)159 #expect(filedDocument.schemaViolations().isEmpty)160161 // A second activation imports nothing twice.162 await app.importSharedItems()163 #expect(try await app.store.pageCount() == 3)164 }165166 @Test func duplicateFileNamesAreKeptApart() throws {167 let directory = FileManager.default.temporaryDirectory.appendingPathComponent("spnotes-inbox-\(UUID().uuidString)", isDirectory: true)168 let inbox = SharedInbox(container: directory)169 let source = directory.appendingPathComponent("photo.jpg")170 try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)171 try Data([0xFF, 0xD8, 0xFF]).write(to: source)172 try inbox.save(SharedItem(title: "Deux photos"), files: [(name: "photo.jpg", source: source), (name: "photo.jpg", source: source)])173 let item = try #require(inbox.pending().first)174 #expect(item.files == ["photo.jpg", "photo 2.jpg"])175 for name in item.files { #expect(FileManager.default.fileExists(atPath: inbox.fileURL(item: item, name: name).path)) }176 }177}178179// MARK: intents180181@MainActor182struct QuickNoteActionTests {183 @Test func titleComesFromTheFirstLineWhenMissing() {184 #expect(AppModel.quickNoteParts(title: " Courses ", text: " lait\npain ") == ("Courses", "lait\npain"))185 #expect(AppModel.quickNoteParts(title: nil, text: "Appeler le plombier") == ("Appeler le plombier", ""))186 #expect(AppModel.quickNoteParts(title: "", text: "Réunion\n\nOrdre du jour\nSuivis") == ("Réunion", "Ordre du jour\nSuivis"))187 let long = String(repeating: "mot ", count: 40)188 let parts = AppModel.quickNoteParts(title: nil, text: long)189 #expect(parts.title.count <= 80 && parts.title.hasSuffix("…"))190 #expect(parts.body == long.trimmingCharacters(in: .whitespaces))191 #expect(AppModel.quickNoteParts(title: nil, text: " \n ") == ("", ""))192 }193194 @Test func createsANoteLocally() async throws {195 let (app, _) = try makeModel()196 let id = try await app.quickCreate(title: "Idées", text: "Première idée\n\n- un point\n- un autre")197 let page = try #require(try await app.store.page(id: id))198 #expect(page.title == "Idées")199 #expect(page.plainText.contains("Première idée") && page.plainText.contains("un autre"))200 #expect(page.needsCreate && page.syncState == .pending)201 let entity = try await app.noteEntity(id: id)202 #expect(entity.id == id && entity.title == "Idées" && entity.preview.contains("Première idée"))203204 let untitled = try await app.quickCreate(title: nil, text: "")205 #expect(try await app.noteEntity(id: untitled).title == "Sans titre")206 }207208 @Test func appendsParagraphsThroughTheSavePath() async throws {209 let (app, _) = try makeModel()210 let id = try await app.quickCreate(title: "Journal", text: "- [ ] tâche existante")211 let before = try #require(try await app.store.page(id: id))212 #expect(try await app.appendText("Ligne ajoutée\n\nUne autre ligne", toNote: id))213 let after = try #require(try await app.store.page(id: id))214 #expect(after.editSeq > before.editSeq)215 #expect(after.title == "Journal")216 #expect(after.plainText.contains("tâche existante"))217 let document = try NoteDocument(json: after.content)218 #expect(document.lines.count == 3)219 #expect(document.listKind(at: 0) == .task)220 #expect(document.lines[1].path.isEmpty && document.lines[2].path.isEmpty)221 #expect(document.lines.suffix(2).map(\.displayString) == ["Ligne ajoutée", "Une autre ligne"])222 #expect(document.schemaViolations().isEmpty)223 #expect(after.preview == ContentDigest(document: document).preview)224225 #expect(try await app.appendText(" \n ", toNote: id) == false)226 await #expect(throws: AppError.self) { try await app.appendText("texte", toNote: "00000000-0000-4000-8000-00000000dead") }227 try await app.trash(id)228 await #expect(throws: AppError.self) { try await app.appendText("texte", toNote: id) }229 }230231 @Test func anEmptyNoteIsFilledNotExtended() async throws {232 let (app, _) = try makeModel()233 let id = try await app.createNote(title: "Vide")234 try await app.appendText("Premier paragraphe", toNote: id)235 let document = try NoteDocument(json: try #require(try await app.store.page(id: id)).content)236 #expect(document.lines.map(\.displayString) == ["Premier paragraphe"])237 }238239 @Test func searchReturnsEntities() async throws {240 let (app, _) = try makeModel()241 let soup = try await app.quickCreate(title: "Soupe à l’oignon", text: "Gruyère et bouillon")242 _ = try await app.quickCreate(title: "Budget", text: "Loyer et transport")243 let folder = try await app.createNote(title: "Recettes de soupe", isFolder: true)244 let trashed = try await app.quickCreate(title: "Soupe ratée", text: "à jeter")245 try await app.trash(trashed)246247 let results = try await app.searchNotes("soupe")248 #expect(results.map(\.id) == [soup])249 #expect(results.first?.title == "Soupe à l’oignon")250 #expect(try await app.searchNotes("gruyere").map(\.id) == [soup])251 #expect(try await app.searchNotes("introuvable").isEmpty)252 #expect(!(try await app.searchNotes("recettes")).contains { $0.id == folder })253 }254}255256// MARK: sample data257258@MainActor259struct SampleDataTests {260 @Test func seedsTheWorkspaceOnceIntoAnEmptyStore() async throws {261 let (app, _) = try makeModel()262 #expect(await SampleData.seed(into: app))263 let store = app.store264 #expect(try await store.pageCount() == SampleData.pageCount)265 #expect(SampleData.pageCount == 20 && SampleData.noteCount == 18) // 2.0: + « Blocs 3.0 », + « Note vocale »266267 let counts = try await store.counts()268 #expect(counts.pinned == 2 && counts.favorites == 2 && counts.archived == 1 && counts.trash == 1 && counts.inbox == 1)269 let folders = try await store.folderTree()270 #expect(Set(folders.map(\.id)) == [SampleData.travelFolderID, SampleData.kitchenFolderID])271 #expect(try await store.children(of: SampleData.travelFolderID).count == 2)272 #expect(try await store.children(of: SampleData.kitchenFolderID).count == 2)273 for section in ["notes", "documents", "projects", "research"] {274 #expect(!(try await store.children(of: nil, section: section)).isEmpty, "no note in \(section)")275 }276 #expect(try await store.tags().count >= 8)277 #expect(try await store.summaries(list: .all).first?.id == SampleData.welcomeNoteID)278 #expect(try await store.summaries(list: .trash).map(\.id) == [SampleData.trashedNoteID])279 #expect(try await store.summaries(list: .inbox).map(\.id) == [SampleData.inboxNoteID])280 #expect(try await store.upcomingReminders().count == 1)281282 // The long note exercises every kind of block and is valid for the web schema.283 let guide = try NoteDocument(json: try #require(try await store.page(id: SampleData.editorGuideNoteID)).content)284 let types = Set(guide.lines.map(\.type)), containers = Set(guide.lines.flatMap { $0.path.map(\.type) })285 #expect(types.isSuperset(of: [NodeType.heading, NodeType.paragraph, NodeType.codeBlock, NodeType.table, NodeType.blockMath, NodeType.horizontalRule]))286 #expect(containers.isSuperset(of: [NodeType.bulletList, NodeType.orderedList, NodeType.taskList, NodeType.blockquote]))287 #expect(guide.taskItems().total == 4 && guide.taskItems().checked == 2)288 for item in SampleData.items {289 let page = try #require(try await store.page(id: SampleData.id(item.number)))290 // « Blocs 3.0 » holds one block of an unknown type on purpose (it must be kept verbatim): it is the only violation allowed291 #expect(try NoteDocument(json: page.content).schemaViolations().filter { !$0.contains("blocFutur") }.isEmpty, "\(item.title)")292 }293294 // Nothing is added to a store that already holds notes.295 #expect(await SampleData.seed(into: app) == false)296 #expect(try await store.pageCount() == SampleData.pageCount)297 }298}299300// MARK: widgets301302struct WidgetDataTests {303 private func page(_ title: String, _ text: String, pinned: Bool = false, folder: Bool = false) -> NewPage {304 NewPage(title: title, properties: Data((folder ? #"{"folder":true}"# : "{}").utf8), pinned: pinned, plainText: text, wordCount: 2, preview: text)305 }306307 @Test func readsTheDatabaseReadOnlyNextToAWriter() async throws {308 let directory = FileManager.default.temporaryDirectory.appendingPathComponent("spnotes-widget-\(UUID().uuidString)", isDirectory: true)309 try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)310 let url = directory.appendingPathComponent("notes.sqlite")311 let provider = WidgetDataProvider(databaseURL: url)312313 // No database yet: an ordinary state, not an error.314 #expect(await provider.recent(limit: 3) == .unavailable)315 #expect(await provider.note(id: "missing") == nil)316 #expect(!FileManager.default.fileExists(atPath: url.path))317318 let writer = try NotesStore(url: url)319 #expect(await provider.recent(limit: 3) == .empty)320 #expect(await provider.pinned(limit: 3) == .empty)321322 let first = try await writer.createPage(page("Première", "Texte de la première"))323 try await Task.sleep(for: .milliseconds(5))324 _ = try await writer.createPage(page("Dossier", "", folder: true))325 try await Task.sleep(for: .milliseconds(5))326 let pinned = try await writer.createPage(page("Épinglée", "Texte épinglé", pinned: true))327 try await Task.sleep(for: .milliseconds(5))328 let untitled = try await writer.createPage(page("Untitled", "Sans nom"))329330 // The writer connection is still open: the reader sees every committed transaction.331 let recent = await provider.recent(limit: 6).notes332 #expect(recent.map(\.id) == [untitled.id, pinned.id, first.id])333 #expect(recent.map(\.title) == ["Sans titre", "Épinglée", "Première"])334 #expect(recent.last?.preview == "Texte de la première")335 #expect(await provider.recent(limit: 1).notes.map(\.id) == [untitled.id])336 #expect(await provider.pinned(limit: 6).notes.map(\.id) == [pinned.id])337 #expect(await provider.search("epinglee").map(\.id) == [pinned.id])338 #expect(await provider.notes(ids: [first.id, "missing"]).map(\.id) == [first.id])339 let single = try #require(await provider.note(id: first.id, textLength: 8))340 #expect(single.title == "Première" && single.preview == "Texte de")341342 // A change written afterwards is seen by the next read; the trash hides a note.343 _ = try await writer.trash(id: untitled.id)344 #expect(await provider.recent(limit: 6).notes.map(\.id) == [pinned.id, first.id])345 #expect(await provider.note(id: untitled.id) == nil)346347 // The reader never wrote: the writer is intact and still usable.348 #expect(try await writer.integrityCheck().isEmpty)349 _ = try await writer.createPage(page("Après", "encore"))350 #expect(await provider.recent(limit: 1).notes.first?.title == "Après")351 await writer.close()352 }353354 @Test func entitiesMirrorTheNotes() {355 let note = WidgetNote(id: "abc", title: "Titre", preview: "Aperçu", updatedAt: Date(timeIntervalSince1970: 10))356 let entity = NoteEntity(note)357 #expect(entity.id == "abc" && entity.title == "Titre" && entity.preview == "Aperçu" && entity.modifiedAt == note.updatedAt)358 #expect(note.url.absoluteString == "spnotes://note/abc")359 #expect(WidgetNote.displayTitle(" ") == "Sans titre")360 }361}362363// MARK: Spotlight364365private actor RecordingIndex: SearchIndexing {366 private(set) var items: [String: SpotlightNote] = [:]367 private(set) var removeAllCount = 0368 func index(_ notes: [SpotlightNote]) { for note in notes { items[note.id] = note } }369 func remove(ids: [String]) { for id in ids { items[id] = nil } }370 func removeAll() { items = [:]; removeAllCount += 1 }371}372373@MainActor374struct SpotlightIndexerTests {375 @Test func followsCreationEditsTrashAndErase() async throws {376 let (app, _) = try makeModel()377 let index = RecordingIndex()378 let indexer = SpotlightIndexer(store: app.store, index: index)379380 let kept = try await app.quickCreate(title: "Itinéraire", text: "Alfama puis Belém")381 let folder = try await app.createNote(title: "Dossier", isFolder: true)382 await indexer.reindexAll()383 #expect(await index.items.keys.sorted() == [kept])384 #expect(await index.items[kept]?.title == "Itinéraire")385386 let added = try await app.quickCreate(title: nil, text: "Nouvelle idée")387 await indexer.apply(.pages([added, folder]))388 #expect(await Set(index.items.keys) == [kept, added])389 #expect(await index.items[added]?.text.isEmpty == true)390391 try await app.appendText("Train pour Sintra", toNote: kept)392 await indexer.apply(.pages([kept]))393 #expect(await index.items[kept]?.text.contains("Sintra") == true)394395 try await app.setArchived(added, true)396 await indexer.apply(.pages([added]))397 #expect(await index.items[added] == nil)398399 try await app.trash(kept)400 await indexer.apply(.pages([kept]))401 #expect(await index.items.isEmpty)402403 try await app.restore(kept)404 await indexer.apply(.reset)405 #expect(await index.items.keys.sorted() == [kept])406407 let before = await index.removeAllCount408 try await app.store.wipeAll()409 await indexer.apply(.reset)410 #expect(await index.items.isEmpty)411 #expect(await index.removeAllCount == before + 1)412 }413}414415// MARK: bundle and background tasks416417@MainActor418struct BundleIntegrationTests {419 @Test func backgroundTaskIdentifiersAreDeclared() throws {420 let declared = try #require(Bundle.main.object(forInfoDictionaryKey: "BGTaskSchedulerPermittedIdentifiers") as? [String])421 #expect(Set(declared) == [BackgroundSync.refreshIdentifier, BackgroundSync.processingIdentifier])422 let refresh = BackgroundSync.refreshRequest(now: Date(timeIntervalSince1970: 0))423 #expect(refresh.identifier == BackgroundSync.refreshIdentifier)424 #expect(refresh.earliestBeginDate == Date(timeIntervalSince1970: BackgroundSync.refreshInterval))425 let processing = BackgroundSync.processingRequest()426 #expect(processing.identifier == BackgroundSync.processingIdentifier && processing.requiresNetworkConnectivity && !processing.requiresExternalPower)427 }428429 @Test func theAppDeclaresItsLinksActivityAndPrivacyManifest() throws {430 let types = try #require(Bundle.main.object(forInfoDictionaryKey: "CFBundleURLTypes") as? [[String: Any]])431 #expect(types.contains { ($0["CFBundleURLSchemes"] as? [String])?.contains(DeepLink.scheme) == true })432 #expect((Bundle.main.object(forInfoDictionaryKey: "NSUserActivityTypes") as? [String])?.contains(NoteActivity.type) == true)433 let manifest = try #require(Bundle.main.url(forResource: "PrivacyInfo", withExtension: "xcprivacy"))434 let plist = try #require(try PropertyListSerialization.propertyList(from: Data(contentsOf: manifest), format: nil) as? [String: Any])435 #expect(plist["NSPrivacyTracking"] as? Bool == false)436 let reasons = (plist["NSPrivacyAccessedAPITypes"] as? [[String: Any]] ?? []).flatMap { $0["NSPrivacyAccessedAPITypeReasons"] as? [String] ?? [] }437 #expect(Set(reasons) == ["CA92.1", "C617.1"])438 }439440 @Test func theSingleModelIsShared() throws {441 // The host app already booted: every entry point gets that same model, never a second one.442 let first = try AppRuntime.model(), second = try AppRuntime.model()443 #expect(first === second)444 #expect(Boot().result.isSameModel(as: first))445 }446}447448private extension Result where Success == AppModel {449 func isSameModel(as model: AppModel) -> Bool { (try? get()) === model }450}451