Locally accepted: 32 files/468 tests, typecheck, client/server builds, repository hygiene, and independent P0/P1 review. PR head had zero Actions runs.
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
shouldPauseLocalPreview,
|
|
sourceSwitchNotice,
|
|
} from "../src/client/pages/host-page-notices.ts";
|
|
|
|
describe("shouldPauseLocalPreview", () => {
|
|
it("distinguishes local preview suspension from active focus", () => {
|
|
expect(shouldPauseLocalPreview("hidden", true)).toBe(true);
|
|
expect(shouldPauseLocalPreview("visible", false)).toBe(true);
|
|
expect(shouldPauseLocalPreview("visible", true)).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("sourceSwitchNotice", () => {
|
|
it("does not report success when the SFU source replacement failed", () => {
|
|
expect(
|
|
sourceSwitchNotice({
|
|
failedPeerCount: 0,
|
|
sfuReplaced: false,
|
|
sfuWarning: null,
|
|
}),
|
|
).toBe("SFU 分享来源未切换成功,正在恢复观看连接");
|
|
});
|
|
|
|
it("surfaces an SFU sender warning after a successful replacement", () => {
|
|
expect(
|
|
sourceSwitchNotice({
|
|
failedPeerCount: 1,
|
|
sfuReplaced: true,
|
|
sfuWarning: "浏览器改写了 SFU 发送参数",
|
|
}),
|
|
).toBe("浏览器改写了 SFU 发送参数;部分观看者正在重新连接");
|
|
});
|
|
|
|
it("reports success only when every active route replacement succeeded", () => {
|
|
expect(
|
|
sourceSwitchNotice({
|
|
failedPeerCount: 0,
|
|
sfuReplaced: true,
|
|
sfuWarning: null,
|
|
}),
|
|
).toBe("分享来源已切换");
|
|
});
|
|
});
|