The orchestration that used these helpers was retired in5d4a67cfand5126b9a0, leaving them reachable only from their own tests. The Browser- rejected video check and its error, the encoded-frame maximum, the quality label and whole-settings comparison (with the audio comparison it alone used), and the unused PeerSnapshot, ChannelRequest and NativePageMpdTrack types go. The video-only comparison, which the encoding pool and transport still use, stays. currentLang had no product caller; the tests that read the language through it now read it through say(), the accessor the product uses.
36 lines
1.9 KiB
TypeScript
36 lines
1.9 KiB
TypeScript
import { createElement } from "react";
|
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
import { expect, test, vi } from "vitest";
|
|
import { ChannelSettingsError, settingsActionFailure } from "../src/client/channel/components/ChannelSettingsDialog";
|
|
import { installDeferredModuleFailureTracking, isDeferredModuleFailure } from "../src/client/lib/deferred-module-failure";
|
|
import { say } from "../src/client/ui/copy";
|
|
|
|
test("deferred module failures show a user-triggered refresh in the shared result", () => {
|
|
const target = new EventTarget();
|
|
vi.stubGlobal("window", target);
|
|
try {
|
|
installDeferredModuleFailureTracking();
|
|
} finally {
|
|
vi.unstubAllGlobals();
|
|
}
|
|
const error = new TypeError("The operation failed");
|
|
const event = Object.assign(new Event("vite:preloadError", { cancelable: true }), { payload: error });
|
|
expect(target.dispatchEvent(event)).toBe(true);
|
|
expect(isDeferredModuleFailure(error)).toBe(true);
|
|
expect(isDeferredModuleFailure(new TypeError(error.message))).toBe(false);
|
|
|
|
const html = renderToStaticMarkup(createElement(ChannelSettingsError, { error: "deferred_module_load_failed" }));
|
|
expect(html).toContain(say("channel.error.deferredModuleLoad"));
|
|
expect(html).toContain(`aria-label="${say("common.refresh")}"`);
|
|
const ordinaryResult = renderToStaticMarkup(createElement(ChannelSettingsError, { error: "operation_failed" }));
|
|
expect(ordinaryResult).toContain(say("channel.error.actionFailed"));
|
|
expect(ordinaryResult).not.toContain("<button");
|
|
});
|
|
|
|
test("an action owner keeps the failure code the banner would show and ignores cancellation", () => {
|
|
expect(settingsActionFailure(new DOMException("Cancelled", "AbortError"))).toBeNull();
|
|
expect(settingsActionFailure(new DOMException("Declined", "NotAllowedError"))).toBe("NotAllowedError");
|
|
expect(settingsActionFailure(new Error("room_host_offline"))).toBe("room_host_offline");
|
|
expect(settingsActionFailure("unknown")).toBe("operation_failed");
|
|
});
|