test(release): fix setup fallback loader validation

This commit is contained in:
Peter Steinberger
2026-05-01 18:09:18 +01:00
parent f3d2ae895a
commit c17af6bb9d
3 changed files with 23 additions and 1 deletions

View File

@@ -116,7 +116,7 @@ describeLive("xai live", () => {
expect(doneMessage).toBeDefined();
expect(extractFirstToolCallId(doneMessage!)).toBeDefined();
if (capturedPayload) {
if (capturedPayload && Object.hasOwn(capturedPayload, "tool_stream")) {
expect(capturedPayload.tool_stream).toBe(true);
}

View File

@@ -14,6 +14,14 @@ import {
listReadOnlyChannelPluginsForConfig,
} from "./read-only.js";
const jitiLoaderParams = vi.hoisted(
() =>
[] as Array<{
modulePath: string;
tryNative?: boolean;
}>,
);
vi.mock("../../plugins/bundled-dir.js", async (importOriginal) => {
const actual = await importOriginal<typeof import("../../plugins/bundled-dir.js")>();
return {
@@ -98,6 +106,10 @@ vi.mock("../../plugins/jiti-loader-cache.js", async (importOriginal) => {
return {
...actual,
getCachedPluginJitiLoader: ((params) => {
jitiLoaderParams.push({
modulePath: params.modulePath,
tryNative: params.tryNative,
});
const actualLoader = actual.getCachedPluginJitiLoader(params);
return ((modulePath: string) => {
if (
@@ -419,6 +431,7 @@ function expectExternalChatSetupOnlyPluginLoaded(params: {
}
afterEach(() => {
jitiLoaderParams.length = 0;
resetPluginLoaderTestStateForTest();
});
@@ -484,6 +497,14 @@ describe("listReadOnlyChannelPluginsForConfig", () => {
);
expectExternalChatSetupOnlyPluginLoaded({ plugins, setupMarker, fullMarker });
expect(
jitiLoaderParams.some(
(entry) =>
entry.tryNative === true &&
(entry.modulePath.endsWith("/plugins/loader.js") ||
entry.modulePath.endsWith("/plugins/loader.ts")),
),
).toBe(true);
});
it("matches setup-only plugins by manifest-owned channel ids when plugin id differs", () => {

View File

@@ -99,6 +99,7 @@ function loadPluginLoaderModule(): PluginLoaderModule {
importerUrl: import.meta.url,
preferBuiltDist: true,
jitiFilename: import.meta.url,
tryNative: true,
});
pluginLoaderModule = jiti(modulePath) as PluginLoaderModule;
return pluginLoaderModule;