diff --git a/test/integration-legacy/smoke-testing/test_signing_in_and_out_discuss.js b/test/integration-legacy/smoke-testing/test_signing_in_and_out_discuss.js deleted file mode 100644 index e95426548..000000000 --- a/test/integration-legacy/smoke-testing/test_signing_in_and_out_discuss.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Tests from: - * - * https://github.com/LLK/scratchr2/wiki/Smoke-Testing-Test-Cases - * - */ - -const SeleniumHelper = require('../selenium-helpers.js'); -const helper = new SeleniumHelper(); - -var tap = require('tap'); -const test = tap.test; - -const driver = helper.buildDriver('www-smoke test_sign_in_out_discuss'); - -const { - clickText, - findByXpath, - findText, - clickXpath, - clickButton -} = helper; - -var username = process.env.SMOKE_USERNAME; -var password = process.env.SMOKE_PASSWORD; - -var rootUrl = process.env.ROOT_URL || 'https://scratch.ly'; -var url = rootUrl + '/discuss'; - -tap.plan(2); - -tap.tearDown(function () { - driver.quit(); -}); - -tap.beforeEach(function () { - return driver.get(url); -}); - -test('Sign in to Scratch using scratchr2 navbar', t => { - clickText('Sign in') - .then(() => findByXpath('//input[@id="login_dropdown_username"]')) - .then((element) => element.sendKeys(username)) - .then(() => findByXpath('//input[@name="password"]')) - .then((element) => element.sendKeys(password)) - .then(() => clickButton('Sign in')) - .then(() => findByXpath('//li[contains(@class, "logged-in-user")' + - 'and contains(@class, "dropdown")]/span')) - .then((element) => element.getText('span')) - .then((text) => t.match(text.toLowerCase(), username.substring(0, 10).toLowerCase(), - 'first part of username should be displayed in navbar')) - .then(() => t.end()); -}); - -test('Sign out of Scratch using scratchr2 navbar', t => { - clickXpath('//span[contains(@class, "user-name")' + - ' and contains(@class, "dropdown-toggle")]/img[contains(@class, "user-icon")]') - .then(() => clickXpath('//input[@value="Sign out"]')) - .then(() => findText('Sign in')) - .then((element) => t.ok(element, 'Sign in reappeared on the page after signing out')) - .then(() => t.end()); -}); diff --git a/test/integration-legacy/smoke-testing/test_signing_in_and_out_homepage.js b/test/integration-legacy/smoke-testing/test_signing_in_and_out_homepage.js deleted file mode 100644 index 15687b0cf..000000000 --- a/test/integration-legacy/smoke-testing/test_signing_in_and_out_homepage.js +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Tests from: - * - * https://github.com/LLK/scratchr2/wiki/Smoke-Testing-Test-Cases - * - */ - -const SeleniumHelper = require('../selenium-helpers.js'); -const helper = new SeleniumHelper(); - -var tap = require('tap'); -const test = tap.test; - -const driver = helper.buildDriver('www-smoke test_sign_in_out_homepage'); - -const { - clickText, - findText, - findByXpath, - clickXpath -} = helper; - -var username = process.env.SMOKE_USERNAME; -var password = process.env.SMOKE_PASSWORD; - -var rootUrl = process.env.ROOT_URL || 'https://scratch.ly'; - -tap.plan(2); - -tap.tearDown(function () { - driver.quit(); -}); - -tap.beforeEach(function () { - return driver.get(rootUrl); -}); - -test('Sign in to Scratch using scratch-www navbar', {skip: true}, t => { - clickText('Sign in') - .then(() => findByXpath('//input[@id="frc-username-1088"]')) - .then((element) => element.sendKeys(username)) - .then(() => findByXpath('//input[@id="frc-password-1088"]')) - .then((element) => element.sendKeys(password)) - .then(() => clickXpath('//button[contains(@class, "button") and ' + - 'contains(@class, "submit-button") and contains(@class, "white")]')) - .then(() => findByXpath('//span[contains(@class, "profile-name")]')) - .then((element) => element.getText()) - .then((text) => t.match(text.toLowerCase(), username.substring(0, 10).toLowerCase(), - 'first part of username should be displayed in navbar')) - .then(() => t.end()); -}); - -test('Sign out of Scratch using scratch-www navbar', {skip: true}, t => { - clickXpath('//a[contains(@class, "user-info")]') - .then(() => clickText('Sign out')) - .then(() => findText('Sign in')) - .then((element) => t.ok(element, 'Sign in reappeared on the page after signing out')) - .then(() => t.end()); -}); diff --git a/test/integration/sign-in-and-out.test.js b/test/integration/sign-in-and-out.test.js new file mode 100644 index 000000000..7e2bdf974 --- /dev/null +++ b/test/integration/sign-in-and-out.test.js @@ -0,0 +1,100 @@ +const SeleniumHelper = require('./selenium-helpers.js'); + +const { + clickText, + findByXpath, + clickXpath, + clickButton, + buildDriver +} = new SeleniumHelper(); + +let username = process.env.SMOKE_USERNAME; +let password = process.env.SMOKE_PASSWORD; +let remote = process.env.SMOKE_REMOTE || false; +let rootUrl = process.env.ROOT_URL || 'https://scratch.ly'; +let scratchr2url = rootUrl + '/users/' + username; +let wwwURL = rootUrl; + +if (remote){ + jest.setTimeout(60000); +} + +let driver; + +describe('www-integration sign-in-and-out', () => { + beforeAll(async () => { + driver = await buildDriver('www-integration sign-in-out'); + }); + + describe('sign in', () => { + afterEach(async () => { + await driver.get(wwwURL); + await clickXpath('//div[@class="account-nav"]'); + await clickText('Sign out'); + }); + + test('sign in on www', async () => { + await driver.get(wwwURL); + await driver.sleep(1000); + await clickXpath('//li[@class="link right login-item"]/a'); + let name = await findByXpath('//input[@id="frc-username-1088"]'); + await name.sendKeys(username); + let word = await findByXpath('//input[@id="frc-password-1088"]'); + await word.sendKeys(password); + await clickXpath('//button[contains(@class, "button") and ' + + 'contains(@class, "submit-button") and contains(@class, "white")]'); + let element = await findByXpath('//span[contains(@class, "profile-name")]'); + let text = await element.getText(); + await expect(text.toLowerCase()).toEqual(username.toLowerCase()); + }); + + test('sign in on scratchr2', async () => { + await driver.get(scratchr2url); + await clickXpath('//li[@class="sign-in dropdown"]/span'); + let name = await findByXpath('//input[@id="login_dropdown_username"]'); + await name.sendKeys(username); + let word = await findByXpath('//input[@name="password"]'); + await word.sendKeys(password); + await clickButton('Sign in'); + let element = await findByXpath('//span[@class="user-name dropdown-toggle"]'); + let text = await element.getText(); + await expect(text.toLowerCase()).toEqual(username.toLowerCase()); + }); + }); + + describe('sign out', () => { + beforeEach(async () => { + await driver.get(wwwURL); + await clickXpath('//li[@class="link right login-item"]'); + let name = await findByXpath('//input[@id="frc-username-1088"]'); + await name.sendKeys(username); + let word = await findByXpath('//input[@id="frc-password-1088"]'); + await word.sendKeys(password); + await clickXpath('//button[contains(@class, "button") and ' + + 'contains(@class, "submit-button") and contains(@class, "white")]'); + }); + + test('sign out on www', async () => { + await clickXpath('//a[contains(@class, "user-info")]'); + await clickText('Sign out'); + let element = await findByXpath('//li[@class="link right login-item"]/a/span'); + let text = await element.getText(); + await expect(text.toLowerCase()).toEqual('Sign In'.toLowerCase()); + }); + + test('sign out on scratchr2', async () => { + await driver.get(scratchr2url); + await clickXpath('//span[@class="user-name dropdown-toggle"]'); + await clickXpath('//li[@id="logout"]'); + let element = await findByXpath('//li[@class="link right login-item"]/a/span'); + let text = await element.getText(); + await expect(text.toLowerCase()).toEqual('Sign In'.toLowerCase()); + }); + + }); + + afterAll(async () => { + await driver.quit(); + }); + +});