(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
This commit is contained in:
George Gevoian 2022-02-24 10:38:04 -08:00
parent ff4e5d2769
commit a294eefdff
3 changed files with 14 additions and 4 deletions

View File

@ -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();
});

View File

@ -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;

View File

@ -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!