]*id="home-key-trigger"[^>]*data-analytics-event="demo_key_click"[^>]*>/);
+ const page = analyticsPage(true);
+ page.click("demo_key_click");
+ assert.deepEqual(page.sent, [["event", { name: "demo_key_click" }]]);
+});
+
+test("analytics stays silent without opt in and rejects unknown event names", () => {
+ const disabled = analyticsPage(false);
+ disabled.click("demo_key_click");
+ assert.deepEqual(disabled.sent, []);
+
+ const enabled = analyticsPage(true);
+ enabled.click("receipt_verified");
+ enabled.click("");
+ assert.deepEqual(enabled.sent, []);
+});
diff --git a/site/test_home_contrast.mjs b/site/test_home_contrast.mjs
index 98764b0b..605b4679 100644
--- a/site/test_home_contrast.mjs
+++ b/site/test_home_contrast.mjs
@@ -56,13 +56,14 @@ test("homepage surfaces and controls use the contrast aware palette", () => {
["body.home-light .hero-v2-action-primary,\nbody.home-light #main .hero-v2-action-primary", "color", "var(--home-primary-text)"],
["body.home-light .hero-v2-code", "background", "var(--home-soft)"],
["body.home-light .hero-v2-command-row button", "border", "1px solid var(--home-line)"],
+ ["body.home-light .hero-v2-tab-disabled span", "border", "1px solid #6b7280"],
["body.home-light .hero-v2-step", "background", "var(--home-bg)"],
["body.home-light .hero-v2-intro > p", "color", "var(--home-muted)"],
+ ["body.home-light .hero-v2-intro > .hero-v2-boundary", "font-size", "0.875rem"],
["body.home-light .home-key-drawer", "background", "var(--home-bg)"],
["body.home-light .home-key-field-row", "border", "1px solid var(--home-line)"],
["body.home-light .home-key-field-row button", "color", "var(--home-muted)"],
["body.home-light .home-v2-glossary", "background", "var(--home-soft)"],
- ["body.home-light .home-code-toolbar button", "background", "var(--home-bg)"],
]) {
assert.equal(rule(selector)[property], value, `${selector} ${property}`);
}
diff --git a/site/test_home_key.mjs b/site/test_home_key.mjs
index db68d65a..3fcf400a 100644
--- a/site/test_home_key.mjs
+++ b/site/test_home_key.mjs
@@ -9,14 +9,6 @@ const homeHtml = readFileSync(new URL("./index.html", import.meta.url), "utf8");
const heroCode = homeHtml.match(/]*>([\s\S]*?)<\/code><\/pre>/);
assert.ok(heroCode, "hero Python command block must exist");
const heroTemplate = heroCode[1].replaceAll("&", "&");
-const template = `git clone https://github.com/agentmiddleware/amw-demo.git
-cd amw-demo
-python3 -m venv .venv
-source .venv/bin/activate
-pip install -e .
-export AMW_API_KEY='YOUR_DEMO_KEY'
-export AMW_WALLET_ID='YOUR_WALLET_ID'
-python examples/permit_echo_retry.py`;
function makePage(fetchResponse, { copyFails = false, capture = true, search = "", referrer = "", session: stored = {} } = {}) {
const ids = [
@@ -24,19 +16,15 @@ function makePage(fetchResponse, { copyFails = false, capture = true, search = "
"home-key-title", "home-key-result", "home-key-error", "home-key-error-message",
"home-key-value", "home-wallet-value", "home-key-reveal", "home-wallet-reveal",
"home-key-copy", "home-wallet-copy", "home-key-copy-both", "home-key-budget",
- "home-key-retry", "home-key-email", "home-quickstart-code",
- "home-copy-quickstart", "home-copy-status",
- "home-hero-python-copy", "home-hero-curl-copy", "home-hero-python",
- "home-hero-curl", "home-hero-copy-status",
+ "home-key-retry", "home-key-email", "home-hero-python-copy",
+ "home-hero-python", "home-hero-copy-status",
];
const elements = new Map(ids.map((id) => [id, {
id,
hidden: ["home-key-trigger", "home-key-panel", "home-key-result", "home-key-error",
"home-key-retry", "home-key-email"].includes(id),
- disabled: id === "home-copy-quickstart" || id === "home-hero-python-copy",
- textContent: id === "home-quickstart-code" ? template :
- id === "home-hero-python" ? heroTemplate :
- id === "home-hero-curl" ? "curl -s -X POST https://api.thisisatest.tech/v1/demo/keys" :
+ disabled: id === "home-hero-python-copy",
+ textContent: id === "home-hero-python" ? heroTemplate :
id === "home-key-trigger" ? "Get a free demo key" : "",
value: "",
type: id === "home-key-value" || id === "home-wallet-value" ? "password" : "button",
@@ -50,7 +38,6 @@ function makePage(fetchResponse, { copyFails = false, capture = true, search = "
select() { this.selectCount += 1; },
set innerHTML(_) { throw new Error("API data must not be inserted as HTML"); },
}]));
- elements.get("home-quickstart-code").select = undefined;
const requests = [];
const copies = [];
const session = new Map(Object.entries(stored));
@@ -111,13 +98,13 @@ function issuedResponse(apiKey = "b2a_" + "test", walletId = "agt-test", credits
test("hero Python copy requires an issued demo key and wallet", async () => {
assert.match(heroTemplate, /export AMW_API_KEY='YOUR_DEMO_KEY'\nexport AMW_WALLET_ID='YOUR_WALLET_ID'\npython examples\/permit_echo_retry\.py$/);
assert.match(homeHtml, /id="home-hero-python-copy"[^>]*disabled/);
+ assert.equal(homeHtml.match(/git clone https:\/\/github.com\/agentmiddleware\/amw-demo\.git/g)?.length, 1);
+ assert.match(homeHtml, /hero-v2-tab-disabled">curl<\/code>coming soon<\/span>/);
+ assert.doesNotMatch(homeHtml, /id="home-hero-curl(?:-copy)?"|curl -s -X POST/);
+ assert.doesNotMatch(homeHtml, /id="home-quickstart-code"|id="home-copy-quickstart"/);
const page = makePage(() => { throw new Error("unexpected key request"); });
await page.click("home-hero-python-copy");
- await page.click("home-hero-curl-copy");
- assert.deepEqual(page.copies, [
- "curl -s -X POST https://api.thisisatest.tech/v1/demo/keys",
- ]);
- assert.equal(page.elements.get("home-hero-copy-status").textContent, "Commands copied.");
+ assert.deepEqual(page.copies, []);
assert.equal(page.requests.length, 0);
});
@@ -127,7 +114,6 @@ test("idle, loading, and success issue one empty POST and fill the live quicksta
const get = (id) => page.elements.get(id);
assert.equal(get("home-key-trigger").hidden, false);
assert.equal(get("home-key-panel").hidden, true);
- assert.equal(get("home-copy-quickstart").disabled, true);
assert.equal(get("home-hero-python-copy").disabled, true);
assert.equal(page.requests.length, 0);
@@ -157,16 +143,13 @@ test("idle, loading, and success issue one empty POST and fill the live quicksta
assert.equal(get("home-key-value").value, key);
assert.equal(get("home-wallet-value").value, "agt-test");
assert.equal(get("home-key-budget").textContent, "1000");
- assert.equal(get("home-copy-quickstart").disabled, false);
assert.equal(get("home-hero-python-copy").disabled, false);
- assert.equal(get("home-quickstart-code").textContent,
- template.replace("export AMW_API_KEY='YOUR_DEMO_KEY'", () => "export AMW_API_KEY='b2a_test_'\"'\"'$& '")
- .replace("export AMW_WALLET_ID='YOUR_WALLET_ID'", "export AMW_WALLET_ID='agt-test'"));
assert.equal(get("home-hero-python").textContent,
heroTemplate.replace("export AMW_API_KEY='YOUR_DEMO_KEY'", () => "export AMW_API_KEY='b2a_test_'\"'\"'$& '")
.replace("export AMW_WALLET_ID='YOUR_WALLET_ID'", "export AMW_WALLET_ID='agt-test'"));
await page.click("home-hero-python-copy");
assert.equal(page.copies[0], get("home-hero-python").textContent);
+ assert.equal(get("home-hero-copy-status").textContent, "Commands copied.");
assert.match(page.copies[0], /export AMW_WALLET_ID='agt-test'\npython examples\/permit_echo_retry\.py$/);
assert.equal(page.copies[0].includes("YOUR_DEMO_KEY"), false);
assert.equal(get("home-key-trigger").disabled, false);
@@ -238,14 +221,11 @@ test("reveal and copy controls use full values and quote shell commands", async
await page.click("home-key-copy");
await page.click("home-wallet-copy");
await page.click("home-key-copy-both");
- await page.click("home-copy-quickstart");
assert.deepEqual(page.copies, [
"b2a_a'b",
"agt-w",
"export AMW_API_KEY='b2a_a'\"'\"'b'\nexport AMW_WALLET_ID='agt-w'",
- get("home-quickstart-code").textContent,
]);
- assert.equal(get("home-copy-status").textContent, "Quickstart copied.");
});
test("network and service failures show retry and a later request can succeed", async () => {
@@ -319,7 +299,6 @@ test("malformed success fails closed and unavailable clipboard focuses a manual
await invalid.click("home-key-trigger");
assert.equal(invalid.elements.get("home-key-result").hidden, true);
assert.equal(invalid.elements.get("home-key-retry").hidden, false);
- assert.equal(invalid.elements.get("home-copy-quickstart").disabled, true);
assert.equal(invalid.elements.get("home-hero-python-copy").disabled, true);
}
@@ -331,9 +310,9 @@ test("malformed success fails closed and unavailable clipboard focuses a manual
await page.click("home-key-copy-both");
assert.equal(page.elements.get("home-key-status").textContent,
"Copy was unavailable. Copy Key and Wallet separately.");
- await page.click("home-copy-quickstart");
- assert.equal(page.elements.get("home-quickstart-code").focusCount, 1);
- assert.equal(page.elements.get("home-copy-status").textContent,
+ await page.click("home-hero-python-copy");
+ assert.equal(page.elements.get("home-hero-python").focusCount, 1);
+ assert.equal(page.elements.get("home-hero-copy-status").textContent,
"Copy was unavailable. Select the text and copy it manually.");
});
diff --git a/tests/test_site_agent_interface.py b/tests/test_site_agent_interface.py
index f8093966..953ef701 100644
--- a/tests/test_site_agent_interface.py
+++ b/tests/test_site_agent_interface.py
@@ -237,24 +237,35 @@ def test_rendered_landing_is_human_first_and_has_a_working_funnel(tmp_path) -> N
"configured upstream tool and at most one debit. Each finalized or "
"reconciled path has a receipt."
) in text
- assert "Each action runs once" not in text
+ assert "Each action runs once and leaves a receipt." in text
+ assert re.search(
+ r"Each action runs once and leaves a receipt\.
\s*"
+ r'One accepted request key',
+ page,
+ )
assert "Get a demo key" in text
assert "Run the quickstart: amw-demo" in text
assert re.search(r']*id="home-key-trigger"[^>]*>', page)
- assert '' in page
+ assert '' in page
assert re.search(r'.*?href="/demo-key/?"[^>]*>.*? ', page, re.S)
assert 'href="https://github.com/agentmiddleware/amw-demo"' in page
assert 'id="quickstart"' in page
- assert page.count("rcpt_7Kq2mX9
") == 2
+ assert page.count("rcpt_7Kq2mX9") == 3
+ assert "receipt_id: rcpt_7Kq2mX9\nSame receipt. The tool did not run again." in page
assert "rcpt_7Kq2mX9." not in page
assert page.index('class="home-v2-glossary"') < page.index('id="how-it-works"')
- assert page.count('class="home-v2-guide-step"') == 5
- assert "git clone https://github.com/agentmiddleware/amw-demo.git" in page
+ checklist = page.split(' ", 1)[0]
+ assert checklist.count("curlcoming soon ' in page
+ assert "curl -s -X POST https://api.thisisatest.tech/v1/demo/keys" not in page
+ assert 'id="home-hero-curl-copy"' not in page
assert "The gateway does not dispatch again." in text
- assert "The tool did not run again." not in text
+ assert "Same receipt. The tool did not run again." in text
assert 'id="how-it-works"' in page
for heading in ("Permit", "Request key", "Receipt"):
assert heading in text
@@ -3435,7 +3446,7 @@ def test_landing_keeps_one_illustrative_retry_without_recording(tmp_path) -> Non
assert result.returncode == 0, result.stderr
page = (output / "index.html").read_text(encoding="utf-8")
- assert page.count("rcpt_7Kq2mX9") == 2
+ assert page.count("rcpt_7Kq2mX9") == 3
assert '
Date: Thu, 22 Oct 2026 15:05:25 -0700
Subject: [PATCH 2/2] style: ruff format site interface test
---
tests/test_site_agent_interface.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tests/test_site_agent_interface.py b/tests/test_site_agent_interface.py
index 953ef701..c8875765 100644
--- a/tests/test_site_agent_interface.py
+++ b/tests/test_site_agent_interface.py
@@ -261,7 +261,10 @@ def test_rendered_landing_is_human_first_and_has_a_working_funnel(tmp_path) -> N
assert page.count("git clone https://github.com/agentmiddleware/amw-demo.git") == 1
assert "python examples/permit_echo_retry.py" in page
assert "coming soon" in text
- assert 'class="hero-v2-tab hero-v2-tab-disabled">curlcoming soon ' in page
+ assert (
+ 'class="hero-v2-tab hero-v2-tab-disabled">curlcoming soon '
+ in page
+ )
assert "curl -s -X POST https://api.thisisatest.tech/v1/demo/keys" not in page
assert 'id="home-hero-curl-copy"' not in page
assert "The gateway does not dispatch again." in text