Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* store-sync-poll unit tests (node:test).
|
||||
*
|
||||
* Run from apps/web:
|
||||
* node --experimental-strip-types --test src/lib/store-sync-poll.test.ts
|
||||
*/
|
||||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
|
||||
import {
|
||||
isRetryableStoreSyncStatus,
|
||||
readStoreSyncSnapshot,
|
||||
storeSyncPhase
|
||||
} from "./store-sync-poll.ts";
|
||||
|
||||
describe("store-sync-poll", () => {
|
||||
it("reads product snapshot fields", () => {
|
||||
const snap = readStoreSyncSnapshot(
|
||||
{
|
||||
pending_sync: true,
|
||||
last_synced_at: "2026-01-01T00:00:00Z",
|
||||
last_sync_status: "success",
|
||||
last_sync_error: "",
|
||||
last_sync_summary: { total: 3, created: 1, updated: 2, failed: 0, skipped: 0 }
|
||||
},
|
||||
"products"
|
||||
);
|
||||
assert.equal(snap.pending, true);
|
||||
assert.equal(snap.summary?.total, 3);
|
||||
});
|
||||
|
||||
it("maps pending to queued, claimed to running, advanced synced_at to completed", () => {
|
||||
assert.equal(
|
||||
storeSyncPhase(
|
||||
{ pending: true, syncedAt: "a", status: "", error: "", summary: null },
|
||||
"a"
|
||||
),
|
||||
"queued"
|
||||
);
|
||||
assert.equal(
|
||||
storeSyncPhase(
|
||||
{ pending: false, syncedAt: "a", status: "", error: "", summary: null },
|
||||
"a"
|
||||
),
|
||||
"running"
|
||||
);
|
||||
assert.equal(
|
||||
storeSyncPhase(
|
||||
{ pending: false, syncedAt: "b", status: "success", error: "", summary: null },
|
||||
"a"
|
||||
),
|
||||
"completed"
|
||||
);
|
||||
});
|
||||
|
||||
it("marks failed and partial as retryable", () => {
|
||||
assert.equal(isRetryableStoreSyncStatus("failed"), true);
|
||||
assert.equal(isRetryableStoreSyncStatus("partial"), true);
|
||||
assert.equal(isRetryableStoreSyncStatus("success"), false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user