<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.navigationBars["Client.FxAContentView"])
        XCTAssertTrue(app.navigationBars["Client.FxAContentView"].exists)
        XCTAssertTrue(app.webViews.textFields["Email"].exists)

        // Verify the placeholdervalues here for the textFields
        let mailPlaceholder = "Email"
        let defaultMailPlaceholder = app.webViews.textFields["Email"].placeholderValue!
        XCTAssertEqual(mailPlaceholder, defaultMailPlaceholder, "The mail placeholder does not show the correct value")
        XCTAssertTrue(app.webViews.buttons["Continue"].exists)
    }

    func testTypeOnGivenFields() {
        navigator.goto(FxASigninScreen)
        waitForExistence(app.navigationBars["Client.FxAContentView"])

        // Tap Sign in without any value in email Password focus on Email
        navigator.performAction(Action.FxATapOnContinueButton)
        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.FxATapOnContinueButton)
        waitForExistence(app.webViews.staticTexts["Valid email required"])

        userState.fxaUsername = "<EMAIL>"
        navigator.performAction(Action.FxATypeEmail)
        navigator.performAction(Action.FxATapOnSignInButton)

        // 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.staticTexts["Create a Firefox Account"], timeout: 10)
    }

    func testCreateAnAccountLink() {
        navigator.goto(FxASigninScreen)
        waitForExistence(app.navigationBars["Client.FxAContentView"], timeout: 3)
        userState.fxaUsername = "<EMAIL>"
        navigator.performAction(Action.FxATypeEmail)
        navigator.performAction(Action.FxATapOnContinueButton)
        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.navigationBars["Client.FxAContentView"], timeout: 15)

        // Typing on Email should not show Show (password) option
        userState.fxaUsername = "<EMAIL>"
        navigator.performAction(Action.FxATypeEmail)
        navigator.performAction(Action.FxATapOnContinueButton)
        // Typing on Password should show Show (password) option
        userState.fxaPassword = "f"
        navigator.performAction(Action.FxATypePassword)
        waitForExistence(app.webViews.staticTexts["Show password"])
        // Remove the password typed, Show (password) option should not be shown
        app.secureTextFields.element(boundBy: 0).typeText(XCUIKeyboardKey.delete.rawValue)
        waitForNoExistence(app.webViews.staticTexts["Show password"])<commit_msg>Fix #5221 - XCUITest typeOnGivenField no link found due to recent changes (#5222)<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.navigationBars["Client.FxAContentView"])
        XCTAssertTrue(app.navigationBars["Client.FxAContentView"].exists)
        XCTAssertTrue(app.webViews.textFields["Email"].exists)

        // Verify the placeholdervalues here for the textFields
        let mailPlaceholder = "Email"
        let defaultMailPlaceholder = app.webViews.textFields["Email"].placeholderValue!
        XCTAssertEqual(mailPlaceholder, defaultMailPlaceholder, "The mail placeholder does not show the correct value")
        XCTAssertTrue(app.webViews.buttons["Continue"].exists)
    }

    func testTypeOnGivenFields() {
        navigator.goto(FxASigninScreen)
        waitForExistence(app.navigationBars["Client.FxAContentView"])

        // Tap Sign in without any value in email Password focus on Email
        navigator.performAction(Action.FxATapOnContinueButton)
        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.FxATapOnContinueButton)
        waitForExistence(app.webViews.staticTexts["Valid email required"])

        userState.fxaUsername = "<EMAIL>"
        navigator.performAction(Action.FxATypeEmail)
        navigator.performAction(Action.FxATapOnSignInButton)

        // 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)
        waitForExistence(app.secureTextFields["Repeat password"], timeout: 10)
    }

    func testCreateAnAccountLink() {
        navigator.goto(FxASigninScreen)
        waitForExistence(app.navigationBars["Client.FxAContentView"], timeout: 3)
        userState.fxaUsername = "<EMAIL>"
        navigator.performAction(Action.FxATypeEmail)
        navigator.performAction(Action.FxATapOnContinueButton)
        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.navigationBars["Client.FxAContentView"], timeout: 15)

        // Typing on Email should not show Show (password) option
        userState.fxaUsername = "<EMAIL>"
        navigator.performAction(Action.FxATypeEmail)
        navigator.performAction(Action.FxATapOnContinueButton)
        // Typing on Password should show Show (password) option
        userState.fxaPassword = "f"
        navigator.performAction(Action.FxATypePassword)
        waitForExistence(app.webViews.staticTexts["Show password"])
        // Remove the password typed, Show (password) option should not be shown
        app.secureTextFields.element(boundBy: 0).typeText(XCUIKeyboardKey.delete.rawValue)
        waitForNoExistence(app.webViews.staticTexts["Show password"])
{'fraction_non_alphanumeric': 0.0916884474647151, 'fraction_numerical': 0.006481965499215891, 'mean_word_length': 3.505887894488931, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '790082', 'n_tokens_mistral': 2819, 'n_tokens_neox': 2741, 'n_words': 589}