chore: land in-progress workspace changes before 1.16.2
The tree carried uncommitted work from several areas (web push, mobile screens, admin charts, test-hygiene cleanup, CI and map docs). It is landed as one commit so the release pipeline can start from a clean tree; the desktop transcript-correction behaviour shipped in the previous commit and is unchanged here.
This commit is contained in:
parent
9c2b6a9782
commit
7fe49c437e
144 changed files with 3760 additions and 4523 deletions
50
apps/desktop/tests/unit/license-open-billing.test.ts
Normal file
50
apps/desktop/tests/unit/license-open-billing.test.ts
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { app, ipcMain, shell } from 'electron'
|
||||
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
|
||||
|
||||
vi.mock('../../src/main/services/LicenseService', () => ({
|
||||
getLicenseService: () => ({ on: vi.fn() })
|
||||
}))
|
||||
|
||||
import { registerLicenseHandlers } from '../../src/main/ipc/license-handlers'
|
||||
|
||||
type CapturedHandler = (...args: unknown[]) => unknown
|
||||
|
||||
const handlers = new Map<string, CapturedHandler>()
|
||||
|
||||
async function openBilling(tier: 'pro' | 'pro_plus'): Promise<unknown> {
|
||||
const handler = handlers.get(IPC_CHANNELS.LICENSE.OPEN_BILLING)
|
||||
if (!handler) throw new Error('Missing OPEN_BILLING handler')
|
||||
return handler({}, { tier })
|
||||
}
|
||||
|
||||
function setPackaged(value: boolean): void {
|
||||
Object.defineProperty(app, 'isPackaged', { value, configurable: true, writable: true })
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
handlers.clear()
|
||||
vi.mocked(ipcMain.handle).mockImplementation((channel: string, handler: CapturedHandler) => {
|
||||
handlers.set(channel, handler)
|
||||
})
|
||||
registerLicenseHandlers()
|
||||
})
|
||||
|
||||
describe('LICENSE.OPEN_BILLING', () => {
|
||||
it('opens the single web billing entry with the chosen tier in packaged builds', async () => {
|
||||
setPackaged(true)
|
||||
try {
|
||||
await expect(openBilling('pro_plus')).resolves.toEqual({ success: true, data: undefined })
|
||||
expect(shell.openExternal).toHaveBeenCalledWith('https://d3ro.chanpaca.net/app/billing?tier=pro_plus')
|
||||
} finally {
|
||||
setPackaged(false)
|
||||
}
|
||||
})
|
||||
|
||||
it('opens the local web app under the same base path in development', async () => {
|
||||
setPackaged(false)
|
||||
await openBilling('pro')
|
||||
expect(shell.openExternal).toHaveBeenCalledWith('http://localhost:3000/app/billing?tier=pro')
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue