test(client): cover digital employee sync retries

This commit is contained in:
baiyanyun
2026-06-07 02:16:04 +08:00
parent bdcb5c6c14
commit f8564b631d
2 changed files with 472 additions and 3 deletions

View File

@@ -183,7 +183,7 @@ export async function flushDigitalEmployeeSyncOutbox(
: [];
recordSyncAttempts(syncedRows, config, "synced", null, startedAt, finishedAt);
if (acked.length > 0) {
markRowsSynced(acked, finishedAt);
markRowsSynced(acked, finishedAt, rows);
} else {
markRowsSynced(
rows.map((row) => ({
@@ -380,7 +380,11 @@ function markRowsSyncing(rows: OutboxRow[], now: string): void {
tx();
}
function markRowsSynced(acks: SyncAck[], now: string): void {
function markRowsSynced(
acks: SyncAck[],
now: string,
sourceRows: OutboxRow[] = [],
): void {
const db = getDb();
if (!db) return;
const tx = db.transaction(() => {
@@ -390,7 +394,10 @@ function markRowsSynced(acks: SyncAck[], now: string): void {
WHERE id = ?
`);
for (const ack of acks) {
const outboxId = ack.outbox_id || ack.id;
const outboxId =
ack.outbox_id ||
ack.id ||
sourceRows.find((row) => ackMatchesRow(ack, row))?.id;
if (!outboxId) continue;
outboxStmt.run(now, outboxId);
updateEntitySyncStatus(ack, now);