From 6520a5f4341c4b8833812a1255edf40e05f021ce Mon Sep 17 00:00:00 2001 From: BryceLTaylor Date: Fri, 19 Nov 2021 09:38:23 -0500 Subject: [PATCH] Integration tests use updated Sign In function from Selenium Helpers --- test/integration/comments.test.js | 4 ++-- test/integration/my-stuff.test.js | 14 ++++---------- test/integration/selenium-helpers.js | 8 +++----- test/integration/sign-in-and-out.test.js | 2 +- test/integration/studios-page.test.js | 10 +++++----- 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/test/integration/comments.test.js b/test/integration/comments.test.js index 81b9d5626..03f35f71c 100644 --- a/test/integration/comments.test.js +++ b/test/integration/comments.test.js @@ -61,7 +61,7 @@ describe('comment tests', async () => { describe('leave comments', async () => { beforeAll(async () => { - await signIn(username1, password, driver); + await signIn(username1, password); await findByXpath('//span[contains(@class, "profile-name")]'); }); @@ -137,7 +137,7 @@ describe('comment tests', async () => { describe('second user tests', async () => { beforeAll(async () => { - await signIn(username2, password, driver); + await signIn(username2, password); await findByXpath('//span[contains(@class, "profile-name")]'); }); diff --git a/test/integration/my-stuff.test.js b/test/integration/my-stuff.test.js index 1bc650dd1..035a363b8 100644 --- a/test/integration/my-stuff.test.js +++ b/test/integration/my-stuff.test.js @@ -3,10 +3,11 @@ const SeleniumHelper = require('./selenium-helpers.js'); const { + buildDriver, clickText, - findByXpath, clickXpath, - buildDriver + findByXpath, + signIn } = new SeleniumHelper(); let username = process.env.SMOKE_USERNAME + '1'; @@ -30,14 +31,7 @@ describe('www-integration my_stuff', () => { driver = await buildDriver('www-integration my_stuff'); await driver.get(rootUrl); 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 driver.sleep(500); - await clickXpath('//button[contains(@class, "button") and ' + - 'contains(@class, "submit-button") and contains(@class, "white")]'); + await signIn(username, password); await findByXpath('//span[contains(@class, "profile-name")]'); }); diff --git a/test/integration/selenium-helpers.js b/test/integration/selenium-helpers.js index fbefe1799..9d94f8698 100644 --- a/test/integration/selenium-helpers.js +++ b/test/integration/selenium-helpers.js @@ -151,15 +151,13 @@ class SeleniumHelper { } // must be used on a www page - async signIn (username, password, driver) { + async signIn (username, password) { await this.clickXpath('//li[@class="link right login-item"]/a'); let name = await this.findByXpath('//input[@id="frc-username-1088"]'); await name.sendKeys(username); let word = await this.findByXpath('//input[@id="frc-password-1088"]'); - await word.sendKeys(password); - await driver.sleep(500); - await this.clickXpath('//button[contains(@class, "button") and ' + - 'contains(@class, "submit-button") and contains(@class, "white")]'); + await word.sendKeys(password + this.getKey('ENTER')); + await this.findByXpath('//span[contains(@class, "profile-name")]'); } urlMatches (regex) { diff --git a/test/integration/sign-in-and-out.test.js b/test/integration/sign-in-and-out.test.js index 34534d052..8d8ce2129 100644 --- a/test/integration/sign-in-and-out.test.js +++ b/test/integration/sign-in-and-out.test.js @@ -77,7 +77,7 @@ describe('www-integration sign-in-and-out', () => { describe('sign out', () => { beforeEach(async () => { await driver.get(wwwURL); - await signIn(username, password, driver); + await signIn(username, password); await driver.sleep(500); }); diff --git a/test/integration/studios-page.test.js b/test/integration/studios-page.test.js index 2ca9586e2..9fb1d8da6 100644 --- a/test/integration/studios-page.test.js +++ b/test/integration/studios-page.test.js @@ -78,7 +78,7 @@ describe('studio management', () => { await driver.get(rootUrl); // create a studio for tests - await signIn(username2, password, driver); + await signIn(username2, password); await findByXpath('//span[contains(@class, "profile-name")]'); await driver.get(rateLimitCheck); await driver.get(myStuffURL); @@ -99,7 +99,7 @@ describe('studio management', () => { test('invite a curator', async () => { // sign in as user2 - await signIn(username2, password, driver); + await signIn(username2, password); await findByXpath('//span[contains(@class, "profile-name")]'); // invite user3 to curate @@ -114,7 +114,7 @@ describe('studio management', () => { test('accept curator invite', async () => { // Sign in user3 - await signIn(username3, password, driver); + await signIn(username3, password); await findByXpath('//span[contains(@class, "profile-name")]'); // accept the curator invite @@ -126,7 +126,7 @@ describe('studio management', () => { test('promote to manager', async () => { // sign in as user2 - await signIn(username2, password, driver); + await signIn(username2, password); await findByXpath('//span[contains(@class, "profile-name")]'); // for some reason the user isn't showing up without reloading the page await driver.get(curatorTab); @@ -150,7 +150,7 @@ describe('studio management', () => { test('transfer studio host', async () => { // sign in as user2 - await signIn(username2, password, driver); + await signIn(username2, password); await findByXpath('//span[contains(@class, "profile-name")]'); // for some reason the user isn't showing up without reloading the page await driver.get(curatorTab);