Rechtliches: Fristen ohne Monatsende-Drift, Indizes und Warten auf Attribute im Setup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c8c1d84794
commit
c24b3d43c8
4 files changed
+65
-5
No files matched your search
@@ -136,3 +136,12 @@ test('Abloesung am selben Tag: validTo nie vor validFrom', () => {
|
||||
const r = planNewVersion([v5], { documentKey: 'agb', version: 'v6', status: 'current', validFrom: '2026-05-01' })
|
||||
assert.deepEqual(r.updates, [{ id: 'v5', patch: { status: 'superseded', validTo: '2026-05-01' } }])
|
||||
})
|
||||
|
||||
test('Verlaengerungen ab dem 31. driften nicht auf den 28.', () => {
|
||||
const r = nextCancellationDate(
|
||||
{ startDate: '2025-01-31', termMonths: 1, renewalMonths: 1, noticeValue: 1, noticeUnit: 'days' },
|
||||
'2025-04-05'
|
||||
)
|
||||
assert.equal(r.periodEnd, '2025-04-30')
|
||||
assert.equal(r.noticeBy, '2025-04-29')
|
||||
})
|
||||
@@ -0,0 +1,30 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { COLLECTIONS, waitForAttributes } from '../scripts/setup-legal.mjs'
|
||||
|
||||
const indexOn = (id, attr) =>
|
||||
COLLECTIONS.find((c) => c.id === id).indexes?.some((i) => i.attributes.includes(attr))
|
||||
|
||||
test('Indizes fuer alle Abfragen (equal/orderAsc)', () => {
|
||||
assert.ok(indexOn('legalVersions', 'documentKey'))
|
||||
assert.ok(indexOn('legalVersions', 'source'))
|
||||
assert.ok(indexOn('legalDocuments', 'sort'))
|
||||
assert.ok(indexOn('providerContracts', 'provider'))
|
||||
})
|
||||
|
||||
test('waitForAttributes wartet, bis alle Attribute verfuegbar sind', async () => {
|
||||
let calls = 0
|
||||
const db = {
|
||||
listAttributes: async () => {
|
||||
calls++
|
||||
return { attributes: [{ key: 'a', status: 'available' }, { key: 'b', status: calls < 3 ? 'processing' : 'available' }] }
|
||||
},
|
||||
}
|
||||
await waitForAttributes(db, 'x', { intervalMs: 1, timeoutMs: 1000 })
|
||||
assert.equal(calls, 3)
|
||||
})
|
||||
|
||||
test('waitForAttributes bricht bei fehlgeschlagenem Attribut ab', async () => {
|
||||
const db = { listAttributes: async () => ({ attributes: [{ key: 'b', status: 'failed', error: 'kaputt' }] }) }
|
||||
await assert.rejects(waitForAttributes(db, 'x', { intervalMs: 1, timeoutMs: 1000 }), /b/)
|
||||
})
|
||||
Reference in new issue
Block a user