(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
pull/165/head
George Gevoian 2 years ago
parent accd640078
commit ac910389bc

@ -29,7 +29,8 @@ describe('HomeIntro', function() {
// Check that the link takes us to a login page. // Check that the link takes us to a login page.
await signUp.click(); 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 driver.navigate().back();
await gu.waitForDocMenuToLoad(); await gu.waitForDocMenuToLoad();
}); });

@ -77,10 +77,7 @@ export class HomeUtil {
await this.driver.get('about:blank'); await this.driver.get('about:blank');
// When running against an external server, we log in through Cognito. // When running against an external server, we log in through Cognito.
await this.driver.get(this.server.getUrl(org, "")); 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.isOnLoginPage())) {
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. // Explicitly click sign-in link if necessary.
await this.driver.findWait('.test-user-signin', 4000).click(); await this.driver.findWait('.test-user-signin', 4000).click();
await this.driver.findContentWait('.grist-floating-menu a', 'Sign in', 500).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. * Returns whether we are currently on the Cognito login page.
*/ */
public async isOnLoginPage() { 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. * Returns whether we are currently on a Grist login page.
*/ */
public async isOnGristLoginPage() { public async isOnGristLoginPage() {
return /login(-s)?\.getgrist\.com/.test(await this.driver.getCurrentUrl()); return /^https:\/\/login(-s)?\.getgrist\.com/.test(await this.driver.getCurrentUrl());
} }
/** /**

Loading…
Cancel
Save