Skip to content

Commit

Permalink
Replace react-modal with native browser dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
davidje13 committed Nov 30, 2024
1 parent 44f7965 commit a3734cc
Show file tree
Hide file tree
Showing 13 changed files with 205 additions and 246 deletions.
7 changes: 0 additions & 7 deletions e2e/pages/SiteMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { type WebDriver } from 'selenium-webdriver';
import { getDocumentHtml, getLogs } from '../helpers/debug';
import { Welcome } from './Welcome';
import { Password } from './Password';
import { RetroList } from './RetroList';

export class SiteMap {
public constructor(public readonly driver: WebDriver) {}
Expand All @@ -11,12 +10,6 @@ export class SiteMap {
return new Welcome(this.driver).load();
}

public navigateToRetroList() {
// An unknown bug in chromedriver causes communication with the browser to hang for
// exactly 5 seconds at this point, so use at least a 6 second timeout to avoid flakiness:
return new RetroList(this.driver).load(6000);
}

public navigateToRetroPassword(slug: string) {
return new Password(this.driver, slug).load();
}
Expand Down
4 changes: 1 addition & 3 deletions e2e/pages/SsoLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export class SsoLogin<TargetPageT extends Page> extends Page {
public async submit(): Promise<TargetPageT> {
await this.click(By.css('form button'));

// An unknown bug in chromedriver causes communication with the browser to hang for
// exactly 5 seconds at this point, so use at least a 6 second timeout to avoid flakiness:
return new this.ExpectedTarget(this.driver).wait(6000);
return new this.ExpectedTarget(this.driver).wait();
}

public async loginAs(identifier: string): Promise<TargetPageT> {
Expand Down
8 changes: 4 additions & 4 deletions e2e/pages/common/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ export abstract class Page extends PageFragment {
this.untilNavigated = until.elementLocated(By.css(expectedCSS));
}

public async load(loadTimeoutOverride?: number) {
public async load() {
await this.navigate();
await this.wait(loadTimeoutOverride);
await this.wait();
return this;
}

public async wait(loadTimeoutOverride: number = 0) {
public async wait() {
await this.driver.wait(
this.untilNavigated,
Math.max(this.explicitWaitTimeout, loadTimeoutOverride),
this.explicitWaitTimeout,
`Failed to load page '${this.constructor.name}'`,
);
await this.driver.wait(
Expand Down
4 changes: 3 additions & 1 deletion e2e/pages/common/PageFragment.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { type By, type WebDriver } from 'selenium-webdriver';

export abstract class PageFragment {
// An unknown bug in chromedriver causes communication with the browser to hang for
// exactly 5 seconds at some points, so use at least a 6 second timeout to avoid flakiness:
protected readonly explicitWaitTimeout = Number(
process.env['EXPLICIT_WAIT_TIMEOUT'] || '5000',
process.env['EXPLICIT_WAIT_TIMEOUT'] || '6000',
);

protected constructor(
Expand Down
7 changes: 5 additions & 2 deletions e2e/pages/common/Popup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { By, WebDriver } from 'selenium-webdriver';
import { By, Key, WebDriver } from 'selenium-webdriver';
import { untilNoElementLocated } from '../../helpers/customUntil';
import { byButtonText } from '../../helpers/customBy';
import { PageFragment } from './PageFragment';
Expand All @@ -25,7 +25,10 @@ export class Popup extends PageFragment {
return;
}

await this.driver.findElement(By.css('.popup-overlay')).click();
await this.driver
.actions({ async: false, bridge: false })
.sendKeys(Key.ESCAPE)
.perform();
await this.waitUntilDismissed();
}
}
Loading

0 comments on commit a3734cc

Please sign in to comment.