make some more methods available for grist-widget tests (#677)

This moves a few more gristUtils methods to gristWebDriverUtils,
which is easier to use from other repositories (specifically
grist-widget).
pull/684/head
Paul Fitzpatrick 8 months ago committed by GitHub
parent 173708726f
commit 2df1b2dbe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -83,6 +83,11 @@ export const selectWidget = webdriverUtils.selectWidget.bind(webdriverUtils);
export const dismissBehavioralPrompts = webdriverUtils.dismissBehavioralPrompts.bind(webdriverUtils);
export const toggleSelectable = webdriverUtils.toggleSelectable.bind(webdriverUtils);
export const waitToPass = webdriverUtils.waitToPass.bind(webdriverUtils);
export const refreshDismiss = webdriverUtils.refreshDismiss.bind(webdriverUtils);
export const acceptAlert = webdriverUtils.acceptAlert.bind(webdriverUtils);
export const isAlertShown = webdriverUtils.isAlertShown.bind(webdriverUtils);
export const waitForDocToLoad = webdriverUtils.waitForDocToLoad.bind(webdriverUtils);
export const reloadDoc = webdriverUtils.reloadDoc.bind(webdriverUtils);
export const fixturesRoot: string = testUtils.fixturesRoot;
@ -776,21 +781,6 @@ export async function loadDocMenu(relPath: string, wait: boolean = true): Promis
if (wait) { await waitForDocMenuToLoad(); }
}
/**
* Wait for the doc to be loaded, to the point of finishing fetch for the data on the current
* page. If you navigate from a doc page, use e.g. waitForUrl() before waitForDocToLoad() to
* ensure you are checking the new page and not the old.
*/
export async function waitForDocToLoad(timeoutMs: number = 10000): Promise<void> {
await driver.findWait('.viewsection_title', timeoutMs);
await waitForServer();
}
export async function reloadDoc() {
await driver.navigate().refresh();
await waitForDocToLoad();
}
/**
* Wait for the doc list to show, to know that workspaces are fetched, and imports enabled.
*/
@ -2879,34 +2869,6 @@ export async function getFilterMenuState(): Promise<FilterMenuValue[]> {
}));
}
/**
* Refresh browser and dismiss alert that is shown (for refreshing during edits).
*/
export async function refreshDismiss() {
await driver.navigate().refresh();
await acceptAlert();
await waitForDocToLoad();
}
/**
* Accepts an alert.
*/
export async function acceptAlert() {
await (await driver.switchTo().alert()).accept();
}
/**
* Returns whether an alert is shown.
*/
export async function isAlertShown() {
try {
await driver.switchTo().alert();
return true;
} catch {
return false;
}
}
/**
* Dismisses any tutorial card that might be active.
*/

@ -203,6 +203,49 @@ export class GristWebDriverUtils {
await check();
}
}
/**
* Refresh browser and dismiss alert that is shown (for refreshing during edits).
*/
public async refreshDismiss() {
await this.driver.navigate().refresh();
await this.acceptAlert();
await this.waitForDocToLoad();
}
/**
* Accepts an alert.
*/
public async acceptAlert() {
await (await this.driver.switchTo().alert()).accept();
}
/**
* Returns whether an alert is shown.
*/
public async isAlertShown() {
try {
await this.driver.switchTo().alert();
return true;
} catch {
return false;
}
}
/**
* Wait for the doc to be loaded, to the point of finishing fetch for the data on the current
* page. If you navigate from a doc page, use e.g. waitForUrl() before waitForDocToLoad() to
* ensure you are checking the new page and not the old.
*/
public async waitForDocToLoad(timeoutMs: number = 10000): Promise<void> {
await this.driver.findWait('.viewsection_title', timeoutMs);
await this.waitForServer();
}
public async reloadDoc() {
await this.driver.navigate().refresh();
await this.waitForDocToLoad();
}
}
export interface WindowDimensions {

Loading…
Cancel
Save