-
Notifications
You must be signed in to change notification settings - Fork 4
[PB-4263] Backup folders popup overlaps file explorer window #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
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.
| 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.
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.
| 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.
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
| beforeEach(() => { | ||
| mockedGetFocusedWindow.mockReturnValue(mockWindow as unknown as BrowserWindow); | ||
| mockedGetAllWindows.mockReturnValue([mockWindow] as unknown as BrowserWindow[]); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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