Cotton code
53 lines · 2.5 KB · SwiftRaw
// How the settings sheet opens the seven Settings tables (rebuild note// 7b95efa4: "Settings are lists and pages drawn by the same interpreter"):// each one's row opens that table's list, a slip opens its page, and the// hand-drawn screens they replaced are gone.import CottonKitimport Foundationimport XCTest@testable import CottonUIfinal class SettingsTablesOpenTests: XCTestCase {    /// The screens and models the lists and pages replaced. Not one of them    /// may be declared again: a second way to draw a device is a second place    /// its approve and remove can disagree.    static let replaced = [        "DevicesScreen", "DeviceScreen", "DevicesToolModel", "DeviceSheetContent", "DeviceSheetState",        "PendingPairingRow", "YourDevices", "DeviceCard", "DeviceCardView",    ]    /// The connection sheets the Connected list and its pages replaced, with    /// their models. Google's connect is the Calendar tool's own act now    /// (`tools.act`).    static let connectionSheets = [        "ConnectedAisScreen", "ConnectedAisModel", "GoogleScreen", "GoogleModel", "CodeHostingScreen", "CodeHostingModel",    ]    private func code(_ path: String) throws -> String {        SourceSweep.withoutComments(try SourceSweep.mustRead("apps/cotton/Sources/CottonUI/" + path, ownedBy: "the Settings tables"))    }    /// RULE: The open Feedback list reads again when a report is written, so a report sent over it shows at once.    func testTheFeedbackListReadsAgainWhenAReportIsWritten() {        XCTAssertTrue(InvalidationMap.families(for: ["cotton_feedback"], origin: nil).contains(.feedback))    }    /// RULE: An open Storage list or page follows local media arrivals, eviction and record changes, so its sizes do not wait for Back.    func testTheStorageRouteReadsAgainWhenMediaMoves() throws {        let family = ScreenFamily.storage        XCTAssertTrue(InvalidationMap.families(for: ["_media"], origin: ClientEvent.localMediaOrigin).contains(family))        for table in ["cotton_photos", "cotton_videos", "cotton_documents", "cotton_storage_rules"] {            XCTAssertTrue(InvalidationMap.families(for: [table], origin: nil).contains(family), table)        }    }    /// RULE: A table with a route and no Settings row is opened by its route, never by a settings-sheet row.    func testARoutedTableIsOpenedByItsRoute() throws {        // No settings-sheet row opens one.        let rows = Set(SettingsTables.entries.map(\.table))        XCTAssertTrue(SettingsTables.routed.allSatisfy { !rows.contains($0.table) })    }}