From c8369ad452449591ea23ea8d2c7fdcea3125f7a2 Mon Sep 17 00:00:00 2001 From: Barry Chen Date: Mon, 12 Feb 2018 15:17:24 -0600 Subject: [PATCH] Add nav to My Shots test. (#4030) --- test/test.js | 50 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/test/test.js b/test/test.js index c4b5a06805..601f6e4824 100644 --- a/test/test.js +++ b/test/test.js @@ -74,12 +74,6 @@ function promiseFinally(promise, finallyCallback) { }); } -function setTimeoutPromise(time) { - return new Promise((resolve, reject) => { - setTimeout(resolve, time); - }); -} - /** This will start Screenshots, and return a promise that will be true if the onboarding slides are active, or false if not. An error will be returned if it does not start @@ -219,9 +213,7 @@ describe("Test Screenshots", function() { until.elementLocated(By.css(".visible")) ); }).then((visibleButton) => { - visibleButton.click(); - // We'll get a stale element error (!?) if the next line is removed - return setTimeoutPromise(1000); + return visibleButton.click(); }).then(() => { return driver.switchTo().defaultContent(); }).then(() => { @@ -281,4 +273,44 @@ describe("Test Screenshots", function() { }); }); + it("should navigate to My Shots", function() { + let currentTabs, startingTabCount; + return driver.getAllWindowHandles().then(tabs => { + startingTabCount = tabs.length; + }).then(() => { + return driver.get(backend); + }).then(() => { + return startScreenshots(driver); + }).then(() => { + return driver.wait( + until.ableToSwitchToFrame(By.id(PRESELECTION_IFRAME_ID)) + ); + }).then(() => { + return driver.wait( + until.elementLocated(By.css(".myshots-button")) + ); + }).then(myShotsButton => { + return myShotsButton.click(); + }).then(() => { + return driver.wait( + () => { + return driver.getAllWindowHandles().then(tabs => { + currentTabs = tabs; + return currentTabs.length > startingTabCount; + }); + } + ); + }).then(() => { + return driver.switchTo().window(currentTabs[currentTabs.length - 1]); + }).then(() => { + return driver.wait( + until.elementLocated(By.css("#shot-index-page")) + ); + }).then(() => { + return driver.getCurrentUrl(); + }).then(url => { + assert.equal(url, `${backend}/shots`, `Navigated to ${url} instead of My Shots at ${backend}/shots`); + }); + }); + });