mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-19 22:15:12 +08:00
🐛 fix(update): 同步 Windows Portable 更新版本
- 版本化 Portable 更新后切换到新包文件名并清理旧文件 - 下载完成进度采用后端实际返回的版本与资产 - 补充前端竞态和 Windows PowerShell 集成回归测试
This commit is contained in:
@@ -167,6 +167,63 @@ describe('useAppUpdateManager', () => {
|
||||
}));
|
||||
});
|
||||
|
||||
it('uses the backend download result version for progress and cached update metadata', async () => {
|
||||
backendApp.CheckForUpdates.mockResolvedValue({
|
||||
success: true,
|
||||
data: {
|
||||
hasUpdate: true,
|
||||
channel: 'dev',
|
||||
currentVersion: 'dev-current',
|
||||
latestVersion: 'dev-old',
|
||||
assetName: 'GoNavi-dev-old-Windows-Amd64-Portable.exe',
|
||||
packageType: 'portable',
|
||||
installMode: 'portable',
|
||||
autoRelaunch: true,
|
||||
downloaded: false,
|
||||
assetSize: 4096,
|
||||
},
|
||||
});
|
||||
backendApp.DownloadUpdate.mockResolvedValue({
|
||||
success: true,
|
||||
data: {
|
||||
info: {
|
||||
hasUpdate: true,
|
||||
channel: 'dev',
|
||||
currentVersion: 'dev-current',
|
||||
latestVersion: 'dev-new',
|
||||
assetName: 'GoNavi-dev-new-Windows-Amd64-Portable.exe',
|
||||
packageType: 'portable',
|
||||
installMode: 'portable',
|
||||
autoRelaunch: true,
|
||||
},
|
||||
downloadPath: 'C:\\GoNavi\\GoNavi-dev-new-Windows-Amd64-Portable.exe',
|
||||
packageType: 'portable',
|
||||
installMode: 'portable',
|
||||
autoRelaunch: true,
|
||||
},
|
||||
});
|
||||
|
||||
renderHook();
|
||||
await act(async () => {
|
||||
await hook?.checkForUpdates(false);
|
||||
});
|
||||
await act(async () => {
|
||||
await hook?.downloadUpdate(hook?.lastUpdateInfo!, false);
|
||||
});
|
||||
|
||||
expect(hook?.lastUpdateInfo).toMatchObject({
|
||||
latestVersion: 'dev-new',
|
||||
assetName: 'GoNavi-dev-new-Windows-Amd64-Portable.exe',
|
||||
downloaded: true,
|
||||
downloadPath: 'C:\\GoNavi\\GoNavi-dev-new-Windows-Amd64-Portable.exe',
|
||||
});
|
||||
expect(hook?.updateDownloadProgress).toMatchObject({
|
||||
version: 'dev-new',
|
||||
key: 'dev:dev-new:portable:gonavi-dev-new-windows-amd64-portable.exe',
|
||||
status: 'done',
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps same-version Portable and MSI downloads in separate cache identities', async () => {
|
||||
const portableInfo = {
|
||||
hasUpdate: true,
|
||||
|
||||
@@ -314,6 +314,7 @@ export const useAppUpdateManager = ({
|
||||
const total = prev.total > 0 ? prev.total : (info.assetSize || 0);
|
||||
return {
|
||||
...prev,
|
||||
version: downloadedInfo.latestVersion,
|
||||
key: downloadedKey,
|
||||
status: 'done',
|
||||
percent: 100,
|
||||
@@ -328,6 +329,7 @@ export const useAppUpdateManager = ({
|
||||
// 下载到 100% 后停留在就绪态,由用户确认当前安装方式对应的更新动作。
|
||||
setUpdateDownloadProgress((prev) => ({
|
||||
...prev,
|
||||
version: downloadedInfo.latestVersion,
|
||||
open: prev.open || !updateUserDismissedRef.current,
|
||||
status: 'done',
|
||||
percent: 100,
|
||||
|
||||
Reference in New Issue
Block a user