You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
6.3 KiB

// Copyright © 2015 Abhishek Banthia
import XCTest
class OnboardingTests: XCTestCase {
var app: XCUIApplication!
static let kOnboardingTestsLaunchArgument = "isTestingTheOnboardingFlow"
override func setUp() {
continueAfterFailure = false
app = XCUIApplication()
app.launchArguments.append(Self.kOnboardingTestsLaunchArgument)
app.launch()
}
// We test a couple of things in the Onboarding Process
// 1. The flow (forward button and back button take the user to the correct screen)
// 2. Static texts and button title's are appropriate
func testForwardButton() {
welcomeControllerTests()
6 years ago
// Let's go to the Permissions View
moveForward()
permissionsControllerTests()
6 years ago
// Time to test the launchAtLoginView
moveForward()
startupControllerTests()
6 years ago
// Let's go to OnboardingSearchController
moveForward()
searchControllerTests()
6 years ago
// Let's go to the FinalOnboardingController
moveForward()
finalOnboardingControllerTests()
6 years ago
backButtonTests()
}
6 years ago
func backButtonTests() {
moveBackward()
searchControllerTests()
6 years ago
moveBackward()
startupControllerTests()
6 years ago
moveBackward()
permissionsControllerTests()
6 years ago
moveBackward()
welcomeControllerTests()
6 years ago
alternateStartupFlowTests()
}
6 years ago
func alternateStartupFlowTests() {
// Let's go to the Permissions View
moveForward()
permissionsControllerTests()
6 years ago
// Time to test the launchAtLoginView
moveForward()
startupControllerTests()
6 years ago
// Let's go to OnboardingSearchController
alternateMoveForward()
searchControllerTests()
6 years ago
// Let's go to the FinalOnboardingController
moveForward()
finalOnboardingControllerTests()
6 years ago
moveForward()
XCTAssertTrue(app.statusItems.count > 0, "Status item was not installed in the menubar")
}
6 years ago
private func moveForward() {
let onboardingWindow = app.windows["OnboardingWindow"]
onboardingWindow.buttons["Forward"].click()
sleep(1)
}
6 years ago
private func alternateMoveForward() {
let onboardingWindow = app.windows["OnboardingWindow"]
onboardingWindow.buttons["Alternate"].click()
sleep(1)
}
6 years ago
private func moveBackward() {
let onboardingWindow = app.windows["OnboardingWindow"]
onboardingWindow.buttons["Backward"].click()
sleep(1)
}
6 years ago
private func welcomeControllerTests() {
let onboardingWindow = app.windows["OnboardingWindow"]
6 years ago
// Tests static texts
5 years ago
XCTAssertTrue(onboardingWindow.staticTexts["CFBundleDisplayName".localizedString()].exists, "Static text Clocker was unexpectedly missing")
XCTAssertTrue(onboardingWindow.staticTexts["It only takes 3 steps to set up Clocker.".localizedString()].exists, "Accessory label's static text was unexpectedly wrong.")
6 years ago
let button = onboardingWindow.buttons["Forward"]
6 years ago
// Test the button title
XCTAssertTrue(button.exists, "Button title was unexpectedly wrong. Expected \"Get Started\", Actual: \"\(onboardingWindow.buttons.firstMatch.title)\" ")
6 years ago
XCTAssertTrue(onboardingWindow.buttons.count == 1, "More than 1 button on Welcome screen!")
}
6 years ago
private func permissionsControllerTests() {
let onboardingWindow = app.windows["OnboardingWindow"]
6 years ago
5 years ago
XCTAssertTrue(onboardingWindow.staticTexts["Permissions".localizedString()].exists, "Header label's static text was unexpectedly wrong.")
8 months ago
XCTAssertTrue(onboardingWindow.staticTexts["Your data doesn't leave your device 🔐"].exists, "Onboarding Info label's static text was unexpectedly wrong.")
6 years ago
5 years ago
XCTAssertTrue(onboardingWindow.buttons["Forward"].title == "Continue".localizedString(), "Forward button title's was unexpectedly wrong")
XCTAssertTrue(onboardingWindow.buttons["Backward"].exists, "Back button was unexpectedly missing")
XCTAssertFalse(onboardingWindow.buttons["Alternate"].exists, "Alternate button was unexpectedly present.")
}
6 years ago
private func startupControllerTests() {
let onboardingWindow = app.windows["OnboardingWindow"]
6 years ago
4 years ago
XCTAssertTrue(onboardingWindow.buttons["Forward"].title == "Open Clocker At Login".localizedString(), "Forward button title's was unexpectedly wrong")
XCTAssertTrue(onboardingWindow.buttons["Alternate"].title == "Don't Open".localizedString(), "Alternate button title's was unexpectedly wrong")
6 years ago
5 years ago
XCTAssertTrue(onboardingWindow.staticTexts["Launch at Login".localizedString()].exists, "Header label's static text was unexpectedly wrong.")
XCTAssertTrue(onboardingWindow.staticTexts["Should Clocker open automatically on startup?".localizedString()].exists, "Accessory label's static text was unexpectedly wrong.")
}
6 years ago
private func searchControllerTests() {
6 years ago
let onboardingWindow = app.windows["OnboardingWindow"]
6 years ago
XCTAssertFalse(onboardingWindow.buttons["Alternate"].exists, "Alternate button was unexpectedly present.")
5 years ago
XCTAssertTrue(onboardingWindow.buttons["Forward"].title == "Continue".localizedString(), "Forward button title's was unexpectedly wrong")
6 years ago
5 years ago
XCTAssertTrue(onboardingWindow.staticTexts["Quick Add Locations".localizedString()].exists, "Header label's static text was unexpectedly wrong.")
4 years ago
XCTAssertTrue(onboardingWindow.staticTexts["More search options in Clocker Preferences.".localizedString()].exists, "Accessory label's static text was unexpectedly wrong.")
}
6 years ago
private func finalOnboardingControllerTests() {
let onboardingWindow = app.windows["OnboardingWindow"]
6 years ago
// Let's test the buttons
4 years ago
XCTAssertTrue(onboardingWindow.staticTexts["You're all set!".localizedString()].exists, "Header label's static text was unexpectedly wrong.")
XCTAssertTrue(onboardingWindow.staticTexts["Thank you for the details.".localizedString()].exists, "Accessory label's static text was unexpectedly wrong.")
6 years ago
4 years ago
XCTAssertFalse(onboardingWindow.buttons["Alternate".localizedString()].exists, "Alternate button was unexpectedly present.")
XCTAssertTrue(onboardingWindow.buttons["Forward".localizedString()].title == "Launch Clocker".localizedString(), "Forward button's title was unexpectedly wrong.")
}
}