oficina / sheets Public

Clone
git clone https://amadan.net/oficina/sheets

Plain git — no account needed to clone.

Download

Download this file

1#if os(macOS)
2import Foundation
3import Testing
4import RastrilloApple
5@testable import SheetsMac
6
7@MainActor @Test func windowsReuseDocumentsWithinAccountAndOriginOnly() {
8 let windows = SheetsWindows()
9 let first = NativeHTTP(origin: URL(string: "https://first.invalid")!)
10 let second = NativeHTTP(origin: URL(string: "https://second.invalid")!)
11 let document: UInt64 = 7
12 let id = windows.reserve(account: "a", document: document, title: "One", client: first)
13 #expect(windows.reserve(account: "a", document: document, title: "Renamed", client: first) == id)
14 #expect(windows.entries.count == 1)
15 #expect(!windows.canSignOut("a"))
16 #expect(windows.reserve(account: "b", document: document, title: "Other account", client: first) != id)
17 #expect(windows.reserve(account: "a", document: document, title: "Other server", client: second) != id)
18 #expect(windows.entries.count == 3)
19 windows.setOpen(id, false)
20 #expect(!windows.canSignOut("a"))
21 for entry in windows.entries where entry.account == "a" { windows.setOpen(entry.id, false) }
22 #expect(windows.canSignOut("a"))
23 windows.updateRecents([(document, "Current title")], account: "a", client: first)
24 #expect(windows.entries.first(where: { $0.id == id })?.title == "Current title")
25 #expect(windows.entries.first(where: { $0.id == id })?.isOpen == false)
26}
27#endif
28