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,64 @@
|
||||
/**
|
||||
* admin-store-reconnect unit tests (node:test).
|
||||
*
|
||||
* Run from apps/web:
|
||||
* node --experimental-strip-types --test src/lib/admin-store-reconnect.test.ts
|
||||
*/
|
||||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
|
||||
import {
|
||||
normalizeStoreReconnectInventory,
|
||||
storeReconnectChannelLabelKey,
|
||||
storeReconnectReasonLabelKey
|
||||
} from "./admin-store-reconnect.ts";
|
||||
|
||||
describe("normalizeStoreReconnectInventory", () => {
|
||||
it("returns empty inventory for nullish payloads", () => {
|
||||
assert.deepEqual(normalizeStoreReconnectInventory(null), {
|
||||
stores: [],
|
||||
total: 0,
|
||||
limit: 0,
|
||||
offset: 0
|
||||
});
|
||||
});
|
||||
|
||||
it("normalizes gap rows", () => {
|
||||
const inv = normalizeStoreReconnectInventory({
|
||||
total: 1,
|
||||
limit: 50,
|
||||
offset: 0,
|
||||
stores: [
|
||||
{
|
||||
company_id: "abc",
|
||||
company_name: "Acme",
|
||||
channel: "shopify",
|
||||
identity: "acme.myshopify.com",
|
||||
is_enabled: true,
|
||||
reason: "missing_credentials",
|
||||
last_test_status: ""
|
||||
}
|
||||
]
|
||||
});
|
||||
assert.equal(inv.total, 1);
|
||||
assert.equal(inv.stores.length, 1);
|
||||
assert.equal(inv.stores[0]?.channel, "shopify");
|
||||
assert.equal(inv.stores[0]?.reason, "missing_credentials");
|
||||
assert.equal(inv.stores[0]?.last_test_status, undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe("storeReconnect label keys", () => {
|
||||
it("maps known reasons and channels", () => {
|
||||
assert.equal(
|
||||
storeReconnectReasonLabelKey("missing_credentials"),
|
||||
"admin.storeReconnect.reason.missingCredentials"
|
||||
);
|
||||
assert.equal(storeReconnectReasonLabelKey("weird"), "admin.storeReconnect.reason.other");
|
||||
assert.equal(
|
||||
storeReconnectChannelLabelKey("woocommerce"),
|
||||
"admin.storeReconnect.channel.woocommerce"
|
||||
);
|
||||
assert.equal(storeReconnectChannelLabelKey("x"), "admin.storeReconnect.channel.other");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user