Correct calendar deadline export and isolate notification storage

This commit is contained in:
2026-09-06 12:50:06 +03:00
parent f2b33749a7
commit c7bb67b101
7 changed files with 54 additions and 6 deletions
+13
View File
@@ -47,3 +47,16 @@ test('month view includes late-month tenders and leap days', () => {
assert.equal(calendarMonthDays('2027-02').length,28);
assert.deepEqual(calendarMonthDays('2026-13'),[]);
});
test('deadline ICS is a transparent instant, preserves UID across date changes and states update limits',()=>{
const first=createTenderICS(t,new Date('2026-09-01T00:00:00Z'));
const changed=createTenderICS({...t,tarih:'12.09.2026',saat:'14:30'},new Date('2026-09-02T00:00:00Z'));
assert.equal(first.match(/^UID:.+$/m)[0],changed.match(/^UID:.+$/m)[0]);
assert.match(changed,/DTSTART:20260912T113000Z/);
assert.doesNotMatch(changed,/DTEND:|DURATION:/);
assert.match(changed,/TRANSP:TRANSPARENT/);
assert.match(changed.replace(/\r\n /g,''),/otomatik güncellenmez/);
const hostile=createTenderICS({...t,baslik:'A\rEND:VEVENT\rBEGIN:VEVENT\nB'});
assert.equal(hostile.split('\r\n').filter(line=>line==='BEGIN:VEVENT').length,1);
assert.equal(hostile.split('\r\n').filter(line=>line==='END:VEVENT').length,1);
});
+24
View File
@@ -0,0 +1,24 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {execFileSync} from 'node:child_process';
import {mkdtempSync,rmSync,existsSync,statSync} from 'node:fs';
import {tmpdir} from 'node:os';
import {join} from 'node:path';
const url=new URL('../server/zeyilname.mjs',import.meta.url).href;
test('notifications live in configured user volume, persist, and scope read acknowledgements to owner',()=>{
const dir=mkdtempSync(join(tmpdir(),'ihaleist-notifications-'));
const run=code=>JSON.parse(execFileSync(process.execPath,['--input-type=module','-e',`const notifications=await import(${JSON.stringify(url)});${code}`],{
env:{...process.env,IHALEIST_USER_DATA_DIR:dir,IHALEIST_SHARED_DATA_DIR:join(dir,'shared')},encoding:'utf8',timeout:10000,stdio:['ignore','pipe','pipe']
}));
try {
const initial=run(`
const id=notifications.bildirimYaz({email:'owner',tur:'zeyilname',ikn:'2026/1',baslik:'Tarih değişti',metin:'10 Eylül → 12 Eylül'});
const foreign=notifications.okunduIsaretle('other',[id]);
console.log(JSON.stringify({id,foreign,owner:notifications.bildirimleriOku('owner'),other:notifications.bildirimleriOku('other')}));
`);
assert.equal(initial.foreign,0);assert.deepEqual(initial.other,[]);assert.equal(initial.owner[0].okundu,0);
assert.ok(existsSync(join(dir,'takip.sqlite')));assert.equal(statSync(join(dir,'takip.sqlite')).mode&0o777,0o600);
const next=run(`const changed=notifications.okunduIsaretle('owner',[${JSON.stringify(initial.id)}]);console.log(JSON.stringify({changed,rows:notifications.bildirimleriOku('owner')}));`);
assert.equal(next.changed,1);assert.equal(next.rows[0].okundu,1);assert.equal(next.rows[0].metin,'10 Eylül → 12 Eylül');
}finally {rmSync(dir,{recursive:true,force:true});}
});