(core) port some more test/browser tests to newer selenium

Summary:
Ports more test/browser tests from *.test.js (run using an old selenium setup) to *.ntest.js (run using newer setup).

Weird test failures happened due to a change in timing. Eventually tracked in down to billing changes in one test suite resulting in reloads in another test suite, since it turns out redis pub/sub channels are not scoped to the redis database specified in REDIS_URL, but are global:
  https://redis.io/docs/manual/pubsub/#database--scoping.

Test Plan: Ported tests should run and pass

Reviewers: jarek

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D3844
This commit is contained in:
Paul Fitzpatrick
2023-04-12 12:18:48 -04:00
parent 900859854c
commit cc0e1154d0
5 changed files with 44 additions and 6 deletions

View File

@@ -178,7 +178,7 @@ export function getSupportedEngineChoices(): EngineCode[]|undefined {
* Returns a promise that resolves in the given number of milliseconds or rejects
* when the given signal is raised.
*/
export function delayAbort(msec: number, signal?: AbortSignal): Promise<void> {
export function delayAbort(msec: number, signal?: AbortSignal): Promise<void> {
return new Promise<void>((resolve, reject) => {
let resolved = false;
const timeout = setTimeout(() => {
@@ -198,3 +198,20 @@ export function getSupportedEngineChoices(): EngineCode[]|undefined {
}
});
}
/**
* For a Redis URI, we expect no path component, or a path component
* that is an integer database number. We'd like to scope pub/sub to
* individual databases. Redis doesn't do that, so we construct a
* key prefix to have the same effect.
* https://redis.io/docs/manual/pubsub/#database--scoping
*/
export function getPubSubPrefix(): string {
const redisUrl = process.env.REDIS_URL;
if (!redisUrl) { return 'db-x'; }
const dbNumber = new URL(redisUrl).pathname.replace(/^\//, '');
if (dbNumber.match(/[^0-9]/)) {
throw new Error('REDIS_URL has an unexpected structure');
}
return `db-${dbNumber}`;
}