Tickets: ticketPath, Listenzustand in der URL (Reiter, Art, Dringend, Suche, limit), woid-Umleitung, Zeilenklick-Helfer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-06 06:02:54 +00:00
1 parent f3b73ca1dd
commit 54fc44ed11
7 files changed
+249 -1

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { loadModule } from './load.mjs'
const { ticketPath, ticketRef, resolveTicketTab, listBackPath } = await loadModule('src/lib/ticketRoutes.js')
test('ticketPath: woid, Zahl, $id, Reiter', () => {
assert.equal(ticketPath('100131'), '/tickets/100131')
assert.equal(ticketPath(100131), '/tickets/100131')
assert.equal(ticketPath('100131', 'details'), '/tickets/100131')
assert.equal(ticketPath('100131', 'arbeitsblaetter'), '/tickets/100131/arbeitsblaetter')
assert.equal(ticketPath('100131', 'unbekannt'), '/tickets/100131')
assert.equal(ticketPath('66f1c2a9000b1c2d3e4f'), '/tickets/66f1c2a9000b1c2d3e4f')
})
test('ticketPath: Sonderzeichen kodiert, leeres ref ergibt /tickets', () => {
assert.equal(ticketPath('a/b c?d#e'), '/tickets/a%2Fb%20c%3Fd%23e')
for (const empty of ['', ' ', null, undefined]) {
assert.equal(ticketPath(empty), '/tickets')
assert.equal(ticketPath(empty, 'arbeitsblaetter'), '/tickets')
}
})
test('ticketRef: woid vor $id, nie die Kurznummer', () => {
assert.equal(ticketRef({ woid: '100131', $id: 'abc' }), '100131')
assert.equal(ticketRef({ woid: '', $id: 'abcdefghij' }), 'abcdefghij')
assert.equal(ticketRef(null), '')
})
test('resolveTicketTab: unbekannt ergibt null', () => {
assert.equal(resolveTicketTab(undefined), 'details')
assert.equal(resolveTicketTab('arbeitsblaetter'), 'arbeitsblaetter')
for (const bad of ['Details', 'worksheets', '', 'x']) assert.equal(resolveTicketTab(bad), null)
})
test('listBackPath: nur Suchteile mit ?', () => {
assert.equal(listBackPath({ listSearch: '?status=done&q=x' }), '/tickets?status=done&q=x')
for (const bad of [undefined, null, {}, { listSearch: '' }, { listSearch: '?' }, { listSearch: 'evil' }, { listSearch: 42 }]) assert.equal(listBackPath(bad), '/tickets')
})