From 481122b4d300de974c4b8616c71ccb5178bf07b4 Mon Sep 17 00:00:00 2001 From: George Gevoian Date: Mon, 21 Feb 2022 11:02:57 -0800 Subject: [PATCH] (core) Fix failing login tests Summary: The rollout of the new sign-up page on prod caused a few tests that previously expected to be on the Cognito sign-up page to fail. Test Plan: N/A (fixing failing tests). Reviewers: alexmojaki Reviewed By: alexmojaki Subscribers: alexmojaki Differential Revision: https://phab.getgrist.com/D3279 --- test/nbrowser/gristUtils.ts | 1 + test/nbrowser/homeUtil.ts | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/test/nbrowser/gristUtils.ts b/test/nbrowser/gristUtils.ts index 2e2d7d06..8089e0e8 100644 --- a/test/nbrowser/gristUtils.ts +++ b/test/nbrowser/gristUtils.ts @@ -42,6 +42,7 @@ export const removeLogin = homeUtil.removeLogin.bind(homeUtil); export const setValue = homeUtil.setValue.bind(homeUtil); export const isOnLoginPage = homeUtil.isOnLoginPage.bind(homeUtil); export const checkLoginPage = homeUtil.checkLoginPage.bind(homeUtil); +export const checkGristLoginPage = homeUtil.checkGristLoginPage.bind(homeUtil); export const fixturesRoot: string = testUtils.fixturesRoot; diff --git a/test/nbrowser/homeUtil.ts b/test/nbrowser/homeUtil.ts index 89346224..35ef9d89 100644 --- a/test/nbrowser/homeUtil.ts +++ b/test/nbrowser/homeUtil.ts @@ -78,7 +78,7 @@ export class HomeUtil { // When running against an external server, we log in through Cognito. await this.driver.get(this.server.getUrl(org, "")); // Check if we got redirected to the Grist sign-up page. - if (await this.isOnSignupPage()) { + if (await this.isOnGristLoginPage()) { await this.driver.findWait('a[href*="login?"]', 4000).click(); } else if (!(await this.isOnLoginPage())) { // Explicitly click sign-in link if necessary. @@ -86,7 +86,7 @@ export class HomeUtil { await this.driver.findContentWait('.grist-floating-menu a', 'Sign in', 500).click(); } // Check if we need to switch to Cognito login from the Grist sign-up page. - if (await this.isOnSignupPage()) { + if (await this.isOnGristLoginPage()) { await this.driver.findWait('a[href*="login?"]', 4000).click(); } await this.checkLoginPage(); @@ -263,10 +263,10 @@ export class HomeUtil { } /** - * Returns whether we are currently on the Grist sign-up page. + * Returns whether we are currently on a Grist login page. */ - public async isOnSignupPage() { - return /login(-s)?\.getgrist\.com\/signup/.test(await this.driver.getCurrentUrl()); + public async isOnGristLoginPage() { + return /login(-s)?\.getgrist\.com/.test(await this.driver.getCurrentUrl()); } /** @@ -276,6 +276,13 @@ export class HomeUtil { await this.driver.wait(this.isOnLoginPage.bind(this), waitMs); } + /** + * Waits for browser to navigate to Grist login page. + */ + public async checkGristLoginPage(waitMs: number = 2000) { + await this.driver.wait(this.isOnGristLoginPage.bind(this), waitMs); + } + /** * Delete and recreate the user, via the specified org. The specified user must be * currently logged in!