#if os(macOS) import Foundation import Testing import RastrilloApple @testable import SheetsMac @MainActor @Test func windowsReuseDocumentsWithinAccountAndOriginOnly() { let windows = SheetsWindows() let first = NativeHTTP(origin: URL(string: "https://first.invalid")!) let second = NativeHTTP(origin: URL(string: "https://second.invalid")!) let document: UInt64 = 7 let id = windows.reserve(account: "a", document: document, title: "One", client: first) #expect(windows.reserve(account: "a", document: document, title: "Renamed", client: first) == id) #expect(windows.entries.count == 1) #expect(!windows.canSignOut("a")) #expect(windows.reserve(account: "b", document: document, title: "Other account", client: first) != id) #expect(windows.reserve(account: "a", document: document, title: "Other server", client: second) != id) #expect(windows.entries.count == 3) windows.setOpen(id, false) #expect(!windows.canSignOut("a")) for entry in windows.entries where entry.account == "a" { windows.setOpen(entry.id, false) } #expect(windows.canSignOut("a")) windows.updateRecents([(document, "Current title")], account: "a", client: first) #expect(windows.entries.first(where: { $0.id == id })?.title == "Current title") #expect(windows.entries.first(where: { $0.id == id })?.isOpen == false) } #endif