[PB-4263] Backup folders popup overlaps file explorer window#239
[PB-4263] Backup folders popup overlaps file explorer window#239AlexisMora merged 4 commits intomainfrom
Conversation
f61c117 to
79ea1f8
Compare
| const mockWindow = { | ||
| hide: vi.fn(), | ||
| show: vi.fn(), | ||
| isVisible: vi.fn().mockReturnValue(true), | ||
| isDestroyed: vi.fn().mockReturnValue(false), | ||
| }; |
There was a problem hiding this comment.
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.
| const mockWindow = { | |
| hide: vi.fn(), | |
| show: vi.fn(), | |
| isVisible: vi.fn().mockReturnValue(true), | |
| isDestroyed: vi.fn().mockReturnValue(false), | |
| }; | |
| const mockWindow = mockDeep<BrowserWindow>(); |
| vi.mock('electron', () => ({ | ||
| dialog: { | ||
| showOpenDialog: vi.fn(), | ||
| }, | ||
| BrowserWindow: { | ||
| getFocusedWindow: vi.fn(), | ||
| getAllWindows: vi.fn(), | ||
| }, | ||
| })); |
There was a problem hiding this comment.
These functions can be added to the same object in vitest.setup.main.ts to avoid duplication.
| const mockedDialog = vi.mocked(dialog.showOpenDialog); | ||
| const mockedGetFocusedWindow = vi.mocked(BrowserWindow.getFocusedWindow); | ||
| const mockedGetAllWindows = vi.mocked(BrowserWindow.getAllWindows); |
There was a problem hiding this comment.
Use partialSpyOn helper intead of vi.mocked
|
|
||
| await getPathFromDialog(); | ||
|
|
||
| expect(mockWindow.hide).toHaveBeenCalled(); |
There was a problem hiding this comment.
Use toBeCalled instead toHaveBeenCalled
|



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