Merge branch 'dev' into feat/ci-flatpak
This commit is contained in:
commit
aa97159837
@ -48,6 +48,12 @@ Object.defineProperty(window, 'core', {
|
|||||||
writable: true,
|
writable: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Mock global AUTO_UPDATER_DISABLED
|
||||||
|
Object.defineProperty(global, 'AUTO_UPDATER_DISABLED', {
|
||||||
|
value: false,
|
||||||
|
writable: true,
|
||||||
|
})
|
||||||
|
|
||||||
import { isDev } from '@/lib/utils'
|
import { isDev } from '@/lib/utils'
|
||||||
import { check } from '@tauri-apps/plugin-updater'
|
import { check } from '@tauri-apps/plugin-updater'
|
||||||
import { events } from '@janhq/core'
|
import { events } from '@janhq/core'
|
||||||
@ -251,11 +257,14 @@ describe('useAppUpdater', () => {
|
|||||||
downloadAndInstall: mockDownloadAndInstall,
|
downloadAndInstall: mockDownloadAndInstall,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mock check to return the update
|
||||||
|
mockCheck.mockResolvedValue(mockUpdate)
|
||||||
|
|
||||||
const { result } = renderHook(() => useAppUpdater())
|
const { result } = renderHook(() => useAppUpdater())
|
||||||
|
|
||||||
// Set update info first
|
// Set update info first by calling checkForUpdate
|
||||||
act(() => {
|
await act(async () => {
|
||||||
result.current.updateState.updateInfo = mockUpdate
|
await result.current.checkForUpdate()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Mock the download and install process
|
// Mock the download and install process
|
||||||
@ -296,11 +305,14 @@ describe('useAppUpdater', () => {
|
|||||||
downloadAndInstall: mockDownloadAndInstall,
|
downloadAndInstall: mockDownloadAndInstall,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mock check to return the update
|
||||||
|
mockCheck.mockResolvedValue(mockUpdate)
|
||||||
|
|
||||||
const { result } = renderHook(() => useAppUpdater())
|
const { result } = renderHook(() => useAppUpdater())
|
||||||
|
|
||||||
// Set update info first
|
// Set update info first by calling checkForUpdate
|
||||||
act(() => {
|
await act(async () => {
|
||||||
result.current.updateState.updateInfo = mockUpdate
|
await result.current.checkForUpdate()
|
||||||
})
|
})
|
||||||
|
|
||||||
mockDownloadAndInstall.mockRejectedValue(new Error('Download failed'))
|
mockDownloadAndInstall.mockRejectedValue(new Error('Download failed'))
|
||||||
@ -338,11 +350,14 @@ describe('useAppUpdater', () => {
|
|||||||
downloadAndInstall: mockDownloadAndInstall,
|
downloadAndInstall: mockDownloadAndInstall,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mock check to return the update
|
||||||
|
mockCheck.mockResolvedValue(mockUpdate)
|
||||||
|
|
||||||
const { result } = renderHook(() => useAppUpdater())
|
const { result } = renderHook(() => useAppUpdater())
|
||||||
|
|
||||||
// Set update info first
|
// Set update info first by calling checkForUpdate
|
||||||
act(() => {
|
await act(async () => {
|
||||||
result.current.updateState.updateInfo = mockUpdate
|
await result.current.checkForUpdate()
|
||||||
})
|
})
|
||||||
|
|
||||||
mockDownloadAndInstall.mockImplementation(async (progressCallback) => {
|
mockDownloadAndInstall.mockImplementation(async (progressCallback) => {
|
||||||
|
|||||||
@ -53,6 +53,11 @@ export const useAppUpdater = () => {
|
|||||||
|
|
||||||
const checkForUpdate = useCallback(
|
const checkForUpdate = useCallback(
|
||||||
async (resetRemindMeLater = false) => {
|
async (resetRemindMeLater = false) => {
|
||||||
|
if (AUTO_UPDATER_DISABLED) {
|
||||||
|
console.log('Auto updater is disabled')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Reset remindMeLater if requested (e.g., when called from settings)
|
// Reset remindMeLater if requested (e.g., when called from settings)
|
||||||
if (resetRemindMeLater) {
|
if (resetRemindMeLater) {
|
||||||
@ -148,6 +153,11 @@ export const useAppUpdater = () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const downloadAndInstallUpdate = useCallback(async () => {
|
const downloadAndInstallUpdate = useCallback(async () => {
|
||||||
|
if (AUTO_UPDATER_DISABLED) {
|
||||||
|
console.log('Auto updater is disabled')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!updateState.updateInfo) return
|
if (!updateState.updateInfo) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -260,26 +260,28 @@ function General() {
|
|||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<CardItem
|
{!AUTO_UPDATER_DISABLED && (
|
||||||
title={t('settings:general.checkForUpdates')}
|
<CardItem
|
||||||
description={t('settings:general.checkForUpdatesDesc')}
|
title={t('settings:general.checkForUpdates')}
|
||||||
className="flex-col sm:flex-row items-start sm:items-center sm:justify-between gap-y-2"
|
description={t('settings:general.checkForUpdatesDesc')}
|
||||||
actions={
|
className="flex-col sm:flex-row items-start sm:items-center sm:justify-between gap-y-2"
|
||||||
<Button
|
actions={
|
||||||
variant="link"
|
<Button
|
||||||
size="sm"
|
variant="link"
|
||||||
className="p-0"
|
size="sm"
|
||||||
onClick={handleCheckForUpdate}
|
className="p-0"
|
||||||
disabled={isCheckingUpdate}
|
onClick={handleCheckForUpdate}
|
||||||
>
|
disabled={isCheckingUpdate}
|
||||||
<div className="cursor-pointer rounded-sm hover:bg-main-view-fg/15 bg-main-view-fg/10 transition-all duration-200 ease-in-out px-2 py-1 gap-1">
|
>
|
||||||
{isCheckingUpdate
|
<div className="cursor-pointer rounded-sm hover:bg-main-view-fg/15 bg-main-view-fg/10 transition-all duration-200 ease-in-out px-2 py-1 gap-1">
|
||||||
? t('settings:general.checkingForUpdates')
|
{isCheckingUpdate
|
||||||
: t('settings:general.checkForUpdates')}
|
? t('settings:general.checkingForUpdates')
|
||||||
</div>
|
: t('settings:general.checkForUpdates')}
|
||||||
</Button>
|
</div>
|
||||||
}
|
</Button>
|
||||||
/>
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{/* <CardItem
|
{/* <CardItem
|
||||||
title={t('common:language')}
|
title={t('common:language')}
|
||||||
actions={<LanguageSwitcher />}
|
actions={<LanguageSwitcher />}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user