Base fixes and test harness
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
import XCTest
|
||||
|
||||
/// UI Tests for Portfolio Journal app
|
||||
/// These tests verify the app's user interface and navigation flows
|
||||
final class PortfolioJournalUITests: XCTestCase {
|
||||
|
||||
var app: XCUIApplication!
|
||||
|
||||
override func setUpWithError() throws {
|
||||
continueAfterFailure = false
|
||||
app = XCUIApplication()
|
||||
app.launchArguments = ["--uitesting"]
|
||||
app.launch()
|
||||
}
|
||||
|
||||
override func tearDownWithError() throws {
|
||||
app = nil
|
||||
}
|
||||
|
||||
// MARK: - App Launch Tests
|
||||
|
||||
func testAppLaunches() throws {
|
||||
// Verify the app launches successfully
|
||||
XCTAssertTrue(app.exists)
|
||||
}
|
||||
|
||||
func testTabBarExists() throws {
|
||||
// Wait for the tab bar to appear
|
||||
let tabBar = app.tabBars.firstMatch
|
||||
let exists = tabBar.waitForExistence(timeout: 5)
|
||||
XCTAssertTrue(exists, "Tab bar should exist after launch")
|
||||
}
|
||||
|
||||
// MARK: - Navigation Tests
|
||||
|
||||
func testDashboardTabIsSelected() throws {
|
||||
// Dashboard should be the default selected tab
|
||||
let tabBar = app.tabBars.firstMatch
|
||||
_ = tabBar.waitForExistence(timeout: 5)
|
||||
|
||||
// Look for Dashboard tab button
|
||||
let dashboardTab = tabBar.buttons["Dashboard"]
|
||||
if dashboardTab.exists {
|
||||
XCTAssertTrue(dashboardTab.isSelected || dashboardTab.isHittable)
|
||||
}
|
||||
}
|
||||
|
||||
func testNavigateToSourcesTab() throws {
|
||||
let tabBar = app.tabBars.firstMatch
|
||||
_ = tabBar.waitForExistence(timeout: 5)
|
||||
|
||||
let sourcesTab = tabBar.buttons["Sources"]
|
||||
if sourcesTab.exists {
|
||||
sourcesTab.tap()
|
||||
// Verify we're on the Sources screen
|
||||
XCTAssertTrue(sourcesTab.isSelected || sourcesTab.isHittable)
|
||||
}
|
||||
}
|
||||
|
||||
func testNavigateToGoalsTab() throws {
|
||||
let tabBar = app.tabBars.firstMatch
|
||||
_ = tabBar.waitForExistence(timeout: 5)
|
||||
|
||||
let goalsTab = tabBar.buttons["Goals"]
|
||||
if goalsTab.exists {
|
||||
goalsTab.tap()
|
||||
XCTAssertTrue(goalsTab.isSelected || goalsTab.isHittable)
|
||||
}
|
||||
}
|
||||
|
||||
func testNavigateToJournalTab() throws {
|
||||
let tabBar = app.tabBars.firstMatch
|
||||
_ = tabBar.waitForExistence(timeout: 5)
|
||||
|
||||
let journalTab = tabBar.buttons["Journal"]
|
||||
if journalTab.exists {
|
||||
journalTab.tap()
|
||||
XCTAssertTrue(journalTab.isSelected || journalTab.isHittable)
|
||||
}
|
||||
}
|
||||
|
||||
func testNavigateToSettingsTab() throws {
|
||||
let tabBar = app.tabBars.firstMatch
|
||||
_ = tabBar.waitForExistence(timeout: 5)
|
||||
|
||||
let settingsTab = tabBar.buttons["Settings"]
|
||||
if settingsTab.exists {
|
||||
settingsTab.tap()
|
||||
XCTAssertTrue(settingsTab.isSelected || settingsTab.isHittable)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - All Tabs Navigation Test
|
||||
|
||||
func testNavigateThroughAllTabs() throws {
|
||||
let tabBar = app.tabBars.firstMatch
|
||||
guard tabBar.waitForExistence(timeout: 5) else {
|
||||
XCTFail("Tab bar not found")
|
||||
return
|
||||
}
|
||||
|
||||
let tabs = ["Dashboard", "Sources", "Goals", "Journal", "Settings"]
|
||||
|
||||
for tabName in tabs {
|
||||
let tab = tabBar.buttons[tabName]
|
||||
if tab.exists && tab.isHittable {
|
||||
tab.tap()
|
||||
// Give time for navigation
|
||||
Thread.sleep(forTimeInterval: 0.3)
|
||||
}
|
||||
}
|
||||
|
||||
// Return to Dashboard
|
||||
let dashboardTab = tabBar.buttons["Dashboard"]
|
||||
if dashboardTab.exists {
|
||||
dashboardTab.tap()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import XCTest
|
||||
|
||||
/// Launch performance tests for Portfolio Journal
|
||||
final class PortfolioJournalUITestsLaunchTests: XCTestCase {
|
||||
|
||||
override class var runsForEachTargetApplicationUIConfiguration: Bool {
|
||||
true
|
||||
}
|
||||
|
||||
override func setUpWithError() throws {
|
||||
continueAfterFailure = false
|
||||
}
|
||||
|
||||
func testLaunch() throws {
|
||||
let app = XCUIApplication()
|
||||
app.launch()
|
||||
|
||||
// Take a screenshot after launch
|
||||
let attachment = XCTAttachment(screenshot: app.screenshot())
|
||||
attachment.name = "Launch Screen"
|
||||
attachment.lifetime = .keepAlways
|
||||
add(attachment)
|
||||
}
|
||||
|
||||
func testLaunchPerformance() throws {
|
||||
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
|
||||
measure(metrics: [XCTApplicationLaunchMetric()]) {
|
||||
XCUIApplication().launch()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import XCTest
|
||||
|
||||
/// UI Tests for Settings functionality
|
||||
final class SettingsUITests: XCTestCase {
|
||||
|
||||
var app: XCUIApplication!
|
||||
|
||||
override func setUpWithError() throws {
|
||||
continueAfterFailure = false
|
||||
app = XCUIApplication()
|
||||
app.launchArguments = ["--uitesting"]
|
||||
app.launch()
|
||||
|
||||
// Navigate to Settings tab
|
||||
let tabBar = app.tabBars.firstMatch
|
||||
_ = tabBar.waitForExistence(timeout: 5)
|
||||
let settingsTab = tabBar.buttons["Settings"]
|
||||
if settingsTab.exists {
|
||||
settingsTab.tap()
|
||||
}
|
||||
}
|
||||
|
||||
override func tearDownWithError() throws {
|
||||
app = nil
|
||||
}
|
||||
|
||||
// MARK: - Settings Screen Tests
|
||||
|
||||
func testSettingsScreenLoads() throws {
|
||||
// Verify settings content is visible
|
||||
// Look for common settings elements
|
||||
let settingsView = app.scrollViews.firstMatch
|
||||
XCTAssertTrue(settingsView.exists || app.collectionViews.firstMatch.exists || app.tables.firstMatch.exists)
|
||||
}
|
||||
|
||||
func testCurrencySettingExists() throws {
|
||||
// Look for currency-related UI elements
|
||||
let currencyLabel = app.staticTexts["Currency"]
|
||||
if currencyLabel.waitForExistence(timeout: 2) {
|
||||
XCTAssertTrue(currencyLabel.exists)
|
||||
}
|
||||
}
|
||||
|
||||
func testAppVersionDisplayed() throws {
|
||||
// Scroll to bottom if needed and look for version info
|
||||
let scrollView = app.scrollViews.firstMatch
|
||||
if scrollView.exists {
|
||||
scrollView.swipeUp()
|
||||
}
|
||||
|
||||
// Version text is usually at the bottom
|
||||
Thread.sleep(forTimeInterval: 0.5)
|
||||
|
||||
// Just verify the settings screen is still visible after scrolling
|
||||
let tabBar = app.tabBars.firstMatch
|
||||
XCTAssertTrue(tabBar.exists)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user