mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) When reporting email in log metadata, use normalized email.
Summary: There has been inconsistency in using display email vs normalized email, which ends up creating some duplication in downstream analyses (e.g. the same user showing up twice with different capitalization). 1. Add UserProfile.loginEmail field with normalized email to prefer, when set, over the inconsistently used UserProfile.email. 2. In one place where it's not available, normalize the display email manually. 3. Clean up some code in Client.ts. Unrelated tweak to API Console to be clear when a URL parameter wasn't found (rather than show whatever happens to be the first value). Several test robustness improvements: - Misplaced parenthesis in gristWebDriverUtils has been causing optTimeout argument to be ignored in tests, and treated always as indefinite. - Attempt to fix SortMenu test by ignoring (retrying with logging) errors in waitForServer, which include "script timeout" errors that come from a non-configurable selenium or chromedriver timeout. - Attempt to improve onNewTab() helper, which plays a role in failing Billing tests. Test Plan: Tested manually the capitalization of logged emails. Counting on existing tests to catch issues. Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D4188
This commit is contained in:
@@ -889,7 +889,7 @@ export async function importFileDialog(filePath: string): Promise<void> {
|
||||
await driver.findContent('.test-dp-import-option', /Import from file/i).doClick();
|
||||
});
|
||||
await driver.findWait('.test-importer-dialog', 5000);
|
||||
await waitForServer();
|
||||
await waitForServer(10_000);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2821,14 +2821,21 @@ export async function getEnabledOptions(): Promise<SortOption[]> {
|
||||
* on whole test suite if needed.
|
||||
*/
|
||||
export async function onNewTab(action: () => Promise<void>) {
|
||||
const currentTab = await driver.getWindowHandle();
|
||||
await driver.executeScript("window.open('about:blank', '_blank')");
|
||||
const tabs = await driver.getAllWindowHandles();
|
||||
await driver.switchTo().window(tabs[tabs.length - 1]);
|
||||
const newTab = tabs[tabs.length - 1];
|
||||
await driver.switchTo().window(newTab);
|
||||
try {
|
||||
await action();
|
||||
} finally {
|
||||
await driver.close();
|
||||
await driver.switchTo().window(tabs[tabs.length - 2]);
|
||||
const newCurrentTab = await driver.getWindowHandle();
|
||||
if (newCurrentTab === newTab) {
|
||||
await driver.close();
|
||||
await driver.switchTo().window(currentTab);
|
||||
} else {
|
||||
console.log("onNewTab not cleaning up because is not on expected tab");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,15 +26,21 @@ export class GristWebDriverUtils {
|
||||
*
|
||||
* Simply call this after some request has been made, and when it resolves, you know that request
|
||||
* has been processed.
|
||||
* @param optTimeout: Timeout in ms, defaults to 2000.
|
||||
* @param optTimeout: Timeout in ms, defaults to 5000.
|
||||
*/
|
||||
public async waitForServer(optTimeout: number = 2000) {
|
||||
public async waitForServer(optTimeout: number = 5000) {
|
||||
await this.driver.wait(() => this.driver.executeScript(
|
||||
"return window.gristApp && (!window.gristApp.comm || !window.gristApp.comm.hasActiveRequests())"
|
||||
+ " && window.gristApp.testNumPendingApiRequests() === 0",
|
||||
+ " && window.gristApp.testNumPendingApiRequests() === 0"
|
||||
)
|
||||
// The catch is in case executeScript() fails. This is rare but happens occasionally when
|
||||
// browser is busy (e.g. sorting) and doesn't respond quickly enough. The timeout selenium
|
||||
// allows for a response is short (and I see no place to configure it); by catching, we'll
|
||||
// let the call fail until our intended timeout expires.
|
||||
.catch((e) => { console.log("Ignoring executeScript error", String(e)); }),
|
||||
optTimeout,
|
||||
"Timed out waiting for server requests to complete"
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
public async waitForSidePanel() {
|
||||
|
||||
Reference in New Issue
Block a user