From 108ca3f349c2fbd5fa0193209e17ffa351d1dd82 Mon Sep 17 00:00:00 2001 From: Andreas Bauer Date: Mon, 20 Nov 2023 13:49:33 -0800 Subject: [PATCH] Test account deletion --- .../FirebaseAccountStorageTests.swift | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Tests/UITests/TestAppUITests/FirebaseAccountStorageTests.swift b/Tests/UITests/TestAppUITests/FirebaseAccountStorageTests.swift index 8fd0bcf..623712b 100644 --- a/Tests/UITests/TestAppUITests/FirebaseAccountStorageTests.swift +++ b/Tests/UITests/TestAppUITests/FirebaseAccountStorageTests.swift @@ -61,5 +61,26 @@ final class FirebaseAccountStorageTests: XCTestCase { app.navigationBars.buttons["Done"].tap() XCTAssertTrue(app.staticTexts["Biography, Hello Stanford2"].waitForExistence(timeout: 2.0)) + + // TEST ACCOUNT DELETION + XCTAssertTrue(app.navigationBars.buttons["Edit"].exists) + app.navigationBars.buttons["Edit"].tap() + + XCTAssertTrue(app.buttons["Delete Account"].waitForExistence(timeout: 4.0)) + app.buttons["Delete Account"].tap() + + let alert = "Are you sure you want to delete your account?" + XCTAssertTrue(XCUIApplication().alerts[alert].waitForExistence(timeout: 6.0)) + XCUIApplication().alerts[alert].scrollViews.otherElements.buttons["Delete"].tap() + + XCTAssertTrue(app.alerts["Authentication Required"].waitForExistence(timeout: 2.0)) + XCTAssertTrue(app.alerts["Authentication Required"].secureTextFields["Password"].waitForExistence(timeout: 0.5)) + app.typeText("TestPassword1") // the password field has focus already + XCTAssertTrue(app.alerts["Authentication Required"].buttons["Login"].waitForExistence(timeout: 0.5)) + app.alerts["Authentication Required"].buttons["Login"].tap() + + sleep(2) + let accountsNew = try await FirebaseClient.getAllAccounts() + XCTAssertTrue(accountsNew.isEmpty) } }