Skip to content
Merged
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ HERESY-API asks a deeply irresponsible question:

The answer now comes in two forms: the Python **API Time Machine** and the browser-based **HERESY API Calculator**.

**Live Pages site:** [https://qsolkcb.github.io/HERESY-API/](https://qsolkcb.github.io/HERESY-API/)

## HERESY API Calculator

The calculator is a plain HTML/CSS/JavaScript static app under [`web/`](web/).
Expand All @@ -18,14 +20,14 @@ Open it locally with no server at all:
web/index.html
```

Or use the GitHub Pages deployment after PR #3 lands:
Or launch the live GitHub Pages copy:

```text
https://qsolkcb.github.io/HERESY-API/
```
[**Launch the HERESY API Calculator**](https://qsolkcb.github.io/HERESY-API/)

GitHub Pages is only the display case. The exact same files work directly from local disk.

The form behaves like the enterprise governance artefact it pretends to be: editing operands, operation, or interface style only **stages** the request. Nothing executes until you press **COMMIT ENTERPRISE ARITHMETIC**.

### Calculator contract

- no framework
Expand Down
33 changes: 28 additions & 5 deletions tests/app_dom_smoke.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,38 @@ global.document = documentStub;

require("../web/app.js");

assert.strictEqual(elements.result.textContent, "4");
assert.strictEqual(elements.intent.textContent, "ADD 2 2");
// Loading the app stages the defaults but does not execute arithmetic.
assert.strictEqual(elements.result.textContent, "");
assert.strictEqual(elements.intent.textContent, "");
assert.strictEqual(elements.payload.textContent, "");
assert.strictEqual(elements.error.hidden, true);

for (const id of ["left", "right", "operation", "style"]) {
assert.strictEqual(elements[id].listeners.change, undefined, id + " unexpectedly recalculates on change");
}

// Changing staged input must not execute until the enterprise commit is submitted.
elements.left.value = "9";
elements.right.value = "4";
elements.operation.value = "multiply";
assert.strictEqual(elements.result.textContent, "");

let prevented = false;
elements["calculator-form"].listeners.submit({
preventDefault() {
prevented = true;
},
});
assert.strictEqual(prevented, true);
assert.strictEqual(elements.result.textContent, "36");
assert.strictEqual(elements.intent.textContent, "MUL 9 4");
assert.ok(elements.payload.textContent.length > 0);
assert.strictEqual(elements.error.hidden, true);

// Force a failed calculation after a successful one.
// Force a failed calculation after a successful one, again only through submit.
elements.operation.value = "divide";
elements.right.value = "0";
elements.right.listeners.change();
elements["calculator-form"].listeners.submit({ preventDefault() {} });

assert.strictEqual(elements.error.hidden, false);
assert.match(elements.error.textContent, /architecture committee/);
Expand All @@ -101,4 +124,4 @@ for (const id of [
assert.strictEqual(elements[id].textContent, "", id + " retained stale output");
}

console.log("HERESY DOM adapter: failed calculations clear stale museum output.");
console.log("HERESY DOM adapter: arithmetic executes only after enterprise commit approval.");
8 changes: 8 additions & 0 deletions tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

ROOT = Path(__file__).resolve().parents[1]
WEB = ROOT / "web"
PAGES_URL = "https://qsolkcb.github.io/HERESY-API/"


class OfflineCalculatorTests(unittest.TestCase):
Expand Down Expand Up @@ -40,11 +41,18 @@ def test_ui_retains_required_joke_and_measurement_surfaces(self) -> None:
'id="api-key-status"',
'id="auth-status"',
"NO API KEY FOR DAVE TO LOSE",
"Nothing executes until enterprise arithmetic is committed",
):
self.assertIn(marker, index)
self.assertIn('authenticationStatus: authenticated ? "401"', core)
self.assertIn('remediation: authenticated ? "rewind tape"', core)

def test_readme_links_live_pages_calculator(self) -> None:
readme = (ROOT / "README.md").read_text(encoding="utf-8")
self.assertIn(PAGES_URL, readme)
self.assertIn("COMMIT ENTERPRISE ARITHMETIC", readme)
self.assertIn("stages", readme)

def test_pages_workflow_publishes_only_static_web_directory(self) -> None:
workflow = (ROOT / ".github" / "workflows" / "pages.yml").read_text(encoding="utf-8")
self.assertIn("actions/upload-pages-artifact", workflow)
Expand Down
6 changes: 1 addition & 5 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@
calculate();
});

["left", "right", "operation", "style"].forEach(function (id) {
document.getElementById(id).addEventListener("change", calculate);
});

populateStyles();
calculate();
clearReport();
Comment thread
EmergentMonk marked this conversation as resolved.
Comment thread
EmergentMonk marked this conversation as resolved.
})();
1 change: 1 addition & 0 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ <h2 id="calculator-title">1. Specify the dangerous mathematics</h2>
</label>

<button type="submit">COMMIT ENTERPRISE ARITHMETIC</button>
<p class="commit-note">Inputs are staged locally. Nothing executes until enterprise arithmetic is committed.</p>
</form>

<p id="error" class="error" role="alert" hidden></p>
Expand Down