Files
piik/tests/release-mirror-source.test.ts
T
TNTcraft 07e37c7228 fix(app): stabilize authorization and compact room controls
## Problem and outcome / 问题与结果

App authorization could stay busy after a stalled save, a pending microphone request could survive a capture-source handoff, and compact room controls could lose focus, position or readable names. This maintenance phase corrects those owners and makes connection help easier to find.

## Verification / 验证

Validation: the exact candidate tree passed all 1,943 Web tests and documentation checks. Its unchanged product source has passed TypeScript and a production Web build. Controlled UI checks cover delayed microphone permission, stalled approval responses, keyboard viewport changes, rapid floating-panel hide/show and narrow nickname layouts. Published 2.x wire, native control and storage contracts are unchanged.

## Impact / 影响

Compatible 2.x maintenance release. Existing App, site and persisted room contracts are retained. Matching packages, download mirrors and both managed sites are verified through the normal release workflow.

## Release notes

**Piik, now in your pocket.**

Piik App supports Android screen sharing, with touch controls for a friend's computer.

**手机,也能开播。**

Piik App 支持 Android 屏幕分享,也能用手机控制朋友的电脑。

### English

This maintenance update improves App authorization, capture-source switching and controls on smaller screens.

- Fix commentary controls remaining busy after switching from Browser capture to the App.
- Let App site approval recover from a stalled save, keeping access already granted.
- Preserve numeric-input focus when the mobile keyboard resizes the page, and provide increase/decrease buttons. Keep interaction windows at their remembered position after rapid hide/show actions.
- Give nicknames readable space on smaller screens, while retaining edit controls and accessible labels. Keep launcher diagnostics inside the shared Help menu.
- Make room-connection help easier to find, and clarify Safari screen-sharing and sound support.
- Complete package mirroring after a later CI publication step fails, and verify managed-service deployments against the intended source revision.

This maintenance update preserves the established 2.x room, invitation, media,
App-control and storage contracts. Refresh a site's open pages after it is
updated. App-local users need the updated App bundle to receive its included
Web fixes. Existing compatible 2.x App/site workflows remain supported.

### 中文

本次维护更新改善 App 授权、切换分享源和小屏操作。

- 修复浏览器切换为 App 采集后,分享麦克风控制一直处于忙碌状态的问题。
- App 站点授权不再因保存卡住而一直转圈;可以重试,已批准的授权也会保留。
- 手机键盘改变页面尺寸时保留数字输入焦点,并提供增减按钮;互动窗口快速隐藏再打开后保留记忆位置。
- 小屏上为昵称保留可读空间,同时保留编辑入口与无障碍名称;启动页诊断统一收进帮助菜单。
- 更容易找到房间连接问题的排查入口,并说明 Safari 屏幕分享与声音的支持情况。
- 发布流程后续步骤失败时,仍可补全已经发布的程序包镜像;部署核验明确比对预期源码版本。

本维护更新保留既有 2.x 房间、邀请、媒体、App 控制与存储契约。
站点更新后请刷新已打开的网页;App 本地使用者需更新程序包,才能使用其中的新网页修复。
已有兼容的 2.x App/站点使用方式继续支持。
2026-11-08 12:28:03 -04:00

73 lines
3.4 KiB
TypeScript

import { beforeEach, describe, expect, it, vi } from "vitest";
import { resolveMirrorSource } from "../scripts/release-mirror-source.mjs";
const { command } = vi.hoisted(() => ({ command: vi.fn() }));
vi.mock("node:child_process", () => ({ execFileSync: command }));
const repository = "TNTcraftHIM/Piik";
const revision = "a".repeat(40);
const run = {
id: 12345, repository: { full_name: repository }, head_repository: { full_name: repository },
event: "push", head_branch: "main", head_sha: revision,
path: ".github/workflows/repository-hygiene.yml", status: "completed", conclusion: "success",
};
const release = { tag_name: "v1.9.2", target_commitish: revision, draft: false, prerelease: false };
function api(source = run, latest = release) {
command.mockImplementation((program: string, args: string[]) => {
expect(program).toBe("gh");
if (args[1] === `repos/${repository}/actions/runs/12345`) return JSON.stringify(source);
if (args[1] === `repos/${repository}/releases/latest`) return JSON.stringify(latest);
throw new Error(`Unexpected request: ${args.join(" ")}`);
});
}
beforeEach(() => { command.mockReset(); api(); });
describe("mirror source authority", () => {
it("binds automatic and manual retries to the published source run", () => {
const expected = { run_id: "12345", version: release.tag_name, revision };
expect(resolveMirrorSource("12345", true)).toEqual(expected);
expect(resolveMirrorSource("12345")).toEqual(expected);
api({ ...run, conclusion: "failure" });
expect(resolveMirrorSource("12345")).toEqual(expected);
expect(resolveMirrorSource("12345", true)).toEqual(expected);
});
it.each(["", "012345", "1e3", "-1", "12345\nmirror=true", "9007199254740992", undefined])
("rejects invalid run IDs before accessing GitHub: %s", (id) => {
expect(() => resolveMirrorSource(id)).toThrow(/numeric ID/);
expect(command).not.toHaveBeenCalled();
});
it.each([
{ id: 99 }, { repository: { full_name: "fork/Piik" } },
{ head_repository: { full_name: "fork/Piik" } }, { event: "pull_request" },
{ event: "workflow_dispatch" }, { head_branch: "preview" },
{ path: ".github/workflows/other.yml" }, { status: "in_progress" }, { head_sha: "short" },
])("rejects artifacts from a different authority or unfinished run: %j", (patch) => {
api({ ...run, ...patch });
expect(() => resolveMirrorSource("12345")).toThrow(/completed main push/);
expect(command).toHaveBeenCalledTimes(1);
});
it("skips automatic runs without a current release and refuses an explicit stale retry", () => {
for (const conclusion of ["success", "failure", "cancelled"]) {
api({ ...run, conclusion }, { ...release, target_commitish: "b".repeat(40) });
expect(resolveMirrorSource("12345", true)).toBeNull();
expect(() => resolveMirrorSource("12345")).toThrow(/does not match the latest/);
}
});
it.each([{ draft: true }, { prerelease: true }, { tag_name: "preview" }, { target_commitish: "main" }])
("rejects an unverified release: %j", (patch) => {
api(run, { ...release, ...patch });
expect(() => resolveMirrorSource("12345")).toThrow(/published stable GitHub release/);
});
it("does not turn an API failure into an empty successful mirror", () => {
command.mockImplementationOnce(() => { throw new Error("GitHub unavailable"); });
expect(() => resolveMirrorSource("12345", true)).toThrow("GitHub unavailable");
});
});