Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config/nativephp.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use App\Providers\NativeAppServiceProvider;

return [
/**
* The version of your app.
Expand Down Expand Up @@ -51,7 +53,7 @@
* takes care of bootstrapping your application and configuring
* any global hotkeys, menus, windows, etc.
*/
'provider' => \App\Providers\NativeAppServiceProvider::class,
'provider' => NativeAppServiceProvider::class,

/**
* A list of environment keys that should be removed from the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const { playMock } = vi.hoisted(() => ({ playMock: vi.fn() }));
// that records its event handlers and lets the test fire them, mimicking the
// OS raising a click/close on the notification.
vi.mock('electron', () => ({
Notification: vi.fn().mockImplementation(() => {
// Vitest 4 constructs mock implementations with `new`, so the factory must
// be a regular function. An arrow function throws "is not a constructor"
Notification: vi.fn().mockImplementation(function () {
const handlers: Record<string, (...args: any[]) => void> = {};
return {
show: vi.fn(),
Expand Down
45 changes: 23 additions & 22 deletions resources/electron/electron-plugin/tests/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mockForNodeRequire('electron', () => ({
writeImage: vi.fn(),
readImage: vi.fn(),
},
BrowserWindow: vi.fn().mockImplementation(() => ({
BrowserWindow: vi.fn().mockImplementation(function () { return ({
loadURL: vi.fn(),
loadFile: vi.fn(),
on: vi.fn(),
Expand All @@ -52,7 +52,7 @@ mockForNodeRequire('electron', () => ({
isMaximized: vi.fn(),
isMinimized: vi.fn(),
setProgressBar: vi.fn(),
})),
}); }),
ipcMain: {
on: vi.fn(),
handle: vi.fn(),
Expand Down Expand Up @@ -89,10 +89,10 @@ mockForNodeRequire('electron', () => ({
isRegistered: vi.fn(),
unregisterAll: vi.fn(),
},
Notification: vi.fn().mockImplementation(() => ({
Notification: vi.fn().mockImplementation(function () { return ({
show: vi.fn(),
on: vi.fn(),
})),
}); }),
Menu: {
buildFromTemplate: vi.fn().mockReturnValue({
popup: vi.fn(),
Expand All @@ -104,13 +104,13 @@ mockForNodeRequire('electron', () => ({
setApplicationMenu: vi.fn(),
getApplicationMenu: vi.fn(),
},
Tray: vi.fn().mockImplementation(() => ({
Tray: vi.fn().mockImplementation(function () { return ({
setContextMenu: vi.fn(),
on: vi.fn(),
setImage: vi.fn(),
setToolTip: vi.fn(),
destroy: vi.fn(),
})),
}); }),
MenuItem: vi.fn(),
shell: {
openExternal: vi.fn().mockResolvedValue(true),
Expand Down Expand Up @@ -167,23 +167,24 @@ vi.mock('@electron/remote', () => ({
},
}));

// Mock electron-store with onDidAnyChange method
// Mock electron-store with onDidAnyChange method.
// Vitest 4 resolves a `vi.fn()` default export to its raw implementation when
// constructed with `new`, so an arrow factory throws "is not a constructor".
// A real class is unambiguously constructable across the ESM interop.
vi.mock('electron-store', () => {
return {
default: vi.fn().mockImplementation(() => ({
get: vi.fn(),
set: vi.fn(),
has: vi.fn(),
delete: vi.fn(),
clear: vi.fn(),
onDidAnyChange: vi.fn().mockImplementation(() => {
// Return an unsubscribe function
return () => {};
}),
store: {},
path: '/fake/path/to/store.json',
})),
};
class Store {
get = vi.fn();
set = vi.fn();
has = vi.fn();
delete = vi.fn();
clear = vi.fn();
// Return an unsubscribe function
onDidAnyChange = vi.fn(() => () => {});
store = {};
path = '/fake/path/to/store.json';
}

return { default: Store };
});

// Create empty router mocks for all API routes
Expand Down
Loading