2021-08-18 10:04:28 -04:00
|
|
|
// these tests do not sign in as a user
|
|
|
|
|
2020-09-30 14:30:00 -04:00
|
|
|
const SeleniumHelper = require('./selenium-helpers.js');
|
|
|
|
|
|
|
|
const {
|
|
|
|
findByXpath,
|
|
|
|
clickXpath,
|
|
|
|
buildDriver
|
|
|
|
} = new SeleniumHelper();
|
|
|
|
|
|
|
|
let rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
|
|
|
|
let takenUsername = process.env.SMOKE_USERNAME;
|
|
|
|
|
2021-12-03 09:14:25 -05:00
|
|
|
jest.setTimeout(60000);
|
2020-09-30 14:30:00 -04:00
|
|
|
|
|
|
|
let driver;
|
|
|
|
|
|
|
|
describe('www-integration join flow', () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
driver = await buildDriver('www-integration join flow');
|
|
|
|
await driver.get(rootUrl);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => await driver.quit());
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
2021-12-07 13:06:56 -05:00
|
|
|
await driver.get(rootUrl);
|
2020-09-30 14:30:00 -04:00
|
|
|
await clickXpath('//a[@class="registrationLink"]');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('click Join opens join modal', async () => {
|
|
|
|
let joinModal = await findByXpath('//div[@class = "join-flow-outer-content"]');
|
|
|
|
let modalVisible = await joinModal.isDisplayed();
|
|
|
|
await expect(modalVisible).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('username validation message appears', async () => {
|
|
|
|
await clickXpath('//input[contains(@name, "username")]');
|
|
|
|
let message = await findByXpath('//div[contains(@class, "validation-message")]');
|
|
|
|
let messageText = await message.getText();
|
|
|
|
await expect(messageText).toEqual('Don\'t use your real name');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
test('password validation message appears', async () => {
|
|
|
|
await clickXpath('//input[contains(@name, "password")]');
|
|
|
|
let message = await findByXpath('//div[contains(@class, "validation-message")]');
|
|
|
|
let messageText = await message.getText();
|
|
|
|
await expect(messageText).toContain('Write it down so you remember.');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('password validation message appears', async () => {
|
|
|
|
await clickXpath('//input[contains(@name, "passwordConfirm")]');
|
|
|
|
let message = await findByXpath('//div[contains(@class, "validation-message")]');
|
|
|
|
let messageText = await message.getText();
|
|
|
|
await expect(messageText).toEqual('Type password again');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('username validation: too short', async () => {
|
|
|
|
let textInput = await findByXpath('//input[contains(@name, "username")]');
|
|
|
|
await textInput.click();
|
|
|
|
await textInput.sendKeys('ab');
|
|
|
|
await clickXpath('//div[@class = "join-flow-outer-content"]');
|
|
|
|
let message = await findByXpath('//div[contains(@class, "validation-error")]');
|
|
|
|
let messageText = await message.getText();
|
|
|
|
await expect(messageText).toContain('Must be 3 letters or longer');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('username validation: username taken', async () => {
|
|
|
|
let textInput = await findByXpath('//input[contains(@name, "username")]');
|
|
|
|
await textInput.click();
|
|
|
|
await textInput.sendKeys(takenUsername);
|
|
|
|
await clickXpath('//div[@class = "join-flow-outer-content"]');
|
|
|
|
let message = await findByXpath('//div[contains(@class, "validation-error")]');
|
|
|
|
let messageText = await message.getText();
|
|
|
|
await expect(messageText).toContain('Username taken.');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('username validation: bad word', async () => {
|
|
|
|
let textInput = await findByXpath('//input[contains(@name, "username")]');
|
|
|
|
await textInput.click();
|
|
|
|
await textInput.sendKeys('qnb02mclepghwic9');
|
|
|
|
await clickXpath('//div[@class = "join-flow-outer-content"]');
|
|
|
|
let message = await findByXpath('//div[contains(@class, "validation-error")]');
|
|
|
|
let messageText = await message.getText();
|
|
|
|
await expect(messageText).toContain('Username not allowed');
|
|
|
|
});
|
|
|
|
});
|