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,62 @@
|
||||
/**
|
||||
* woocommerce-admin-urls unit tests (node:test).
|
||||
* Pure URL builders for Woo REST API keys deep links (no network).
|
||||
*
|
||||
* Run from apps/web:
|
||||
* node --experimental-strip-types --test src/lib/woocommerce-admin-urls.test.ts
|
||||
*/
|
||||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
|
||||
import {
|
||||
WOO_REST_API_DOCS_URL,
|
||||
wooAdminRestApiKeysUrl
|
||||
} from "./woocommerce-admin-urls.ts";
|
||||
|
||||
describe("wooAdminRestApiKeysUrl", () => {
|
||||
it("returns null for empty or invalid input", () => {
|
||||
assert.equal(wooAdminRestApiKeysUrl(""), null);
|
||||
assert.equal(wooAdminRestApiKeysUrl(" "), null);
|
||||
assert.equal(wooAdminRestApiKeysUrl("not a url"), null);
|
||||
assert.equal(wooAdminRestApiKeysUrl("ftp://store.example"), null);
|
||||
});
|
||||
|
||||
it("builds keys list URL from https store URL", () => {
|
||||
assert.equal(
|
||||
wooAdminRestApiKeysUrl("https://shop.example/"),
|
||||
"https://shop.example/wp-admin/admin.php?page=wc-settings&tab=advanced§ion=keys"
|
||||
);
|
||||
});
|
||||
|
||||
it("strips path and query from store URL", () => {
|
||||
assert.equal(
|
||||
wooAdminRestApiKeysUrl("https://shop.example/product/foo?x=1"),
|
||||
"https://shop.example/wp-admin/admin.php?page=wc-settings&tab=advanced§ion=keys"
|
||||
);
|
||||
});
|
||||
|
||||
it("adds create-key when requested", () => {
|
||||
assert.equal(
|
||||
wooAdminRestApiKeysUrl("https://shop.example", { create: true }),
|
||||
"https://shop.example/wp-admin/admin.php?page=wc-settings&tab=advanced§ion=keys&create-key=1"
|
||||
);
|
||||
});
|
||||
|
||||
it("assumes https when scheme is omitted", () => {
|
||||
assert.equal(
|
||||
wooAdminRestApiKeysUrl("shop.example"),
|
||||
"https://shop.example/wp-admin/admin.php?page=wc-settings&tab=advanced§ion=keys"
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves http for local stores", () => {
|
||||
assert.equal(
|
||||
wooAdminRestApiKeysUrl("http://localhost:8080"),
|
||||
"http://localhost:8080/wp-admin/admin.php?page=wc-settings&tab=advanced§ion=keys"
|
||||
);
|
||||
});
|
||||
|
||||
it("exposes static docs URL", () => {
|
||||
assert.match(WOO_REST_API_DOCS_URL, /^https:\/\/woocommerce\.com\//);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user