import XCTest /// Regression test for the App Store rejection (Guideline 2.1a): the /// "disconnect & delete account data" button was unresponsive. This drives the /// full flow: open settings, tap delete, confirm, and verify the app returns to /// the initial connect screen with the account data cleared. final class AccountDeletionUITests: XCTestCase { override func setUpWithError() throws { continueAfterFailure = false } private func launchConfigured() -> XCUIApplication { let app = XCUIApplication() // Argument-domain overrides win over the app's persisted UserDefaults, // so the app starts already connected to the test server. app.launchArguments = [ "-webdav.url", "https://test-denote.andros.dev", "-webdav.username", "reviewer", "-webdav.notesPath", "/notes/", "-debug.password", "DenoteTest2026", ] app.launch() return app } func testDeleteAccountButtonIsResponsiveAndClearsData() throws { let app = launchConfigured() // We start on the note list. let settingsButton = app.buttons["M-x settings"] XCTAssertTrue(settingsButton.waitForExistence(timeout: 10), "note list did not appear") settingsButton.tap() // Reach the delete button (scroll if needed). let deleteButton = app.buttons["[ disconnect & delete account data ]"] XCTAssertTrue(deleteButton.waitForExistence(timeout: 5), "delete button not found in settings") if !deleteButton.isHittable { app.swipeUp() } deleteButton.tap() // The button must respond by showing the confirmation alert. let alert = app.alerts["Delete account data?"] XCTAssertTrue(alert.waitForExistence(timeout: 5), "delete button was unresponsive: no confirmation alert") alert.buttons["Delete"].tap() // After deletion we land back on the initial connect screen. let testConnection = app.buttons["[ test connection ]"] XCTAssertTrue(testConnection.waitForExistence(timeout: 5), "did not return to connect screen after deletion") XCTAssertFalse(app.buttons["M-x settings"].exists, "still showing the note list after deletion") } }