//
//  MyProfileTests.swift
//  TuskerUITests
//
//  Created by Shadowfacts on 12/31/19.
//  Copyright © 2019 Shadowfacts. All rights reserved.
//

import XCTest

class MyProfileTests: TuskerUITests {

    override func setUp() {
        super.setUp()
        
//        router.allRoutes()

        app.launchEnvironment["UI_TESTING_LOGIN"] = "true"
        app.launch()
    }
    
    func testProfileHeader() {
        app.tabBars.buttons["My Profile"].tap()
        
        XCTAssertTrue(app.staticTexts["Admin Account"].exists)
        XCTAssertTrue(app.staticTexts["@admin"].exists)
        XCTAssertTrue(app.staticTexts["My profile description."].exists)
        
        let segmented = app.segmentedControls.firstMatch
        XCTAssertTrue(segmented.exists)
        XCTAssertEqual(segmented.buttons.count, 3)
        XCTAssertTrue(segmented.buttons["Posts"].exists)
        XCTAssertTrue(segmented.buttons["Posts and Replies"].exists)
        XCTAssertTrue(segmented.buttons["Media"].exists)
        
        XCTAssertTrue(app.buttons["More Actions"].exists)
        
        app.buttons["More Actions"].tap()
        XCTAssertTrue(app.buttons["Open in Safari"].exists)
        XCTAssertTrue(app.buttons["Share..."].exists)
        XCTAssertTrue(app.buttons["Send Message"].exists)
        
        app.buttons["Open in Safari"].tap()
        XCTAssertTrue(app.otherElements["TopBrowserBar"].exists)
        app.buttons["Done"].tap()
        XCTAssertFalse(app.otherElements["TopBrowserBar"].exists)
        
        app.buttons["More Actions"].tap()
        app.buttons["Share..."].tap()
        let activityListView = app.otherElements["ActivityListView"]
        XCTAssertTrue(activityListView.waitForExistence(timeout: 0.2))
        activityListView.buttons["Close"].tap()
        XCTAssertFalse(activityListView.exists)
        
        app.buttons["More Actions"].tap()
        app.buttons["Send Message"].tap()
        XCTAssertTrue(app.staticTexts["Compose"].exists)
        XCTAssertTrue(app.buttons["Cancel"].exists)
        XCTAssertTrue(app.buttons["Post"].exists)
        app.buttons["Cancel"].tap()
    }

}
