mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-01 02:52:49 +08:00
test(skins): verify surface deletion recovery
This commit is contained in:
1 parent
da0472383d
commit
3fd8e76a98
2 files changed
+74
-1
No files matched your search
@@ -140,7 +140,7 @@ schema v2 支持公开组件布局、桌面/平板/手机配置、本地覆盖
|
||||
- 存储现按皮肤 ID 和版本分键;单份损坏数据可以单独清除并恢复原包,不影响其他皮肤。宿主保留的 data-ws-* 属性不会由作者节点写入渲染 DOM。
|
||||
- 编辑器操作按钮和选择器现在保留至少 44 px 触控高度,支持 Escape 关闭并在打开/关闭时移动焦点;继续打磨窄屏布局和可理解的校验提示。组件新增权限仍由宿主按既有权限机制要求批准;删除整页 surface 后应自然回到 WebSpeak 页面和宿主恢复控件。
|
||||
- 稳定门禁至少覆盖:组件/节点完整 CRUD 与撤销重做;导入导出往返;空组件文档;旧 schema v1/v2 只读兼容并在首次编辑时安全升到 v3;存储按皮肤版本隔离且坏数据可独立恢复;非法或越权文档不保存、不渲染;页面切换、皮肤切换及恢复入口不丢失。
|
||||
- 2026-10-10 的统一验证通过:621 项测试通过,服务端 TypeScript 构建、前端类型检查与 Vite 生产构建通过。编辑器到渲染出口的集成回归已证明新增、修改、删除会即时更新页面预览;运行时插件的屏幕采集动作也有回归证明其异步动作桥会拒绝并要求使用可信宿主控件。这仍不代表真实窄屏作者体验、跨浏览器行为或插件安全边界已经验收。
|
||||
- 2026-10-10 的统一验证通过:622 项测试通过,服务端 TypeScript 构建、前端类型检查与 Vite 生产构建通过。编辑器到渲染出口的集成回归已证明新增、修改、删除会即时更新页面预览;删除最后一个已授权 surface 也会自动恢复宿主页面;运行时插件的屏幕采集动作会被异步桥拒绝并要求使用可信宿主控件。这仍不代表真实窄屏作者体验、跨浏览器行为或插件安全边界已经验收。
|
||||
- 当前补查发现客户端曾接受 v4 包级 `layout.json`,服务端却未读取该字段,造成同一个包本地可导入但服务端拒绝;已为校验一致性修复补充回归用例。后续只在整批修改后统一验证。
|
||||
- 组件渲染器原先只按素材路径缓存 Blob URL,切换皮肤后同名图片可能沿用旧皮肤素材,旧 URL 也会一直留到卸载;现改为同时绑定 Blob,并在资源替换、皮肤切换或组件卸载时释放。对应缺失素材和换包回归已加入自动化验证。
|
||||
- R5 完成门槛包括:编辑器能完整管理组件和节点;更新后页面即时预览;导入、导出、版本隔离、坏数据恢复及旧格式迁移可靠;客户端与服务端对每种包格式采用一致校验;键盘与窄屏作者流程可用;授权拒绝/撤销、恢复原生页面、插件销毁与资源回收通过针对性验证;跨浏览器动作和资源边界完成独立复核。
|
||||
|
||||
@@ -13,6 +13,7 @@ let vite;
|
||||
let SkinPluginEditor;
|
||||
let SkinPluginOutlet;
|
||||
let authoring;
|
||||
let approvals;
|
||||
let focusedNode;
|
||||
const localStorageDescriptor = Object.getOwnPropertyDescriptor(globalThis, "localStorage");
|
||||
|
||||
@@ -35,6 +36,7 @@ const hostNode = (tag, type = "element") => ({
|
||||
},
|
||||
dispatchEvent(event) { for (const listener of this.listeners.get(event.type) ?? []) listener(event); },
|
||||
});
|
||||
const teleportRoot = hostNode("teleport-root");
|
||||
function insert(child, parent, anchor = null) {
|
||||
if (child.parent) {
|
||||
const previous = child.parent.children.indexOf(child);
|
||||
@@ -61,6 +63,7 @@ const renderer = createRenderer({
|
||||
node.parent = null;
|
||||
},
|
||||
parentNode: node => node.parent,
|
||||
querySelector: selector => selector === "body" ? teleportRoot : null,
|
||||
nextSibling(node) {
|
||||
if (!node.parent) return null;
|
||||
return node.parent.children[node.parent.children.indexOf(node) + 1] ?? null;
|
||||
@@ -135,6 +138,7 @@ before(async () => {
|
||||
});
|
||||
({ default: SkinPluginEditor } = await vite.ssrLoadModule("/src/components/SkinPluginEditor.vue"));
|
||||
({ default: SkinPluginOutlet } = await vite.ssrLoadModule("/src/components/SkinPluginOutlet.ts"));
|
||||
approvals = await vite.ssrLoadModule("/src/services/skin-plugin-approval.ts");
|
||||
const require = createRequire(import.meta.url);
|
||||
const { parse, compileScript, compileTemplate } = require("../node_modules/@vue/compiler-sfc");
|
||||
const filename = fileURLToPath(new URL("../src/components/SkinPluginEditor.vue", import.meta.url));
|
||||
@@ -358,3 +362,72 @@ test("component create, update, and delete immediately change the rendered skin
|
||||
app.unmount();
|
||||
}
|
||||
});
|
||||
|
||||
test("deleting the last surface component immediately restores the host page", async () => {
|
||||
Object.defineProperty(globalThis, "localStorage", { configurable: true, value: new MemoryStorage() });
|
||||
const skinId = "community.surface";
|
||||
const skinVersion = "1.0.0";
|
||||
const baseDocument = {
|
||||
schemaVersion: 3,
|
||||
components: [{
|
||||
id: "full-surface",
|
||||
name: "Full surface",
|
||||
page: "voice",
|
||||
mode: "surface",
|
||||
accessibleName: "Full voice page",
|
||||
permissions: ["ui.surface.replace"],
|
||||
actions: {},
|
||||
root: { tag: "main", children: [{ text: "Custom voice surface" }] },
|
||||
}],
|
||||
};
|
||||
approvals.approveSkinPluginComponents(skinId, skinVersion, baseDocument.components);
|
||||
const revision = Vue.ref(0);
|
||||
const surfaceActive = Vue.ref(false);
|
||||
const props = { skinId, skinVersion, baseDocument, page: "voice", lang: "zh" };
|
||||
const preview = Vue.defineComponent({
|
||||
setup() {
|
||||
const currentDocument = () => {
|
||||
revision.value;
|
||||
return authoring.loadSkinPluginAuthoringDocument(skinId, skinVersion) ?? baseDocument;
|
||||
};
|
||||
return () => Vue.h("main", null, [
|
||||
surfaceActive.value ? null : Vue.h("section", { "data-native-host": "true" }, "WebSpeak host page"),
|
||||
Vue.h(SkinPluginOutlet, {
|
||||
skinId,
|
||||
skinVersion,
|
||||
document: currentDocument(),
|
||||
page: "voice",
|
||||
data: {},
|
||||
assets: {},
|
||||
actions: {},
|
||||
manageSurfaceRecovery: false,
|
||||
onSurfaceChange: (active) => { surfaceActive.value = active; },
|
||||
}),
|
||||
Vue.h(SkinPluginEditor, { ...props, onUpdated: () => { revision.value += 1; } }),
|
||||
]);
|
||||
},
|
||||
});
|
||||
const root = hostNode("root");
|
||||
const app = renderer.createApp(preview);
|
||||
app.provide(ssrContextKey, { modules: new Set() });
|
||||
app.mount(root);
|
||||
|
||||
try {
|
||||
await nextTick();
|
||||
assert.equal(surfaceActive.value, true, "the approved surface replaces the host page");
|
||||
assert.equal(visit(root, node => node.props["data-native-host"] === "true"), null);
|
||||
|
||||
clickButton(root, "组件结构");
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
clickButton(root, "删除组件");
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
|
||||
assert.equal(surfaceActive.value, false, "deleting the surface clears its active state");
|
||||
assert.equal(visit(root, node => node.props["data-ws-plugin-surface"] === "voice"), null);
|
||||
assert.match(nodeText(root), /WebSpeak host page/, "the host page is restored without requiring a skin reset");
|
||||
} finally {
|
||||
app.unmount();
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user