سامانه صدور فاکتور و حسابداری
test: verify atomic autopost migration and rollback contract
davoodmehraban89 committed
Nov 17, 2026 at 14:20 UTC
5c1f67878c9ab9d6c51c654aeb056255d52da8c7
1 file changed
+14
scripts/journal-rpc-adapter.test.mjs
+14
@@ -306,3 +306,17 @@ test('source edit and delete surfaces freeze while autopost outcome is ambiguous
306
assert.match(invoices,/inv\.accountingPostingPending\)/);
307
assert.match(purchases,/p\.accountingPostingPending/);
308
});
309
+
310
+
311
+test('autopost database migration atomically links source records and has a restoring rollback',async()=>{
312
+ const migration=await readFile(new URL('../supabase/migrations/20261117110000_wp1_autopost_source_link_atomic.sql',import.meta.url),'utf8');
313
+ const rollback=await readFile(new URL('../supabase/rollback/20261117110000_wp1_autopost_source_link_atomic.sql',import.meta.url),'utf8');
314
+ assert.match(migration,/FOR UPDATE/);
315
+ assert.match(migration,/journalVoucherId/);
316
+ assert.match(migration,/accountingStatus/);
317
+ assert.match(migration,/documentStatus/);
318
+ assert.match(migration,/prior\.id/);
319
+ assert.match(migration,/posted#>>'\{voucher,postedAt\}'/);
320
+ assert.match(rollback,/CREATE OR REPLACE FUNCTION public\.finora_journal_autopost/);
321
+ assert.doesNotMatch(rollback,/UPDATE public\.records r SET data=/);
322
+});