46 lines
1.9 KiB
TypeScript
46 lines
1.9 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
BUG_REPORT_ISSUE_URL,
|
|
buildBugReportUrl,
|
|
formatRuntimeSystem,
|
|
githubBugPlatform,
|
|
} from '../../src/utils/bugReport'
|
|
|
|
describe('bugReport', () => {
|
|
it('maps rust OS names onto the GitHub form dropdown', () => {
|
|
expect(githubBugPlatform('macos')).toBe('macOS')
|
|
expect(githubBugPlatform('windows')).toBe('Windows')
|
|
expect(githubBugPlatform('linux')).toBe('Linux')
|
|
expect(githubBugPlatform('freebsd')).toBeUndefined()
|
|
})
|
|
|
|
it('formats the About system line for people, not rust consts', () => {
|
|
expect(formatRuntimeSystem('macos', 'aarch64')).toBe('macOS · aarch64')
|
|
expect(formatRuntimeSystem('windows', 'x86_64')).toBe('Windows · x86_64')
|
|
})
|
|
|
|
it('pre-fills the issue form the way Settings → About should', () => {
|
|
const url = buildBugReportUrl({
|
|
appVersion: '2.1.1',
|
|
os: 'macos',
|
|
arch: 'aarch64',
|
|
logPath: '/tmp/opsxshell.log',
|
|
userAgent: 'Mozilla/5.0 Test',
|
|
})
|
|
|
|
const parsed = new URL(url)
|
|
expect(`${parsed.origin}${parsed.pathname}`).toBe(BUG_REPORT_ISSUE_URL)
|
|
expect(parsed.searchParams.get('template')).toBe('bug_report.yml')
|
|
expect(parsed.searchParams.get('title')).toBe('[Bug] ')
|
|
expect(parsed.searchParams.get('platform')).toBe('macOS')
|
|
expect(parsed.searchParams.get('version')).toBe('2.1.1')
|
|
expect(parsed.searchParams.get('install_source')).toBeNull()
|
|
expect(parsed.searchParams.get('logs')).toContain('Reported from OpsXShell Settings (opsxshell 2.1.1).')
|
|
expect(parsed.searchParams.get('logs')).toContain('OS: macos aarch64')
|
|
expect(parsed.searchParams.get('logs')).toContain('Log file: /tmp/opsxshell.log')
|
|
expect(parsed.searchParams.get('logs')).not.toContain('Tauri')
|
|
expect(parsed.searchParams.get('logs')).not.toContain('libssh2')
|
|
expect(parsed.searchParams.get('logs')).not.toContain('password')
|
|
})
|
|
})
|