Skip to content

Commit d606624

Browse files
committed
Fixup e2e tests
1 parent ef928b4 commit d606624

13 files changed

+40
-436
lines changed

src/SIL.XForge.Scripture/ClientApp/e2e/characterize-tests.mts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env -S deno run --allow-run --allow-env --allow-sys --allow-read --allow-write --unstable-sloppy-imports
22
import { chromium } from "npm:playwright";
33
import { preset } from "./e2e-globals.ts";
4-
import { Utils } from "./e2e-utils.js";
5-
import { numberOfTimesToAttemptTest } from "./pass-probability-ts";
4+
import { Utils } from "./e2e-utils.ts";
5+
import { numberOfTimesToAttemptTest } from "./pass-probability.ts";
66
import { ScreenshotContext } from "./presets.ts";
77
import { tests } from "./test-definitions.ts";
88

@@ -34,6 +34,8 @@ while (true) {
3434
console.log(`Saving trace to ${tracePath}`);
3535
browserContext.tracing.stop({ path: tracePath });
3636
} finally {
37+
await browserContext.close();
38+
await browser.close();
3739
printRetriesForEachTest();
3840
}
3941
}

src/SIL.XForge.Scripture/ClientApp/e2e/copy_help_site_screenshots.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const runLogDir = Deno.args[0];
66
const helpRepo = Deno.args[1];
77

88
if (runLogDir == null || helpRepo == null) {
9-
console.error("Usage: ./update_help_site_screenshots.mts <run_log_dir> <help_repo>");
9+
console.error("Usage: ./copy_help_site_screenshots.mts <run_log_dir> <help_repo>");
1010
Deno.exit(1);
1111
}
1212

src/SIL.XForge.Scripture/ClientApp/e2e/e2e.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { chromium, firefox, webkit } from "npm:playwright";
33
import { logger, preset, ScreenshotContext } from "./e2e-globals.ts";
44
import { screenshot } from "./e2e-utils.ts";
5-
import { numberOfTimesToAttemptTest } from "./pass-probability-ts";
5+
import { numberOfTimesToAttemptTest } from "./pass-probability.ts";
66
import { presets } from "./presets.ts";
77
import { tests } from "./test-definitions.ts";
88
import testCharacterization from "./test_characterization.json" with { type: "json" };

src/SIL.XForge.Scripture/ClientApp/e2e/pass-probability-ts renamed to src/SIL.XForge.Scripture/ClientApp/e2e/pass-probability.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import testCharacterization from "./test_characterization.json" with { type: "json" };
1+
import testCharacterization from './test_characterization.json' with { type: 'json' };
22

33
function probabilityOfRegressionGivenPreviousFailureRates(
44
initialRuns: number,
55
initialFailures: number,
66
newFailures: number
77
): number {
8-
if (initialFailures > initialRuns) throw new Error("initialFailures must be less than or equal to initialRuns");
8+
if (initialFailures > initialRuns) throw new Error('initialFailures must be less than or equal to initialRuns');
99

1010
// Adding 1 to both the numerator and denominator provides a better estimate of the actual failure rate.
1111
// If you read explanations of Bayesian statistics, you'll see 1 added when calculating a prior. Just to be clear, I
@@ -40,6 +40,7 @@ function numberOfRunsNeededToAchieveDesiredProbabilityOfRegression(
4040
desiredProbabilityOfRegression: number
4141
): number {
4242
for (let i = 1; ; i++) {
43+
if (i > 100) throw new Error('Number of runs needed to achieve desired probability of regression is too high');
4344
if (
4445
probabilityOfRegressionGivenPreviousFailureRates(initialRuns, initialFailures, i) > desiredProbabilityOfRegression
4546
) {

src/SIL.XForge.Scripture/ClientApp/e2e/pre_merge_ci.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ function shutDownServer() {
4141

4242
function startServer() {
4343
cd "${SCRIPT_DIR}/../.."
44-
local DOTNET_LOG="$(mktemp)"
44+
local DOTNET_LOG
45+
DOTNET_LOG="$(mktemp)"
4546
output "Logging dotnet output to ${DOTNET_LOG}"
4647
export ASPNETCORE_ENVIRONMENT="Development"
4748
nohup dotnet run &>"${DOTNET_LOG}" &

src/SIL.XForge.Scripture/ClientApp/e2e/presets.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import locales from '../../locales.json' with { type: 'json' };
2-
import { BrowserName, UserRole } from './e2e-globals.ts';
2+
import type { BrowserName, UserRole } from './e2e-globals.ts';
33
import { E2ETestRunLogger } from './e2e-test-run-logger.ts';
44
import { Utils } from './e2e-utils.ts';
55

src/SIL.XForge.Scripture/ClientApp/e2e/record_mobile_checking_videos.mts

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { chromium, devices, expect } from "npm:@playwright/test";
33
import { Page } from "npm:playwright";
44
import locales from "../../locales.json" with { type: "json" };
55

6+
// This is a legacy script that is left here for future reference. It works, but is not currently used by the tests.
7+
68
const typingDelayFactor = 1; // reduce to 0 to speed up typing
79

810
// Trick TypeScript into not complaining that the document isn't defined for functions that are actually evaluated in

0 commit comments

Comments
 (0)