From e441e8bb174ae3ee2fc3e3988175e1b48f13ad72 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 1 Apr 2026 07:39:55 +0100 Subject: [PATCH] test: stabilize timed-heavy channel planner checks --- test/scripts/test-planner.test.ts | 40 ++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/test/scripts/test-planner.test.ts b/test/scripts/test-planner.test.ts index 77f1c295ff4..f3cd1ed0b9b 100644 --- a/test/scripts/test-planner.test.ts +++ b/test/scripts/test-planner.test.ts @@ -1,6 +1,7 @@ import fs from "node:fs"; import path from "node:path"; import { describe, expect, it } from "vitest"; +import { loadTestCatalog } from "../../scripts/test-planner/catalog.mjs"; import { createExecutionArtifacts, createTempArtifactWriteStream, @@ -12,8 +13,32 @@ import { buildExecutionPlan, explainExecutionTarget, } from "../../scripts/test-planner/planner.mjs"; +import { + loadChannelTimingManifest, + selectTimedHeavyFiles, +} from "../../scripts/test-runner-manifest.mjs"; import { bundledPluginFile } from "../helpers/bundled-plugin-paths.js"; +const resolveTimedHeavyChannelFixture = () => { + const catalog = loadTestCatalog(); + const timings = loadChannelTimingManifest(); + const candidates = catalog.allKnownTestFiles.filter( + (file) => + catalog.channelTestPrefixes.some((prefix) => file.startsWith(prefix)) && + !catalog.channelIsolatedFileSet.has(file), + ); + const [file] = selectTimedHeavyFiles({ + candidates, + limit: 1, + minDurationMs: 12_000, + timings, + }); + if (!file) { + throw new Error("No timed-heavy channel fixture found"); + } + return file; +}; + describe("test planner", () => { it("builds a capability-aware plan for mid-memory local runs", () => { const artifacts = createExecutionArtifacts({ @@ -173,8 +198,9 @@ describe("test planner", () => { }, ); + const timedHeavyFile = resolveTimedHeavyChannelFixture(); const hotspotUnit = plan.selectedUnits.find( - (unit) => unit.id === "channels-bot-native-commands.plugin-auth-isolated", + (unit) => unit.id === `channels-${path.basename(timedHeavyFile, ".test.ts")}-isolated`, ); expect(hotspotUnit).toBeTruthy(); @@ -469,16 +495,18 @@ describe("test planner", () => { }); it("explains timed-heavy channel suites as isolated", () => { + const env = { + CI: "true", + GITHUB_ACTIONS: "true", + }; + const timedHeavyFile = resolveTimedHeavyChannelFixture(); const explanation = explainExecutionTarget( { mode: "ci", - fileFilters: ["extensions/telegram/src/bot-native-commands.plugin-auth.test.ts"], + fileFilters: [timedHeavyFile], }, { - env: { - CI: "true", - GITHUB_ACTIONS: "true", - }, + env, }, );