<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import XCTest

let getEndPoint = "http://restmail.net/mail/test-256a5b5b18"
let postEndPoint = "https://api-accounts.stage.mozaws.net/v1/recovery_email/verify_code"
let deleteEndPoint = "http://restmail.net/mail/test-256a5b5b18@restmail.net"

let userMail = "<EMAIL>"
let password = "<PASSWORD>"

var uid: String!
var code: String!

class SyncUITests: BaseTestCase {
    func testUIFromSettings () {
        navigator.goto(FxASigninScreen)
        verifyFxASigninScreen()
    }

    func testSyncUIFromBrowserTabMenu() {
        // Check menu available from HomeScreenPanel
        navigator.goto(BrowserTabMenu)
        waitforExistence(app.tables["Context Menu"].cells["menu-sync"])
        navigator.goto(FxASigninScreen)
        verifyFxASigninScreen()

        // Check menu available from a website
        navigator.openURL("mozilla.org")
        waitUntilPageLoad()
        navigator.goto(BrowserTabMenu)
        waitforExistence(app.tables["Context Menu"].cells["menu-sync"])
        navigator.goto(FxASigninScreen)
        verifyFxASigninScreen()
    }

    private func verifyFxASigninScreen() {
        waitforExistence(app.webViews.staticTexts["Sign in"])
        XCTAssertTrue(app.navigationBars["Client.FxAContentView"].exists)
        XCTAssertTrue(app.webViews.textFields["Email"].exists)
        XCTAssertTrue(app.webViews.secureTextFields["Password"].exists)
        // Verify the placeholdervalues here for the textFields
        let mailPlaceholder = "Email"
        let passwordPlaceholder = "Password"

        let defaultMailPlaceholder = app.webViews.textFields["Email"].placeholderValue!
        let defaultPasswordPlaceholder = app.webViews.secureTextFields["Password"].placeholderValue!
        XCTAssertEqual(mailPlaceholder, defaultMailPlaceholder, "The mail placeholder does not show the correct value")
        XCTAssertEqual(passwordPlaceholder, defaultPasswordPlaceholder, "The password placeholder does not show the correct value")
        XCTAssertTrue(app.webViews.buttons["Sign in"].exists)
    }

    func testTypeOnGivenFields() {
        navigator.goto(FxASigninScreen)
        waitforExistence(app.webViews.staticTexts["Sign in"])

        // Tap Sign in without any value in email Password focus on Email
        navigator.performAction(Action.FxATapOnSignInButton)
        waitforExistence(app.webViews.staticTexts["Valid email required"])

        // Enter only email, wrong and correct and tap sign in
        userState.fxaUsername = "bademail"
        navigator.performAction(Action.FxATypeEmail)
        navigator.performAction(Action.FxATapOnSignInButton)
        waitforExistence(app.webViews.staticTexts["Valid email required"])

        userState.fxaUsername = "<EMAIL>"
        navigator.performAction(Action.FxATypeEmail)
        navigator.performAction(Action.FxATapOnSignInButton)
        waitforExistence(app.webViews.staticTexts["Valid password required"])

        // Enter invalid (too short, it should be at least 8 chars) and incorrect password
        userState.fxaPassword = "<PASSWORD>"
        navigator.performAction(Action.FxATypePassword)
        navigator.performAction(Action.FxATapOnSignInButton)
        waitforExistence(app.webViews.staticTexts["Must be at least 8 characters"])

        // Enter valid but incorrect, it does not exists, password
        userState.fxaPassword = "<PASSWORD>"
        navigator.performAction(Action.FxATypePassword)
        navigator.performAction(Action.FxATapOnSignInButton)
        waitforExistence(app.webViews.staticTexts["Unknown account."])
        XCTAssertTrue(app.webViews.links["Sign up"].exists)
    }

    func testCreateAnAccountLink() {
        navigator.goto(FxASigninScreen)
        waitforExistence(app.webViews.links["Create an account"])
        navigator.goto(FxCreateAccount)
        waitforExistence(app.webViews.buttons["Create account"])
    }

    func testShowPassword() {
        // The aim of this test is to check if the option to show password is shown when user starts typing and dissapears when no password is typed
        navigator.goto(FxASigninScreen)
        waitforExistence(app.textFields["Email"])
<commit_msg>Bug 1500997 - XCUITests fix testTypeOnGivenFields (#4335)<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import XCTest

let getEndPoint = "http://restmail.net/mail/test-256a5b5b18"
let postEndPoint = "https://api-accounts.stage.mozaws.net/v1/recovery_email/verify_code"
let deleteEndPoint = "http://restmail.net/mail/test-256a5b5b18@restmail.net"

let userMail = "<EMAIL>"
let password = "<PASSWORD>"

var uid: String!
var code: String!

class SyncUITests: BaseTestCase {
    func testUIFromSettings () {
        navigator.goto(FxASigninScreen)
        verifyFxASigninScreen()
    }

    func testSyncUIFromBrowserTabMenu() {
        // Check menu available from HomeScreenPanel
        navigator.goto(BrowserTabMenu)
        waitforExistence(app.tables["Context Menu"].cells["menu-sync"])
        navigator.goto(FxASigninScreen)
        verifyFxASigninScreen()

        // Check menu available from a website
        navigator.openURL("mozilla.org")
        waitUntilPageLoad()
        navigator.goto(BrowserTabMenu)
        waitforExistence(app.tables["Context Menu"].cells["menu-sync"])
        navigator.goto(FxASigninScreen)
        verifyFxASigninScreen()
    }

    private func verifyFxASigninScreen() {
        waitforExistence(app.webViews.staticTexts["Sign in"])
        XCTAssertTrue(app.navigationBars["Client.FxAContentView"].exists)
        XCTAssertTrue(app.webViews.textFields["Email"].exists)
        XCTAssertTrue(app.webViews.secureTextFields["Password"].exists)
        // Verify the placeholdervalues here for the textFields
        let mailPlaceholder = "Email"
        let passwordPlaceholder = "Password"

        let defaultMailPlaceholder = app.webViews.textFields["Email"].placeholderValue!
        let defaultPasswordPlaceholder = app.webViews.secureTextFields["Password"].placeholderValue!
        XCTAssertEqual(mailPlaceholder, defaultMailPlaceholder, "The mail placeholder does not show the correct value")
        XCTAssertEqual(passwordPlaceholder, defaultPasswordPlaceholder, "The password placeholder does not show the correct value")
        XCTAssertTrue(app.webViews.buttons["Sign in"].exists)
    }

    func testTypeOnGivenFields() {
        navigator.goto(FxASigninScreen)
        waitforExistence(app.webViews.staticTexts["Sign in"])

        // Tap Sign in without any value in email Password focus on Email
        navigator.performAction(Action.FxATapOnSignInButton)
        waitforExistence(app.webViews.staticTexts["Valid email required"])

        // Enter only email, wrong and correct and tap sign in
        userState.fxaUsername = "bademail"
        navigator.performAction(Action.FxATypeEmail)
        navigator.performAction(Action.FxATapOnSignInButton)
        waitforExistence(app.webViews.staticTexts["Valid email required"])

        userState.fxaUsername = "<EMAIL>"
        navigator.performAction(Action.FxATypeEmail)
        navigator.performAction(Action.FxATapOnSignInButton)
        waitforExistence(app.webViews.staticTexts["Valid password required"])

        // Enter invalid (too short, it should be at least 8 chars) and incorrect password
        userState.fxaPassword = "<PASSWORD>"
        navigator.performAction(Action.FxATypePassword)
        navigator.performAction(Action.FxATapOnSignInButton)
        waitforExistence(app.webViews.staticTexts["Must be at least 8 characters"])

        // Enter valid but incorrect, it does not exists, password
        userState.fxaPassword = "<PASSWORD>"
        navigator.performAction(Action.FxATypePassword)
        navigator.performAction(Action.FxATapOnSignInButton)
        waitforExistence(app.webViews.staticTexts["Unknown account."], timeout: 10)
        XCTAssertTrue(app.webViews.links["Sign up"].exists)
    }

    func testCreateAnAccountLink() {
        navigator.goto(FxASigninScreen)
        waitforExistence(app.webViews.links["Create an account"])
        navigator.goto(FxCreateAccount)
        waitforExistence(app.webViews.buttons["Create account"])
    }

    func testShowPassword() {
        // The aim of this test is to check if the option to show password is shown when user starts typing and dissapears when no password is typed
        navigator.goto(FxASigninScreen)
        waitforExistence(app.textFields["Email"])

{'fraction_non_alphanumeric': 0.09259049131964144, 'fraction_numerical': 0.006240780664926813, 'mean_word_length': 3.557394002068252, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3600833', 'n_tokens_mistral': 2573, 'n_tokens_neox': 2497, 'n_words': 541}