diff --git a/package-lock.json b/package-lock.json index 1b590723a..93c8cf26e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3245,9 +3245,9 @@ } }, "chromedriver": { - "version": "75.1.0", - "resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-75.1.0.tgz", - "integrity": "sha512-N2P0fg6FS4c+tTG0R7cCOD5qiVo+E6uAz6xVjmbZesYv1xs1iGdcCUo0IqOY+ppD/4OOObG+XWV1CFWXT6UIgA==", + "version": "76.0.0", + "resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-76.0.0.tgz", + "integrity": "sha512-jGyqs0N+lMo9iaNQxGKNPiLJWb2L9s2rwbRr1jJeQ37n6JQ1+5YMGviv/Fx5Z08vBWYbAvrKEzFsuYf8ppl+lw==", "dev": true, "requires": { "del": "^4.1.1", diff --git a/package.json b/package.json index 76b124919..685b14edb 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "test:lint": "eslint . --ext .js,.jsx,.json", "test:integration": "npm run test:integration:jest && npm run test:smoke", "test:integration:jest": "jest ./test/integration/*.test.js", - "test:integration:remote": "npm run test:integration:jest && npm run test:smoke:sauce", + "test:integration:remote": "npm run test:integration:jest:remote && npm run test:smoke:sauce", + "test:integration:jest:remote": "SMOKE_REMOTE=true jest ./test/integration/*.test.js", "test:smoke": "tap ./test/integration-legacy/smoke-testing/*.js --timeout=3600 --no-coverage -R classic", "test:smoke:verbose": "tap ./test/integration-legacy/smoke-testing/*.js --timeout=3600 --no-coverage -R spec", "test:smoke:sauce": "SMOKE_REMOTE=true tap ./test/integration-legacy/smoke-testing/*.js --timeout=60000 --no-coverage -R classic", @@ -66,7 +67,7 @@ "babel-preset-react": "6.22.0", "bowser": "1.9.4", "cheerio": "1.0.0-rc.2", - "chromedriver": "75.1.0", + "chromedriver": "76.0.0", "classnames": "2.2.5", "cookie": "0.2.2", "copy-webpack-plugin": "0.2.0", diff --git a/test/integration-legacy/selenium-helpers.js b/test/integration-legacy/selenium-helpers.js index 710c00110..99e0b8ceb 100644 --- a/test/integration-legacy/selenium-helpers.js +++ b/test/integration-legacy/selenium-helpers.js @@ -68,7 +68,7 @@ class SeleniumHelper { let driverConfig = { browserName: 'chrome', platform: 'macOS 10.14', - version: '75.0' + version: '76.0' }; var driver = new webdriver.Builder() .withCapabilities({ 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/selenium-helpers.js b/test/integration/selenium-helpers.js index 2b2dfdfb0..99e0b8ceb 100644 --- a/test/integration/selenium-helpers.js +++ b/test/integration/selenium-helpers.js @@ -67,8 +67,8 @@ class SeleniumHelper { // https://wiki.saucelabs.com/display/DOCS/Platform+Configurator let driverConfig = { browserName: 'chrome', - platform: 'macOS 10.13', - version: '70.0' + platform: 'macOS 10.14', + version: '76.0' }; var driver = new webdriver.Builder() .withCapabilities({ 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(); + }); + +}); diff --git a/test/integration/test-integration.test.js b/test/integration/test-integration.test.js deleted file mode 100644 index 44c96735d..000000000 --- a/test/integration/test-integration.test.js +++ /dev/null @@ -1,5 +0,0 @@ -describe('test jest integration', () => { - test('testing test', () => { - expect('integration').toEqual('integration'); - }); -});