bmc_hub/tests/js/case-command-suggestions.test.cjs
Christian 4871dd2d9e Add comprehensive test coverage for various modules
- Introduced tests for mail templates including ranking, rendering, and attachment handling.
- Added tests for time billing selection and approval processes, ensuring proper validation and state management.
- Implemented tests for case types in JavaScript, focusing on loading and editing functionality.
- Created tests for contact mail AI integration, ensuring proper parsing and error handling.
- Developed tests for dark theme CSS contrast and loading order.
- Added tests for invoice fee service, covering various scenarios including exemptions and invalid inputs.
- Implemented vendor resource tests, ensuring proper file handling and query validation.
2026-10-08 08:58:02 +02:00

8 lines
1.4 KiB
JavaScript

const test=require('node:test');const assert=require('node:assert/strict');const {suggest}=require('../../static/js/case-command-suggestions.js');
const users=[{user_id:3,username:'ct',full_name:'Christian Thomas'}];
test('command choice continues with values rather than a full canned example',()=>{const rows=suggest('/ti',3);assert.equal(rows.find(r=>r.label==='/tid').value,'/tid ');assert.ok(suggest('/tid ',5).some(r=>r.value==='30m '));});
test('completion follows time category and description',()=>{assert.ok(suggest('/tid 30m re',11).some(r=>r.value==='research '));assert.ok(suggest('/tid 30m research ',18).some(r=>r.value==='"Beskrivelse" '));});
test('employee completion filters initials and uses an unambiguous identifier',()=>{const row=suggest('/tildel ct',10,{users})[0];assert.equal(row.label,'Christian Thomas');assert.equal(row.value,'3 ');});
test('replacement preserves existing explanation and handles mid-command caret',()=>{let line='/tildel ct "Bestil varer"';const row=suggest(line,10,{users})[0];assert.equal(line.slice(0,row.from)+row.value+line.slice(row.to),'/tildel 3 "Bestil varer"');const command=suggest('/tildel',3)[0];assert.equal(command.to,7);});
test('subcase groups, dates and todo employee choices',()=>{assert.equal(suggest('//gruppe Sup',12,{groups:[{name:'Support'}]})[0].value,'"Support" ');assert.equal(suggest('/udsat i m',10)[0].value,'i morgen');assert.equal(suggest('/todo "Bestil" @ct',18,{users})[0].value,'@3 ');});