diff --git a/test/analyse.test.js b/test/analyse.test.js index f6d4578..c3dad35 100644 --- a/test/analyse.test.js +++ b/test/analyse.test.js @@ -356,7 +356,8 @@ test('Kunde ohne actor-Namen oder Mitarbeiter ohne Textform: 400', async () => { test('Historie: Kunde, Aus, An durch Mitarbeiter in zeitlicher Folge; Portal-Dokument gleich', async () => { aw.seed('websiteProjects', { $id: 'p14', customerId: 'c1', projectName: 'Historie', subdomain: 'historie', isPublic: true }) - const { doc: d1 } = await an.activateAnalyse({ customerId: 'c1', projectId: 'p14', ...cust() }) + // feste Zeiten vor NOW: mit der echten Uhr kippt die Reihenfolge, sobald die Uhr NOW überholt + const { doc: d1 } = await an.activateAnalyse({ customerId: 'c1', projectId: 'p14', ...cust({ now: new Date(NOW.getTime() - 60_000) }) }) let h = await consents('p14') assert.equal(h.length, 1) assert.equal(h[0].event, 'on') @@ -375,8 +376,8 @@ test('Historie: Kunde, Aus, An durch Mitarbeiter in zeitlicher Folge; Portal-Dok assert.equal(d1.avvConsentDate, '') assert.equal(d1.avvConsentChannel, '') // Farbwechsel und erneutes Aktivieren: keine neue Zeile - await an.activateAnalyse({ customerId: 'c1', projectId: 'p14', accentColor: '#222222', ...cust() }) - await an.activateAnalyse({ customerId: 'c1', projectId: 'p14', ...cust() }) + await an.activateAnalyse({ customerId: 'c1', projectId: 'p14', accentColor: '#222222', ...cust({ now: new Date(NOW.getTime() - 50_000) }) }) + await an.activateAnalyse({ customerId: 'c1', projectId: 'p14', ...cust({ now: new Date(NOW.getTime() - 40_000) }) }) assert.equal((await consents('p14')).length, 1) // Marker zurücksetzen beim Wiedereinschalten await updateDocument(config.collections.portalFeatures, d1.$id, { removalTicketId: 'r1', publishTicketId: 'u1' }) @@ -418,14 +419,15 @@ test('recordConsent scheitert: putSite wird zurückgenommen, Dokument bleibt aus test('Ausschalten schreibt off-Historie; Fehler dort verhindert das Ausschalten nicht', async () => { aw.seed('websiteProjects', { $id: 'p16', customerId: 'c1', projectName: 'Aus', subdomain: 'aus', isPublic: true }) - await an.activateAnalyse({ customerId: 'c1', projectId: 'p16', ...cust() }) + // feste Zeiten vor NOW (siehe Historie-Test) + await an.activateAnalyse({ customerId: 'c1', projectId: 'p16', ...cust({ now: new Date(NOW.getTime() - 120_000) }) }) const prev = an.analyseDeps.recordConsent an.analyseDeps.recordConsent = async () => { throw new Error('Historie weg') } const r = await an.deactivateAnalyse({ customerId: 'c1', projectId: 'p16', now: NOW, actor }) an.analyseDeps.recordConsent = prev assert.equal(r.doc.state, 'off') assert.deepEqual((await consents('p16')).map((x) => x.event), ['on']) - await an.activateAnalyse({ customerId: 'c1', projectId: 'p16', ...cust() }) + await an.activateAnalyse({ customerId: 'c1', projectId: 'p16', ...cust({ now: new Date(NOW.getTime() - 60_000) }) }) await an.deactivateAnalyse({ customerId: 'c1', projectId: 'p16', now: NOW, actor }) assert.deepEqual((await consents('p16')).map((x) => x.event), ['on', 'on', 'off']) })