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.
99 lines
3.6 KiB
TypeScript
99 lines
3.6 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { getI18n } from '@d3ro/i18n'
|
|
import { createDialogPrompter } from '../../../src/main/services/update-adapters'
|
|
import { getPopupTranslator } from '../../../src/main/windows/WindowManager'
|
|
|
|
const dialog = vi.hoisted(() => ({ showMessageBox: vi.fn() }))
|
|
|
|
vi.mock('electron', () => ({
|
|
app: { isPackaged: false },
|
|
dialog: { showMessageBox: dialog.showMessageBox },
|
|
}))
|
|
|
|
vi.mock('../../../src/main/windows/WindowManager', () => ({
|
|
getMainWindow: vi.fn(() => null),
|
|
getPopupTranslator: vi.fn(),
|
|
}))
|
|
|
|
describe('업데이트 대화상자 i18n', () => {
|
|
beforeEach(() => {
|
|
dialog.showMessageBox.mockReset()
|
|
vi.mocked(getPopupTranslator).mockReset()
|
|
})
|
|
|
|
it('한국어 일반 다운로드 문구와 버튼 순서를 유지한다', async () => {
|
|
vi.mocked(getPopupTranslator).mockReturnValue(getI18n('ko').t)
|
|
dialog.showMessageBox.mockResolvedValue({ response: 2 })
|
|
|
|
const answer = await createDialogPrompter().askConsent({
|
|
version: '1.16.1',
|
|
releaseNotes: '- 입력 경합 수정',
|
|
mandatory: false,
|
|
})
|
|
|
|
expect(answer).toBe('skip')
|
|
expect(dialog.showMessageBox).toHaveBeenCalledWith({
|
|
type: 'info',
|
|
title: '새 버전 업데이트',
|
|
message:
|
|
'D3RO Voice v1.16.1 새 버전이 출시되었습니다. 지금 다운로드할까요?\n\n[주요 변경사항]\n- 입력 경합 수정',
|
|
buttons: ['지금 다운로드', '나중에', getI18n('ko').t('update.dialog.skipVersion')],
|
|
defaultId: 0,
|
|
cancelId: 1,
|
|
})
|
|
})
|
|
|
|
it('영어 필수 재시작 문구도 같은 계약으로 표시한다', async () => {
|
|
vi.mocked(getPopupTranslator).mockReturnValue(getI18n('en').t)
|
|
dialog.showMessageBox.mockResolvedValue({ response: 0 })
|
|
|
|
const answer = await createDialogPrompter().askRestart('1.16.1', { mandatory: true })
|
|
|
|
expect(answer).toBe('restart')
|
|
expect(dialog.showMessageBox).toHaveBeenCalledWith({
|
|
type: 'warning',
|
|
title: 'Required Update',
|
|
message:
|
|
'Required update D3RO Voice v1.16.1 is ready. The app will restart to install it when you continue.',
|
|
buttons: ['Restart & Install Now'],
|
|
defaultId: 0,
|
|
cancelId: 0,
|
|
})
|
|
})
|
|
|
|
it('같은 prompter도 호출 시점의 앱 로케일을 사용한다', async () => {
|
|
vi.mocked(getPopupTranslator).mockReturnValue(getI18n('ko').t)
|
|
dialog.showMessageBox.mockResolvedValue({ response: 1 })
|
|
const prompter = createDialogPrompter()
|
|
|
|
const consent = await prompter.askConsent({
|
|
version: '1.16.1',
|
|
mandatory: false,
|
|
})
|
|
|
|
vi.mocked(getPopupTranslator).mockReturnValue(getI18n('en').t)
|
|
dialog.showMessageBox.mockResolvedValue({ response: 0 })
|
|
const restart = await prompter.askRestart('1.16.1', { mandatory: true })
|
|
|
|
expect(consent).toBe('later')
|
|
expect(restart).toBe('restart')
|
|
expect(getPopupTranslator).toHaveBeenCalledTimes(2)
|
|
expect(dialog.showMessageBox).toHaveBeenNthCalledWith(1, {
|
|
type: 'info',
|
|
title: '새 버전 업데이트',
|
|
message: 'D3RO Voice v1.16.1 새 버전이 출시되었습니다. 지금 다운로드할까요?',
|
|
buttons: ['지금 다운로드', '나중에', '이 버전 건너뛰기'],
|
|
defaultId: 0,
|
|
cancelId: 1,
|
|
})
|
|
expect(dialog.showMessageBox).toHaveBeenNthCalledWith(2, {
|
|
type: 'warning',
|
|
title: 'Required Update',
|
|
message:
|
|
'Required update D3RO Voice v1.16.1 is ready. The app will restart to install it when you continue.',
|
|
buttons: ['Restart & Install Now'],
|
|
defaultId: 0,
|
|
cancelId: 0,
|
|
})
|
|
})
|
|
})
|