@@ -237,6 +237,12 @@ beforeEach(async () => {
237237 } ;
238238 vi . resetAllMocks ( ) ;
239239 ( extensionApi . env . createTelemetryLogger as Mock ) . mockReturnValue ( telemetryLogger ) ;
240+
241+ // Mock withProgress to execute the task immediately
242+ vi . mocked ( extensionApi . window . withProgress ) . mockImplementation ( ( _options , task ) => {
243+ return task ( { report : vi . fn ( ) } , { } as extensionApi . CancellationToken ) ;
244+ } ) ;
245+
240246 extension . initTelemetryLogger ( ) ;
241247 extension . initExtensionNotification ( ) ;
242248 extension . resetShouldNotifySetup ( ) ;
@@ -299,6 +305,7 @@ vi.mock('@podman-desktop/api', async () => {
299305 showInformationMessage : vi . fn ( ) ,
300306 showWarningMessage : vi . fn ( ) ,
301307 showNotification : vi . fn ( ) ,
308+ withProgress : vi . fn ( ) ,
302309 createStatusBarItem : ( ) => ( {
303310 show : vi . fn ( ) ,
304311 dispose : vi . fn ( ) ,
@@ -323,6 +330,11 @@ vi.mock('@podman-desktop/api', async () => {
323330 from : vi . fn ( ) ,
324331 create : vi . fn ( ) ,
325332 } ,
333+ CancellationToken : { } ,
334+ ProgressLocation : {
335+ TASK_WIDGET : 'TASK_WIDGET' ,
336+ APP_ICON : 'APP_ICON' ,
337+ } ,
326338 fs : {
327339 createFileSystemWatcher : vi . fn ( ) ,
328340 } ,
@@ -1683,6 +1695,54 @@ test('should register update when there are multiple Podman installations but cu
16831695 expect ( registerUpdateMock ) . toHaveBeenCalled ( ) ;
16841696} ) ;
16851697
1698+ test ( 'update should be wrapped with withProgress to create a visible task' , async ( ) => {
1699+ extension . initExtensionContext ( { subscriptions : [ ] } as unknown as extensionApi . ExtensionContext ) ;
1700+
1701+ const extensionContext = { subscriptions : [ ] , storagePath : '' } as unknown as extensionApi . ExtensionContext ;
1702+ const podmanInstall : PodmanInstall = new PodmanInstall (
1703+ extensionContext ,
1704+ telemetryLogger ,
1705+ { } as unknown as Installer ,
1706+ undefined ,
1707+ ) ;
1708+
1709+ vi . spyOn ( podmanCli , 'findPodmanInstallations' ) . mockResolvedValue ( [ '/usr/local/bin/podman' ] ) ;
1710+
1711+ vi . spyOn ( podmanInstall , 'checkForUpdate' ) . mockResolvedValue ( {
1712+ hasUpdate : true ,
1713+ bundledVersion : 'v5.0.0' ,
1714+ installedVersion : 'v4.9.0' ,
1715+ } ) ;
1716+
1717+ vi . spyOn ( podmanInstall , 'performUpdate' ) . mockResolvedValue ( ) ;
1718+
1719+ const withProgressSpy = vi . spyOn ( extensionApi . window , 'withProgress' ) ;
1720+
1721+ const installedPodman = { version : '4.9.0' } as InstalledPodman ;
1722+
1723+ let updater : extensionApi . ProviderUpdate | undefined ;
1724+ registerUpdateMock . mockImplementation ( ( update : extensionApi . ProviderUpdate ) => {
1725+ updater = update ;
1726+ } ) ;
1727+
1728+ await extension . registerUpdatesIfAny ( provider , installedPodman , podmanInstall ) ;
1729+
1730+ expect ( registerUpdateMock ) . toHaveBeenCalled ( ) ;
1731+ expect ( updater ) . toBeDefined ( ) ;
1732+
1733+ // Call the update function
1734+ await updater ?. update ( { } as extensionApi . Logger ) ;
1735+
1736+ // Verify withProgress was called with correct parameters
1737+ expect ( withProgressSpy ) . toHaveBeenCalledWith (
1738+ { location : extensionApi . ProgressLocation . TASK_WIDGET , title : 'Updating Podman' } ,
1739+ expect . any ( Function ) ,
1740+ ) ;
1741+
1742+ // Verify performUpdate was called
1743+ expect ( podmanInstall . performUpdate ) . toHaveBeenCalledWith ( provider , installedPodman ) ;
1744+ } ) ;
1745+
16861746test ( 'provider is registered with edit capabilities on MacOS' , async ( ) => {
16871747 // Mock platform to be darwin
16881748 vi . mocked ( extensionApi . env ) . isMac = true ;
0 commit comments