import XCTest /// Verifies that a system exposes its voltage-drop budget and that picking a tighter /// target sticks, which is what drives cable sizing for that system. final class SystemVoltageDropTargetUITests: XCTestCase { override func setUpWithError() throws { try super.setUpWithError() continueAfterFailure = false XCUIDevice.shared.orientation = .portrait } @MainActor func testVoltageDropBudgetIsSelectableInSystemEditor() throws { let app = launch(arguments: ["--uitest-reset-data", "--uitest-sample-data"]) openFirstSystem(in: app) let systemTitle = app.buttons["system-title-button"] XCTAssertTrue(systemTitle.waitForExistence(timeout: 15)) systemTitle.tap() let picker = app.segmentedControls["system-voltage-drop-picker"] XCTAssertTrue(picker.waitForExistence(timeout: 15), "System editor must offer a voltage drop budget") let standard = picker.buttons["5 %"] XCTAssertTrue(standard.waitForExistence(timeout: 5)) XCTAssertTrue(standard.isSelected, "New systems start at the 5 % default") let critical = picker.buttons["3 %"] XCTAssertTrue(critical.exists) critical.tap() XCTAssertTrue(critical.isSelected, "Picking 3 % must stick") } // MARK: - Helpers private func launch(arguments: [String]) -> XCUIApplication { let app = XCUIApplication() app.launchArguments = arguments app.launch() return app } private func openFirstSystem(in app: XCUIApplication) { let list: XCUIElement if app.collectionViews["systems-list"].waitForExistence(timeout: 15) { list = app.collectionViews["systems-list"] } else { list = app.collectionViews.firstMatch } XCTAssertTrue(list.waitForExistence(timeout: 15)) let firstCell = list.cells.element(boundBy: 0) XCTAssertTrue(firstCell.waitForExistence(timeout: 10)) let cellButton = firstCell.buttons.firstMatch if cellButton.exists { cellButton.tap() } else { firstCell.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).tap() } } }