8000 Fix e2e tests · coder/coder@be6bbe7 · GitHub
[go: up one dir, main page]

Skip to content

Commit be6bbe7

Browse files
committed
Fix e2e tests
1 parent ef40473 commit be6bbe7

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

site/e2e/api.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import relativeTime from "dayjs/plugin/relativeTime";
88

99
dayjs.extend(duration);
1010
dayjs.extend(relativeTime);
11+
import { humanDuration } from "utils/time";
1112
import { coderPort, defaultPassword } from "./constants";
1213
import { type LoginOptions, findSessionToken, randomName } from "./helpers";
1314

@@ -295,13 +296,15 @@ export async function verifyConfigFlagDuration(
295296
flag: string,
296297
) {
297298
const opt = findConfigOption(config, flag);
299+
if (typeof opt.value !== "number") {
300+
throw new Error(
301+
`Option with env ${flag} should be a number, but got ${typeof opt.value}.`,
302+
);
303+
}
298304
const configOption = page.locator(
299305
`div.options-table .option-${flag} .option-value-string`,
300306
);
301-
//
302-
await expect(configOption).toHaveText(
303-
dayjs.duration((opt.value as number) / 1e6).humanize(),
304-
);
307+
await expect(configOption).toHaveText(humanDuration(opt.value / 1e6));
305308
}
306309

307310
export function findConfigOption(

site/e2e/tests/deployment/observability.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
verifyConfigFlagArray,
66
verifyConfigFlagBoolean,
77
verifyConfigFlagDuration,
8-
verifyConfigFlagEmpty,
98
verifyConfigFlagString,
109
} from "../../api";
1110
import { login } from "../../helpers";
@@ -28,7 +27,11 @@ test("enabled observability settings", async ({ page }) => {
2827
await verifyConfigFlagBoolean(page, config, "enable-terraform-debug-mode");
2928
await verifyConfigFlagBoolean(page, config, "enable-terraform-debug-mode");
3029
await verifyConfigFlagDuration(page, config, "health-check-refresh");
31-
await verifyConfigFlagEmpty(page, "health-check-threshold-database");
30+
await verifyConfigFlagDuration(
31+
page,
32+
config,
33+
"health-check-threshold-database",
34+
);
3235
await verifyConfigFlagString(page, config, "log-human");
3336
await verifyConfigFlagString(page, config, "prometheus-address");
3437
await verifyConfigFlagArray(

site/src/utils/time.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export function humanDuration(durationInMs: number) {
5454
conjunction: " and ",
5555
serialComma: false,
5656
round: true,
57+
units: ["y", "mo", "w", "d", "h", "m", "s", "ms"],
5758
});
5859
}
5960

0 commit comments

Comments
 (0)
0