From ac910389bc59a7ca24f6ec05e68c67e319e9c545 Mon Sep 17 00:00:00 2001 From: George Gevoian Date: Tue, 22 Feb 2022 13:35:23 -0800 Subject: [PATCH] (core) Make login URL regexes more specific Summary: This should resolve some staging test failures. The previous regexes weren't quite specific enough, so random parts of a URL that had traces of the real login URLs were causing isOnLoginPage() and isOnGristLoginPage() to return true instead of false. Test Plan: N/A (fixing tests) Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D3283 --- test/nbrowser/HomeIntro.ts | 3 ++- test/nbrowser/homeUtil.ts | 9 +++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/test/nbrowser/HomeIntro.ts b/test/nbrowser/HomeIntro.ts index 38eeccaf..797ff63b 100644 --- a/test/nbrowser/HomeIntro.ts +++ b/test/nbrowser/HomeIntro.ts @@ -29,7 +29,8 @@ describe('HomeIntro', function() { // Check that the link takes us to a login page. await signUp.click(); - await gu.checkLoginPage(); + // External servers redirect to Grist sign-up page if client has no sessions. + server.isExternalServer() ? await gu.checkGristLoginPage() : await gu.checkLoginPage(); await driver.navigate().back(); await gu.waitForDocMenuToLoad(); }); diff --git a/test/nbrowser/homeUtil.ts b/test/nbrowser/homeUtil.ts index 35ef9d89..28655609 100644 --- a/test/nbrowser/homeUtil.ts +++ b/test/nbrowser/homeUtil.ts @@ -77,10 +77,7 @@ export class HomeUtil { await this.driver.get('about:blank'); // 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.isOnGristLoginPage()) { - await this.driver.findWait('a[href*="login?"]', 4000).click(); - } else if (!(await this.isOnLoginPage())) { + if (!(await this.isOnGristLoginPage()) && !(await this.isOnLoginPage())) { // Explicitly click sign-in link if necessary. await this.driver.findWait('.test-user-signin', 4000).click(); await this.driver.findContentWait('.grist-floating-menu a', 'Sign in', 500).click(); @@ -259,14 +256,14 @@ export class HomeUtil { * Returns whether we are currently on the Cognito login page. */ public async isOnLoginPage() { - return /gristlogin/.test(await this.driver.getCurrentUrl()); + return /^https:\/\/gristlogin/.test(await this.driver.getCurrentUrl()); } /** * Returns whether we are currently on a Grist login page. */ public async isOnGristLoginPage() { - return /login(-s)?\.getgrist\.com/.test(await this.driver.getCurrentUrl()); + return /^https:\/\/login(-s)?\.getgrist\.com/.test(await this.driver.getCurrentUrl()); } /**