Skip to content

Instantly share code, notes, and snippets.

@subdan
Last active September 18, 2020 06:57
Show Gist options
  • Save subdan/c5698fac4ce102b8d72ce8a79f86895d to your computer and use it in GitHub Desktop.
Save subdan/c5698fac4ce102b8d72ce8a79f86895d to your computer and use it in GitHub Desktop.
import XCTest
final class LoginAnalyticsTests: TestBase {
private let auth = LoginScreen()
private let onboarding = OnboardingScreen()
// Открытие экрана авторизации
func testOpenAuthMetricEvent() {
launchApp(with: .init(skipAuth: false, sendMetricsToPasteboard: true))
waitForElement(onboarding.continueButton)
onboarding.continueButton.tap()
waitForElement(auth.helpButton)
analytics.assertContains(name: "open_auth")
}
// Успешная авторизация
func testAuthMetricEvent() {
launchApp(with: .init(skipAuth: false, sendMetricsToPasteboard: true))
waitForElement(onboarding.continueButton)
onboarding.continueButton.tap()
waitForElement(auth.helpButton)
auth.fillLogin(login: "login@log.in")
auth.fillPassword(password: "password")
auth.loginButton.tap()
analytics.assertContains("authorization", ["response_type": "success"])
}
// Не удалось авторизоваться
func testAuthErrorMetricEvent() {
addMock(LoginMock.auth_401_invalid_credentials)
launchApp(with: .init(skipAuth: false, sendMetricsToPasteboard: true))
waitForElement(onboarding.continueButton)
onboarding.continueButton.tap()
waitForElement(auth.helpButton)
auth.fillLogin(login: "login@log.in")
auth.fillPassword(password: "password")
auth.loginButton.tap()
waitForElement(auth.snackText)
analytics.assertContains("authorization", ["response_type": "error"])
}
// Помощь по входу
func testAuthHelpMetricEvent() {
launchApp(with: .init(skipAuth: false, sendMetricsToPasteboard: true))
waitForElement(onboarding.continueButton)
onboarding.continueButton.tap()
waitForElement(auth.helpButton)
auth.helpButton.tap()
analytics.assertContains(name: "auth_help")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment