refactor(test): relocate browser suite to test/browser

This commit is contained in:
pj committed 2026-06-01 22:38:21 +05:30
1 parent 859eae53d4
commit 51f3a3fc2a
5 files changed

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>counter</title>
</head>
<body>
<button id="decrement">-</button>
<div id="counter">0</div>
<button id="increment">+</button>
<script>
let value = 0;
const display = document.getElementById("counter");
function render() {
display.textContent = String(value);
}
document.getElementById("increment").addEventListener("click", function () {
value += 1;
render();
});
document.getElementById("decrement").addEventListener("click", function () {
value -= 1;
render();
});
</script>
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
import { always, extract, taps } from "@sanderling/spec";
const counter = extract((s) => {
const el = s.ax.find({ id: "counter" });
return el ? parseInt(el.text, 10) || 0 : 0;
}).named("counter");
// The + and - buttons each move the counter by exactly 1, so no step ever
// changes it by more than 1. A bug that double-applied a click would break this.
const changesByAtMostOne = always(() => {
const previous = counter.previous;
if (previous === undefined) return true;
return Math.abs(counter.current - previous) <= 1;
});
export const properties = { changesByAtMostOne };
export const actionsRoot = taps;
+21
View File
@@ -0,0 +1,21 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>throwing</title>
</head>
<body>
<button id="press">press</button>
<div id="count">0</div>
<script>
let presses = 0;
document.getElementById("press").addEventListener("click", function () {
presses += 1;
document.getElementById("count").textContent = String(presses);
if (presses >= 3) {
throw new Error("pressed too many times");
}
});
</script>
</body>
</html>
+6
View File
@@ -0,0 +1,6 @@
import { taps } from "@sanderling/spec";
import { noUncaughtExceptions } from "@sanderling/spec/defaults/properties";
export const properties = { noUncaughtExceptions };
export const actionsRoot = taps;