From a294eefdffbd6ba15d0a2e4c42b6a86cb9e8a4fe Mon Sep 17 00:00:00 2001 From: George Gevoian Date: Thu, 24 Feb 2022 10:38:04 -0800 Subject: [PATCH] (core) Update HomeIntro.ts to check for either login page Summary: The "Sign In" button can either redirect you to the Cognito login page or the Grist sign-up page, depending on whether you've logged in before. Since the HomeIntro tests can either be run as part of a full deployment test suite, or individually, the test could redirect you to both types of login pages. Test Plan: N/A (fixing test) Reviewers: paulfitz Reviewed By: paulfitz Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D3291 --- test/nbrowser/HomeIntro.ts | 5 ++--- test/nbrowser/gristUtils.ts | 1 + test/nbrowser/homeUtil.ts | 12 +++++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/test/nbrowser/HomeIntro.ts b/test/nbrowser/HomeIntro.ts index 797ff63b..6cbacdc2 100644 --- a/test/nbrowser/HomeIntro.ts +++ b/test/nbrowser/HomeIntro.ts @@ -27,10 +27,9 @@ describe('HomeIntro', function() { const signUp = await driver.findContent('.test-welcome-text a', 'sign up'); assert.include(await signUp.getAttribute('href'), '/signin'); - // Check that the link takes us to a login page. + // Check that the link takes us to a login page (either Cognito or Grist, depending on session). await signUp.click(); - // External servers redirect to Grist sign-up page if client has no sessions. - server.isExternalServer() ? await gu.checkGristLoginPage() : await gu.checkLoginPage(); + await gu.checkSigninPage(); await driver.navigate().back(); await gu.waitForDocMenuToLoad(); }); diff --git a/test/nbrowser/gristUtils.ts b/test/nbrowser/gristUtils.ts index 27651ccb..66318083 100644 --- a/test/nbrowser/gristUtils.ts +++ b/test/nbrowser/gristUtils.ts @@ -43,6 +43,7 @@ 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 checkSigninPage = homeUtil.checkSigninPage.bind(homeUtil); export const fixturesRoot: string = testUtils.fixturesRoot; diff --git a/test/nbrowser/homeUtil.ts b/test/nbrowser/homeUtil.ts index bbf03ce1..b8c82da2 100644 --- a/test/nbrowser/homeUtil.ts +++ b/test/nbrowser/homeUtil.ts @@ -273,10 +273,20 @@ export class HomeUtil { /** * Waits for browser to navigate to Grist login page. */ - public async checkGristLoginPage(waitMs: number = 4000) { + public async checkGristLoginPage(waitMs: number = 2000) { await this.driver.wait(this.isOnGristLoginPage.bind(this), waitMs); } + /** + * Waits for browser to navigate to either the Cognito or Grist login page. + */ + public async checkSigninPage(waitMs: number = 4000) { + await this.driver.wait( + async () => await this.isOnLoginPage() || await this.isOnGristLoginPage(), + waitMs + ); + } + /** * Delete and recreate the user, via the specified org. The specified user must be * currently logged in!