<commit_before>const {
    clickText,
    findByXpath,
    clickButton,
    driver,
    until,
    By
} = require('../selenium-helpers.js');

var username = process.env.SMOKE_USERNAME;
var password = process.env.SMOKE_PASSWORD;


var tap = require('tap');
const test = tap.test;

var rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
var url = rootUrl + '/users/' + username;

tap.plan(5);

tap.tearDown(function () {
    driver.quit();
});

tap.beforeEach(function () {
    return driver.get(url);
});

/*
 * This test fails sometimes because blank username eventually
 * triggers the captcha page, which is a bug:
 * https://github.com/LLK/scratchr2/issues/4762
 */
test('Trying to sign in with no username and no password using scratchr2 navbar', t => {
    clickText('Sign in')
        .then(() => clickButton('Sign in'))
        .then(() => driver.wait(until
            .elementLocated(By.xpath('//form[@id="login"]/button[@type="submit"]')))
        )
        .then(() => driver.wait(until
            .elementLocated(By.xpath('//form[@id="login"]/div[@class="error"]')))
        )
        .then(() => findByXpath('//form/div[@class="error"]'))
        .then(element => element.getText())
        .then(text => t.match(text, 'This field is required.',
            '"This field is required" error should be displayed'))
        .then(() => t.end());
});

/*
 * This test fails sometimes because blank username eventually
 * triggers the captcha page, which is a bug:
 * https://github.com/LLK/scratchr2/issues/4762
 */
test('Trying to sign in with no username using scratchr2 navbar', t => {
    clickText('Sign in')
        .then(() => findByXpath('//input[@name="password"]'))
        .then((element) => element.sendKeys(password))
        .then(() => clickButton('Sign in'))
        .then(() => driver.wait(until
            .elementLocated(By.xpath('//form[@id="login"]/button[@type="submit"]')))
        )
        .then(() => driver.wait(until
            .elementLocated(By.xpath('//form[@id="login"]/div[@class="error"]')))
        )
        .then(() => findByXpath('//form/div[@class="error"]'))
        .then((element) => element.getText())
        .then((text) => t.match(text, 'This field is required.',
            '"This field is required" error should be displayed'))
        .then(() => t.end());
});

test('Trying to sign in with no password using scratchr2 navbar', t => {
    var nonsenseusername = Math.random().toString(36)
        .replace(/[^a-z]+/g, '')
        .substr(0, 5);
    clickText('Sign in')
        .then(() => findByXpath('//input[@id="login_dropdown_username"]'))<commit_msg>Remove Selenium smoke tests that sign in with no username since they break constantly.<commit_after>const {
    clickText,
    findByXpath,
    clickButton,
    driver,
    until,
    By
} = require('../selenium-helpers.js');

var username = process.env.SMOKE_USERNAME;
var password = <PASSWORD>;


var tap = require('tap');
const test = tap.test;

var rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
var url = rootUrl + '/users/' + username;

tap.plan(3);

tap.tearDown(function () {
    driver.quit();
});

tap.beforeEach(function () {
    return driver.get(url);
});

test('Trying to sign in with no password using scratchr2 navbar', t => {
    var nonsenseusername = Math.random().toString(36)
        .replace(/[^a-z]+/g, '')
        .substr(0, 5);
    clickText('Sign in')
        .then(() => findByXpath('//input[@id="login_dropdown_username"]'))
{'fraction_non_alphanumeric': 0.18484500574052812, 'fraction_numerical': 0.006888633754305396, 'mean_word_length': 3.0382387022016224, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 26, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '6715839', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1090, 'n_words': 249}