补 C7 版本切换「重载当前预览」验收测试

- resourceVersionSwitch 新增用例:运行模块内切换版本必须既上报宿主又触发 onPlay 重载预览
- 覆盖验收用例 S16 的「并重载当前预览」条款(此前版本入口只测了记录层与高亮,重载没有守卫)
- 变异验证:摘掉 selectActiveVersion 里的 onPlay 调用后,该用例以 expected "spy" to be called at least once 失败
- 定向验证:resourceVersionSwitch 4 passed
This commit is contained in:
2026-09-12 13:34:32 +08:00
parent 028b20a590
commit 3015370286
@@ -216,6 +216,26 @@ describe('C7 运行模块版本切换', () => {
expect(onActiveVersionChange).toHaveBeenCalledWith('version-root');
});
test('reloads the current preview when the version changes in the run module', async () => {
installResourceCardIntersectionObserver();
const manifest = createVersionedManifest();
const onPlay = vi.fn();
const onActiveVersionChange = vi.fn();
renderWorkbench(manifest, { onPlay, onActiveVersionChange });
fireEvent.click(screen.getByRole('tab', { name: '运行' }));
fireEvent.click(await screen.findByLabelText(/^当前版本:/));
const menu = await screen.findByRole('listbox', {
name: '切换游戏版本',
});
fireEvent.click(within(menu).getByRole('option', { name: /初始版本/ }));
expect(onActiveVersionChange).toHaveBeenCalledWith('version-root');
// 验收用例 S16 的「并重载当前预览」:只改记录层而不重载,用户看到的仍是上一个版本的
// 画面(素材不可变,画面靠重载预览回到该版本对应的资源),切换就成了"点了没反应"。
expect(onPlay).toHaveBeenCalled();
});
test('drives the "current use" card highlight from the active version', async () => {
installResourceCardIntersectionObserver();
const manifest = createVersionedManifest();