H2: warm up first editor and modals outside the test budget

The first CodeMirror view and the first render of the editor area,
the palette and the settings dialog in a jsdom worker cost 0.3-0.6 s
once. The first test of EditorArea, language and modals paid it inside
its own 5 s budget and timed out under load. A beforeAll warm-up now
pays it once; no timeout changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-10-25 13:30:57 +01:00
parent e969f6497c
commit 9407d5d6c2
3 changed files with 88 additions and 16 deletions

View file

@ -7,7 +7,7 @@
*/
import { flushPromises, mount, type VueWrapper } from "@vue/test-utils";
import { createPinia, setActivePinia, type Pinia } from "pinia";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { defineComponent, h } from "vue";
const invoke = vi.hoisted(() => vi.fn());
@ -84,7 +84,8 @@ function recoveryShown(): boolean {
return document.querySelector("[data-test=recovery-dialog]") !== null;
}
beforeEach(() => {
/** Fresh Pinia and a fake engine without commands or settings. */
function resetFakeEngine(): void {
pinia = createPinia();
setActivePinia(pinia);
listeners = [];
@ -109,14 +110,37 @@ beforeEach(() => {
}
return Promise.resolve(null);
});
});
}
afterEach(() => {
/** Stops the commands and unmounts every mounted component. */
function unmountAll(): void {
useCommandsStore(pinia).stop();
for (const wrapper of mounted) {
wrapper.unmount();
}
});
}
/**
* Pays the one-time cost of the first modals outside any test: mounts the
* app's modals, opens the palette and then the settings dialog, and
* unmounts again. The first render of the palette and the settings dialog
* in a jsdom worker runs cold (about 0.3 s on an idle machine, against
* 50-100 ms later). Without this, the first test paid that cost inside its
* own 5 s budget and timed out under load.
*/
async function warmUpModals(): Promise<void> {
resetFakeEngine();
await mountApp();
await uiCommand("palette.open");
await uiCommand("settings.open");
unmountAll();
}
beforeAll(warmUpModals);
beforeEach(resetFakeEngine);
afterEach(unmountAll);
describe("one modal at a time", () => {
it("settings.open from the control channel closes the open palette", async () => {