test: tests that assumed an idle machine wait for what they assert, or carry a budget for their work
Under a busy machine (the gate's lanes side by side, 12 busy cores) these went red at random: a press landed while the button was still busy, an answer was settled before it was asked for, a page grew past one wait's budget, a lazy chunk was transformed inside a 1 s wait, focus was taken a frame after the press. They now wait for the condition they depend on, preload the chunks they open, and the tests that do heavy work (whole-repo scans, the type-aware linter, module resets) carry an explicit budget naming that work. The whole suite four times under 12 busy-loop processes: red 4/4 before, 0/4 after.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
// back home; a shared file is the owner's, so its menu only plays, saves, cuts or drops it from my
|
||||
// list. i18n is key-passthrough, so labels read as keys.
|
||||
import { useState } from "react";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
act,
|
||||
cleanup,
|
||||
@@ -118,6 +118,17 @@ import Files from "./Files";
|
||||
import { FILES_LIST_CAP, type QueueJob } from "../lib/api";
|
||||
import { noteQueue, resetQueueWatch, useFinished } from "../lib/downloadQueue";
|
||||
|
||||
// The page loads its dialogs lazily, and the first test to open one would pay for transforming the
|
||||
// chunk inside its own 1 s wait for the dialog — over that on a busy machine. Loaded once, up front.
|
||||
beforeAll(async () => {
|
||||
await Promise.all([
|
||||
import("./FilePreview"),
|
||||
import("./ShareDialog"),
|
||||
import("./UploadDialog"),
|
||||
import("./VideoEditor"),
|
||||
]);
|
||||
}, 60_000);
|
||||
|
||||
const file = (id: number, extra: Partial<LibraryFile> = {}): LibraryFile =>
|
||||
({
|
||||
id,
|
||||
@@ -452,7 +463,9 @@ describe("Files · my file's row", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("Files · a library past the list's cap", () => {
|
||||
// Its cases draw a full page of FILES_LIST_CAP rows, some of them twice (a sort, then its answer):
|
||||
// up to ~0.8 s idle, past 5 s when the full suite's workers share a busy machine.
|
||||
describe("Files · a library past the list's cap", { timeout: 30_000 }, () => {
|
||||
it("a search under the cap runs on the rows; one past it asks the server, so an old file is found", () => {
|
||||
mocks.folders = [YT];
|
||||
mocks.files = [file(1, { display_name: "Recept" }), file(2)];
|
||||
|
||||
Reference in New Issue
Block a user