test(studio): the edit accuracy bench stops waiting on background lint and thumbnail images (#5899)

This commit is contained in:
Miguel Ángel
2026-10-19 18:59:26 +00:00
committed by GitHub
parent 0ce14d6443
commit 4c798f398d
2 changed files with 19 additions and 4 deletions
@@ -242,11 +242,13 @@ const STILL_MS = process.env.EDIT_ACCURACY_STILL_MS
: null;
export const STILL_FRAMES = 3;
// The server's event stream stays open for the page's life; timeline thumbnails are rendered by the server
// for the timeline strip, can take seconds, and never change the preview.
const backgroundRequest = (request) =>
// The server's event stream stays open for the page's life; timeline thumbnails and the background lint
// behind the lint badge run on the server, can take seconds (lint over 15 s on a busy runner), and never
// change the preview. A blob: load is page memory (a thumbnail's image) and can end with no event at all.
export const backgroundRequest = (request) =>
request.resourceType() === "eventsource" ||
/\/api\/projects\/[^/]+\/thumbnail\//.test(request.url());
request.url().startsWith("blob:") ||
/\/api\/projects\/[^/]+\/(thumbnail\/|lint(\?|$))/.test(request.url());
/**
* The Studio page's network, for the stillness check: requests in flight, a counter bumped by any request or
@@ -4,6 +4,7 @@ import { join } from "node:path";
import { describe, expect, it } from "vitest";
import {
STILL_FRAMES,
backgroundRequest,
heldStill,
networkBusy,
seekBound,
@@ -98,6 +99,18 @@ describe("settling on the page's network", () => {
expect(unsettledBy(start, now)).toBe(true);
});
it("never waits on thumbnails, their blob images or background lint, which do not change the preview", () => {
const request = (url, type = "fetch") => ({ url: () => url, resourceType: () => type });
const api = "http://127.0.0.1:5910/api/projects/case";
expect(backgroundRequest(request(`${api}/lint`))).toBe(true);
expect(backgroundRequest(request(`${api}/thumbnail/index.html?t=3.00`))).toBe(true);
expect(backgroundRequest(request(`${api}/events`, "eventsource"))).toBe(true);
expect(backgroundRequest(request("blob:http://127.0.0.1:5910/7baf001f", "image"))).toBe(true);
expect(backgroundRequest(request(`${api}/preview`, "document"))).toBe(false);
expect(backgroundRequest(request(`${api}/files/index.html`))).toBe(false);
expect(backgroundRequest(request(`${api}/lint-rules`))).toBe(false);
});
it("waits for requests in live frames and for the server to announce each written file", () => {
const dir = mkdtempSync(join(tmpdir(), "edit-bench-net-"));
try {