import XCTest

final class HomeScreenUITests: ForgejoUITestBase {

    // MARK: - Home Screen (login, nav links, logout)

    @MainActor
    func testHomeScreen() throws {
        loginAndWaitForHome()

        // Verify home screen content
        XCTAssertTrue(app.tabBars.buttons["Repositories"].exists)

        // All nav links present
        XCTAssertTrue(app.tabBars.buttons["Issues"].exists)
        XCTAssertTrue(app.tabBars.buttons["Pull Requests"].exists)
        XCTAssertTrue(app.tabBars.buttons["Notifications"].exists)

        // Navigate to Settings tab and verify user info
        app.tabBars.buttons["Settings"].tap()
        XCTAssertTrue(app.staticTexts["@testadmin"].waitForExistence(timeout: 5))

        // Scroll down to reveal logout button (may be below the fold)
        app.swipeUp()

        // Logout returns to instance list
        let logoutButton = app.buttons["home-logout-button"]
        XCTAssertTrue(logoutButton.waitForExistence(timeout: 5))
        logoutButton.tap()

        let addButton = app.buttons["instance-add-button"]
        XCTAssertTrue(addButton.waitForExistence(timeout: 5))
    }
}
