Skip to content

Edge-Drop is a clipboard shelf on the edge of your screen. Hover to open it. Drag files and images into any app, click to copy text and links. Free and open-source for Windows.

feat(tray): Replay Welcome Tour

Deepender2563eac6906d6a
diff --git a/electron/main/tray.ts b/electron/main/tray.ts
index 962667d..8f99ef1 100644
--- a/electron/main/tray.ts
+++ b/electron/main/tray.ts
@@ -14,6 +14,7 @@ import { loadSettings, saveSettings } from '../store/settings'
import { getMainWindow, setVisible, repositionWindow, getDisplayListOptions, registerWindowRepositionListener, popUpAndRetract } from './window'
import type { StickPosition } from '../../shared/types'
import { pushState } from './state'
+import { createOnboardingWindow } from './onboardingWindow'
import { en } from '../../src/i18n/translations'
import { mainT, resolveLang } from './i18n'
@@ -193,6 +194,14 @@ function getTrayText(settingsLang: string | undefined, key: keyof typeof en['tra
pushState.openSettings()
}
},
+ {
+ label: t('tour'),
+ click: () => {
+ console.log('[Main] Context menu "Replay Welcome Tour" clicked')
+ // the same window as the first run, from the start; it saves only what the user changes in it
+ createOnboardingWindow()
+ }
+ },
{ type: 'separator' },
{
label: t('incognito'),
diff --git a/tests/trayTour.test.ts b/tests/trayTour.test.ts
new file mode 100644
index 0000000..5c45c0a
--- /dev/null
+++ b/tests/trayTour.test.ts
@@ -0,0 +1,64 @@
+import { describe, it, expect, vi } from 'vitest'
+
+const mocks = vi.hoisted(() => ({
+ buildFromTemplate: vi.fn().mockReturnValue({}),
+ createOnboardingWindow: vi.fn()
+}))
+
+vi.mock('node:child_process', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('node:child_process')>()),
+ execFileSync: vi.fn().mockReturnValue('')
+}))
+
+vi.mock('electron', () => {
+ const image = { resize: vi.fn().mockReturnThis() }
+ return {
+ app: {
+ getAppPath: vi.fn().mockReturnValue(process.cwd()),
+ getPath: vi.fn().mockReturnValue(process.cwd()),
+ getPreferredSystemLanguages: vi.fn().mockReturnValue(['en-US']),
+ quit: vi.fn()
+ },
+ nativeTheme: { shouldUseDarkColors: true, on: vi.fn() },
+ nativeImage: { createFromPath: vi.fn().mockReturnValue(image), createFromBuffer: vi.fn().mockReturnValue(image) },
+ Tray: class {
+ setImage = vi.fn(); setToolTip = vi.fn(); setContextMenu = vi.fn(); on = vi.fn(); isDestroyed = () => false
+ },
+ Menu: { buildFromTemplate: mocks.buildFromTemplate },
+ Notification: { isSupported: vi.fn().mockReturnValue(false) },
+ screen: { on: vi.fn() }
+ }
+})
+
+vi.mock('../electron/store/settings', () => ({
+ loadSettings: () => ({ language: 'en', stickPosition: 'left', incognito: false, hoverActivation: true }),
+ saveSettings: vi.fn()
+}))
+vi.mock('../electron/main/window', () => ({
+ getMainWindow: vi.fn(), setVisible: vi.fn(), repositionWindow: vi.fn(),
+ getDisplayListOptions: () => [], registerWindowRepositionListener: vi.fn(), popUpAndRetract: vi.fn()
+}))
+vi.mock('../electron/main/state', () => ({ pushState: {} }))
+vi.mock('../electron/main/onboardingWindow', () => ({ createOnboardingWindow: mocks.createOnboardingWindow }))
+
+import { createTray } from '../electron/main/tray'
+import { TRANSLATIONS, en } from '../src/i18n/translations'
+
+describe('tray menu: replay the welcome tour', () => {
+ it('sits right under Settings and opens the onboarding window', () => {
+ createTray()
+ const template = mocks.buildFromTemplate.mock.calls.at(-1)![0] as Electron.MenuItemConstructorOptions[]
+ const labels = template.map((item) => item.label)
+ expect(labels.indexOf('Replay Welcome Tour')).toBe(labels.indexOf('Settings') + 1)
+ const item = template.find((it) => it.label === 'Replay Welcome Tour')!
+ ;(item.click as () => void)()
+ expect(mocks.createOnboardingWindow).toHaveBeenCalledTimes(1)
+ })
+
+ it('is translated in every language', () => {
+ for (const [code, dict] of Object.entries(TRANSLATIONS)) {
+ expect(dict.tray.tour, code).toBeTruthy()
+ if (code !== 'en') expect(dict.tray.tour, code).not.toBe(en.tray.tour)
+ }
+ })
+})