SPB Git

Repository Public MIT

GlassStudioUITests.swift 7.5 KB 145 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project          : SP GlassKit7// File             : Apps/GlassStudio/UITests/GlassStudioUITests.swift8// Module           : GlassStudio9// Repository       : https://git.spboucher.ai/sp-glasskit10// Project Website  : https://glass.spboucher.ai11// Created          : 2026-12-0212// Last Modified    : 2026-12-0213//14// Author           : Simon-Pierre Boucher15// Position         : Professor of Finance16// Institution      : Université du Québec en Outaouais (UQO)17// Organization     : SP Boucher18// Website          : https://spboucher.ai19// Git              : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development      : dev@spboucher.ai23// Support          : support@spboucher.ai24// Security/Admin   : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License          : MIT33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041import XCTest4243/// End-to-end checks on the running Studio. Each test starts from launch arguments and a private data44/// directory, so nothing depends on, or touches, the user's own Studio data.45final class GlassStudioUITests: XCTestCase {46    private var dataDirectory: URL!4748    override func setUpWithError() throws {49        continueAfterFailure = false50        dataDirectory = FileManager.default.temporaryDirectory.appendingPathComponent("glassstudio-uitests-\(UUID().uuidString)")51    }5253    private func launch(_ arguments: [String] = []) -> XCUIApplication {54        let app = XCUIApplication()55        app.launchArguments = ["-studioDataDirectory", dataDirectory.path, "-studioLanguage", "en", "-AppleLanguages", "(en)"] + arguments56        app.launch()57        return app58    }5960    func testCatalogueSearchOpensAComponentWithItsPreviewAndCode() throws {61        let app = launch(["-studioSection", "catalog"])62        XCTAssertTrue(app.descendants(matching: .any)["component-glass-tab-bar"].firstMatch.waitForExistence(timeout: 20))63        let search = app.searchFields.firstMatch64        XCTAssertTrue(search.waitForExistence(timeout: 10))65        search.tap()66        search.typeText("split button\n")   // Return dismisses the keyboard, which otherwise covers the results67        let row = app.descendants(matching: .any)["component-glass-split-button"].firstMatch68        XCTAssertTrue(row.waitForExistence(timeout: 10))69        XCTAssertFalse(app.descendants(matching: .any)["component-glass-toast"].exists, "the search filters the gallery")70        row.tap()71        XCTAssertTrue(app.descendants(matching: .any)["component-preview"].waitForExistence(timeout: 10))72        XCTAssertTrue(app.descendants(matching: .any)["copy-code"].firstMatch.waitForExistence(timeout: 10))73    }7475    func testLaunchArgumentsOpenAComponentInAThemeAndTheCodeTabCopies() throws {76        let app = launch(["-studioComponent", "glass-button", "-studioTheme", "aurora", "-studioAppearance", "dark", "-studioTab", "code"])77        let copy = app.descendants(matching: .any)["copy-code"].firstMatch78        XCTAssertTrue(copy.waitForExistence(timeout: 20))79        XCTAssertTrue(app.staticTexts.containing(NSPredicate(format: "label CONTAINS 'spglass add glass-button' OR value CONTAINS 'spglass add glass-button'")).firstMatch.waitForExistence(timeout: 5) || app.descendants(matching: .any).containing(NSPredicate(format: "value CONTAINS 'spglass add glass-button'")).firstMatch.exists)80        copy.tap()81        XCTAssertTrue(app.buttons["Copied"].waitForExistence(timeout: 5), "copying is confirmed in the interface")82    }8384    func testTappingACatalogueCardOpensItsPreview() throws {85        let app = launch(["-studioSection", "catalog"])86        // The gallery is lazy: narrow it to one category so that the card is on screen.87        let chip = app.descendants(matching: .any)["category-buttons"].firstMatch88        XCTAssertTrue(chip.waitForExistence(timeout: 20))89        chip.tap()90        let card = app.descendants(matching: .any)["component-glass-button"].firstMatch91        XCTAssertTrue(card.waitForExistence(timeout: 10))92        card.tap()93        XCTAssertTrue(app.descendants(matching: .any)["component-preview"].waitForExistence(timeout: 10))94        XCTAssertTrue(app.staticTexts["GlassButton"].firstMatch.waitForExistence(timeout: 5), "the page names the component")95    }9697    func testNavigationComponentRunsFullScreen() throws {98        let app = launch(["-studioComponent", "glass-tab-bar"])99        let run = app.descendants(matching: .any)["run-live-preview"].firstMatch100        XCTAssertTrue(run.waitForExistence(timeout: 20))101        run.tap()102        let close = app.descendants(matching: .any)["close-live-preview"].firstMatch103        XCTAssertTrue(close.waitForExistence(timeout: 10))104        close.tap()105        XCTAssertTrue(run.waitForExistence(timeout: 10), "closing returns to the component page")106    }107108    func testFavouriteIsKeptAcrossLaunches() throws {109        var app = launch(["-studioComponent", "glass-toast"])110        let star = app.descendants(matching: .any)["toggle-favorite"].firstMatch111        XCTAssertTrue(star.waitForExistence(timeout: 20))112        star.tap()113        app.terminate()114        app = launch(["-studioSection", "favorites"])115        XCTAssertTrue(app.descendants(matching: .any)["component-glass-toast"].waitForExistence(timeout: 20))116    }117118    func testThemesAndPlaygroundScreensOpen() throws {119        var app = launch(["-studioSection", "themes"])120        XCTAssertTrue(app.descendants(matching: .any)["theme-aurora"].waitForExistence(timeout: 20))121        XCTAssertTrue(app.descendants(matching: .any)["new-theme"].firstMatch.exists)122        app.terminate()123        app = launch(["-studioSection", "playground", "-studioTemplate", "dashboard"])124        XCTAssertTrue(app.descendants(matching: .any)["playground-export"].firstMatch.waitForExistence(timeout: 20))125    }126127    func testFrenchInterface() throws {128        let app = XCUIApplication()129        app.launchArguments = ["-studioDataDirectory", dataDirectory.path, "-studioLanguage", "fr", "-studioSection", "settings"]130        app.launch()131        XCTAssertTrue(app.staticTexts["Langue de l’interface"].waitForExistence(timeout: 20) || app.descendants(matching: .any).matching(NSPredicate(format: "label == 'Langue de l’interface'")).firstMatch.waitForExistence(timeout: 5))132    }133134    func testAccessibilityAuditOfAComponentScreen() throws {135        let app = launch(["-studioComponent", "glass-button"])136        XCTAssertTrue(app.descendants(matching: .any)["component-preview"].waitForExistence(timeout: 20))137        // Contrast and clipping depend on the live backdrop behind system glass; the audit covers the checks138        // that are deterministic: labels, traits and hit regions.139        try app.performAccessibilityAudit(for: [.sufficientElementDescription, .trait, .hitRegion]) { issue in140            // Elements drawn by the system toolbar and search field are outside the Studio's control.141            issue.element == nil142        }143    }144}145
Files main
Menu

Theme