changeset 132:9439c76e6590

Add tests
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Mon, 16 Aug 2021 18:22:46 +0100
parents 501ea028ea5e
children f54d3dabb2d3
files SimoleonUITests/SimoleonUITests.swift
diffstat 1 files changed, 59 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/SimoleonUITests/SimoleonUITests.swift	Mon Aug 16 18:22:38 2021 +0100
+++ b/SimoleonUITests/SimoleonUITests.swift	Mon Aug 16 18:22:46 2021 +0100
@@ -11,6 +11,13 @@
 
     override func setUpWithError() throws {
         // Put setup code here. This method is called before the invocation of each test method in the class.
+        if UIDevice.current.userInterfaceIdiom == .pad {
+            XCUIDevice.shared.orientation = .landscapeLeft
+        }
+        
+        let app = XCUIApplication()
+        app.launchArguments += ["-AppleLocale", "en_US"]
+        app.launch()
 
         // In UI tests it is usually best to stop immediately when a failure occurs.
         continueAfterFailure = false
@@ -21,7 +28,58 @@
     override func tearDownWithError() throws {
         // Put teardown code here. This method is called after the invocation of each test method in the class.
     }
-
+    
+    func testTabBar() throws {
+        let app = XCUIApplication()
+        if UIDevice.current.userInterfaceIdiom == .pad {
+            app.tables["Sidebar"].buttons["NavigateToConversion"].tap()
+            XCTAssertTrue(app.staticTexts["Convert"].exists)
+            
+            app.tables["Sidebar"].buttons["NavigateToFavorites"].tap()
+            XCTAssertTrue(app.staticTexts["Favorites"].exists)
+            
+            app.tables["Sidebar"].buttons["NavigateToSettings"].tap()
+            XCTAssertTrue(app.staticTexts["Settings"].exists)
+        } else {
+            app.tabBars.buttons.element(boundBy: 0).tap()
+            XCTAssertTrue(app.staticTexts["Convert"].exists)
+            
+            app.tabBars.buttons.element(boundBy: 1).tap()
+            XCTAssertTrue(app.staticTexts["Favorites"].exists)
+            
+            app.tabBars.buttons.element(boundBy: 2).tap()
+            XCTAssertTrue(app.staticTexts["Settings"].exists)
+            
+        }
+    }
+    
+    func testCurrencySelector() throws {
+        let app = XCUIApplication()
+        app.scrollViews.buttons["OpenCurrencySelector"].tap()
+        
+        let currencySearchBar = app.textFields["CurrencySearchBar"]
+        currencySearchBar.tap()
+        currencySearchBar.typeText("USD/BTC")
+        app.tables.buttons["From USD to BTC"].tap()
+    }
+    
+    func testCoreData() throws {
+        let app = XCUIApplication()
+        app.scrollViews.buttons["favorite"].tap()
+        
+        if UIDevice.current.userInterfaceIdiom == .pad {
+            app.tables["Sidebar"].buttons["NavigateToFavorites"].tap()
+        } else {
+            app.tabBars.buttons.element(boundBy: 1).tap()
+        }
+        
+        XCTAssertTrue(app.tables.buttons["From USD to GBP"].exists)
+        
+        let favoriteList = app.tables
+        favoriteList.buttons["From USD to GBP"].swipeLeft()
+        favoriteList.buttons["Delete"].tap()
+        XCTAssertFalse(app.tables.buttons["From USD to GBP"].exists)
+    }
 
     func testLaunchPerformance() throws {
         if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {