Skip to content

Conversation

@AlexisMora
Copy link

@AlexisMora AlexisMora commented Feb 10, 2026

What is Changed / Added

Now we hide backup folder selector when selecting path in hide explorer so that the file explorer always stays "on front" and dont overlap

Why

There was this issue while selecting the path to backup in the file explorer, where the backup folder selector window was overlaping the actual file explorer

@AlexisMora AlexisMora changed the title [PB-4263] hide backup folder selector when selecting path in hide explorer [PB-4263] Backup folders popup overlaps file explorer window Feb 10, 2026
@AlexisMora AlexisMora force-pushed the fix/pb-4263-backup-overlaps-file-explorer branch from f61c117 to 79ea1f8 Compare February 10, 2026 12:08
@AlexisMora AlexisMora self-assigned this Feb 10, 2026
@AlexisMora AlexisMora requested a review from egalvis27 February 10, 2026 12:11
@AlexisMora AlexisMora added bug Something isn't working DO NOT MERGE labels Feb 10, 2026
@sonarqubecloud
Copy link

@AlexisMora AlexisMora marked this pull request as ready for review February 10, 2026 12:22
Comment on lines +6 to +11
const mockWindow = {
hide: vi.fn(),
show: vi.fn(),
isVisible: vi.fn().mockReturnValue(true),
isDestroyed: vi.fn().mockReturnValue(false),
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid having to create this fake object here, you can create a mock using mockDeep.

This way, you save yourself from having to define functions in the object manually. The only thing you would have to do is manually define the return of the isVisible and isDestroyed functions in beforeEach.

Suggested change
const mockWindow = {
hide: vi.fn(),
show: vi.fn(),
isVisible: vi.fn().mockReturnValue(true),
isDestroyed: vi.fn().mockReturnValue(false),
};
const mockWindow = mockDeep<BrowserWindow>();

Comment on lines +13 to +21
vi.mock('electron', () => ({
dialog: {
showOpenDialog: vi.fn(),
},
BrowserWindow: {
getFocusedWindow: vi.fn(),
getAllWindows: vi.fn(),
},
}));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions can be added to the same object in vitest.setup.main.ts to avoid duplication.

Comment on lines +24 to +26
const mockedDialog = vi.mocked(dialog.showOpenDialog);
const mockedGetFocusedWindow = vi.mocked(BrowserWindow.getFocusedWindow);
const mockedGetAllWindows = vi.mocked(BrowserWindow.getAllWindows);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use partialSpyOn helper intead of vi.mocked

Comment on lines +28 to +31
beforeEach(() => {
mockedGetFocusedWindow.mockReturnValue(mockWindow as unknown as BrowserWindow);
mockedGetAllWindows.mockReturnValue([mockWindow] as unknown as BrowserWindow[]);
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
beforeEach(() => {
mockedGetFocusedWindow.mockReturnValue(mockWindow as unknown as BrowserWindow);
mockedGetAllWindows.mockReturnValue([mockWindow] as unknown as BrowserWindow[]);
});
beforeEach(() => {
mockedGetFocusedWindow.mockReturnValue(mockWindow as unknown as BrowserWindow);
mockedGetAllWindows.mockReturnValue([mockWindow] as unknown as BrowserWindow[]);
mockWindow.isVisible.mockReturnValue(true);
mockWindow.isDestroyed.mockReturnValue(false);
});


await getPathFromDialog();

expect(mockWindow.hide).toHaveBeenCalled();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use toBeCalled instead toHaveBeenCalled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working DO NOT MERGE

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants