tripwire-e2e 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,169 +1,201 @@
1
- # Tripwire
2
-
3
- **Break the app on purpose to find out whether a green Kane suite means anything.**
4
-
5
- Coding agents write the app and its tests, and they are very good at writing tests that pass.
6
- A passing end-to-end test only matters if it would have failed when the app was broken, and
7
- nobody checks that. Tripwire does.
8
-
9
- A proxy sits between the browser and your app and breaks it in one small, realistic way at a time:
10
- a wrong total, a failed save reported as success, a missing button, another user's order in your
11
- list. It never touches your code. [Kane CLI](https://github.com/LambdaTest/kane-cli) replays your
12
- suite against each broken version with healing off. Every bug the suite walks past goes to your
13
- coding agent, which adds one plain-English assertion, and Kane proves it: the strengthened test
14
- **passes on the real app and fails on the broken one**.
15
-
16
- ![tripwire score](https://raw.githubusercontent.com/da-b0s/tripwire/main/demo/shop/.tripwire/report/badge.svg)
17
-
18
- ## Results
19
-
20
- On the demo shop, with a 6-test suite written by a fresh Claude Code session that was never told
21
- about Tripwire (run of 18 Nov 2026, Kane CLI 0.10.5):
22
-
23
- | | Score | Killed | Survived | Masked by heal | Not reached |
24
- |---|---|---|---|---|---|
25
- | Agent's first-draft suite | **83.3%** | 25 | 4 | 1 | 2 |
26
- | After `tripwire fix` (2 tests strengthened) | **90%** | 27 | 2 | 1 | 2 |
27
-
28
- Bugs the first-draft suite walked past, all green in Kane:
29
-
30
- - **Another customer's order (#91002) listed in "My orders".** Fixed: `cancel_order_test.md` now
31
- checks the list holds exactly the user's own orders.
32
- - **A product price shown 10% too high** ($19.80 instead of $18.00). Fixed: `browse_test.md` now
33
- checks a price in the product grid.
34
- - The "Keep order" button missing from the cancel dialog.
35
- - The "+" and "−" quantity buttons swapping labels (the test presses them by accessibility name,
36
- so it never looks at what the user sees).
37
-
38
- Masked by healing: a one-off "session expired" (401) during cancel. Strict replay failed; with
39
- Kane's default adaptive healing the test re-authored itself past the sign-in page and passed.
40
-
41
- Each fix was proven on the first attempt by two Kane runs: pass on the real app, fail with the bug
42
- armed. One honest caveat: the order-list fix names the injected order ("no other rows such as
43
- #91002"); its "exactly 2 orders" check is what catches the bug, but naming the planted value is
44
- overfitting, so the fix prompt now forbids it. Score = killed ÷ (killed + survived + masked) over 32 of 40 selected mutants; the remaining
45
- 8 are queued (`tripwire run --resume`). The full report
46
- ([live page](https://da-b0s.github.io/tripwire/), [source](https://github.com/da-b0s/tripwire/blob/main/docs/index.html)) has a screenshot of
47
- every broken page the suite passed on, and Kane's own triage of every failure.
48
-
49
- **Cost:** baseline replay of 6 tests ≈ 4 credits; mutant runs ≈ 1 to 5 credits each (a failing
50
- replay costs more because Kane investigates it); a heal check ≈ 15 to 35; each proven fix ≈ 25.
51
-
52
- ## Quickstart
53
-
54
- You need Node 18+, Chrome, and a [TestMu AI](https://www.testmuai.com) account (free credits).
55
-
56
- ```bash
57
- npm install -g @testmuai/kane-cli tripwire-e2e
58
- kane-cli login
59
- ```
60
-
61
- Point your `*_test.md` files at the proxy (`url: http://localhost:8080` in the frontmatter), start
62
- your app, then:
63
-
64
- ```bash
65
- tripwire run # baseline, generate mutants, replay, score, report
66
- tripwire fix # hand each survivor to your agent; Kane proves every new assertion
67
- tripwire check # exit 1 below the threshold (for hooks and CI)
68
- ```
69
-
70
- Try it on the bundled demo shop (its Kane suite and recordings are committed):
71
-
72
- ```bash
73
- git clone https://github.com/da-b0s/tripwire && cd tripwire && npm install
74
- npm run shop # terminal 1: the app, on :3000
75
- ```
76
-
77
- ```bash
78
- cd demo/shop && npx tripwire run # terminal 2: starts the proxy on :8080 itself
79
- ```
80
-
81
- Without spending any credits you can inspect the committed results: `npx tripwire check`,
82
- `npx tripwire list`, `npx tripwire run --dry-run` and `npx tripwire report` all work offline.
83
-
84
- Long runs are safe to interrupt: `tripwire run --resume` continues from the last finished mutant,
85
- and `tripwire run --retry-errors` re-runs only mutants that hit a Kane service error.
86
-
87
- ## What a score means
88
-
89
- | Status | Meaning | Counted |
90
- |---|---|---|
91
- | **killed** | at least one test failed while the bug was live | yes |
92
- | **survived** | the bug fired and every test still passed | yes, against you |
93
- | **masked** | strict replay caught it, but with Kane's default healing the test re-authored itself and passed on the broken app | yes, against you |
94
- | **not reached** | the bug never fired in any test (e.g. no test submits invalid input) | no, listed separately |
95
-
96
- Score = killed ÷ (killed + survived + masked). Kane exit codes 2 and 3 (errors, timeouts) are
97
- retried once and never counted as kills. Mutants are only excluded as "equivalent" with a
98
- human-written reason in `.tripwire/equivalents.json`, and every exclusion is listed in the report.
99
-
100
- ## The operators
101
-
102
- Generated from the traffic and the pages your suite actually produced, so every mutant is
103
- relevant to at least one test. Data mutants only change values that were on screen, and interface
104
- mutants target controls by their visible text.
105
-
106
- | Family | Operator | What breaks |
107
- |---|---|---|
108
- | data | number-drift | a price, total or count is off by one unit or 10% |
109
- | data | item-drop / item-dup | a list loses or repeats an element |
110
- | data | field-swap | two displayed fields of a record are exchanged |
111
- | data | stale-read | a read after a write returns the old data |
112
- | data | wrong-owner | another user's record appears in a list |
113
- | behaviour | silent-fail | a write returns 500 and is dropped |
114
- | behaviour | fake-success | a write answers with its usual success body but is never saved |
115
- | behaviour | double-apply | a POST is applied twice |
116
- | behaviour | validation-off | a 400/422 becomes 200 |
117
- | behaviour | auth-drop | one request mid-flow returns 401 |
118
- | interface | hide-control | a control the tests see but never use disappears |
119
- | interface | dead-control | a control the tests click does nothing |
120
- | interface | label-swap | two button labels are exchanged |
121
- | interface | text-change | a heading or status shows the wrong words |
122
- | interface | wrong-link | a link points to a different page |
123
- | interface | missing-row-action | the first row loses its edit/delete/cancel action |
124
- | saboteur | agent-proposed | domain rules broken on purpose, proposed by your agent (`tripwire sabotage`) |
125
-
126
- ## Use it in your agent
127
-
128
- - **Claude Code Stop hook**: [hooks/stop-hook.mjs](https://github.com/da-b0s/tripwire/blob/main/hooks/stop-hook.mjs) blocks "done" while tests
129
- changed since the last run or the score is below the threshold, and names the bugs that got past.
130
- Merge [hooks/claude-settings.json](https://github.com/da-b0s/tripwire/blob/main/hooks/claude-settings.json) into `.claude/settings.json`.
131
- - **Any agent**: copy [hooks/AGENTS.md](https://github.com/da-b0s/tripwire/blob/main/hooks/AGENTS.md).
132
- - **CI**: [hooks/tripwire.yml](https://github.com/da-b0s/tripwire/blob/main/hooks/tripwire.yml) runs incrementally (`--since`) on pull requests.
133
- - **Memory**: `.tripwire/lessons.md` collects assertion patterns that caught real bugs; the agent
134
- reads it before writing new tests, so first drafts get stronger.
135
-
136
- ## What Kane does here
137
-
138
- | Kane feature | Role in Tripwire |
139
- |---|---|
140
- | `_test.md` replay | the suite runs once per mutant without re-authoring |
141
- | `--no-adaptive-heal` and heal events | strict verdicts; then a healing-on rerun detects masked bugs |
142
- | Policies and `evidence verdict` | an inverted policy (`failed + broken >= 1`) judges every mutant run; a clean policy gates the baseline |
143
- | `metrics.tests_without_checks` | assertion-free tests are reported first |
144
- | Evidence packs | screenshots of the broken page for the report and for the agent |
145
- | NDJSON events, exit codes, failure triage | machine-readable verdicts; Kane's own triage is shown next to each planted bug |
146
- | Official skill | the test-writing agent uses TestMu's skill; Tripwire checks the result |
147
-
148
- ## Limits
149
-
150
- - Tripwire mutates traffic and the rendered page, not source code. It measures whether the suite
151
- notices breakage a user would see. It does not replace unit-level mutation testing.
152
- - Server-rendered pages carry data in HTML, not JSON; data operators work on JSON APIs, interface
153
- operators work on any page. Websockets and static assets pass through untouched.
154
- - A Kane replay re-evaluates its AI checks, so it is cheap but not free (measured: ~2 credits per
155
- 3-step replay). See [NOTES.md](https://github.com/da-b0s/tripwire/blob/main/NOTES.md) for every measurement.
156
- - Only run it against apps you own or run locally.
157
-
158
- ## For judges
159
-
160
- - Everything runs locally against the demo shop; you only need a Kane login.
161
- - The demo suite in `demo/shop/tests/` was written by a separate Claude Code session that was never
162
- told about Tripwire; its full transcript is in `demo/shop/agent-session.jsonl` and the prompt in
163
- [WRITE_TESTS_PROMPT.md](https://github.com/da-b0s/tripwire/blob/main/demo/shop/WRITE_TESTS_PROMPT.md).
164
- - If you cannot run it: the committed report, ledger and screenshots in `demo/shop/.tripwire/`
165
- are the record of the runs shown in the video.
166
-
167
- ## License
168
-
169
- MIT
1
+ # Tripwire
2
+
3
+ **Break the app on purpose to find out whether a green Kane suite means anything.**
4
+
5
+ Coding agents write the app and its tests, and they are very good at writing tests that pass.
6
+ A passing end-to-end test only matters if it would have failed when the app was broken, and
7
+ nobody checks that. Tripwire does.
8
+
9
+ A proxy sits between the browser and your app and breaks it in one small, realistic way at a time:
10
+ a wrong total, a failed save reported as success, a missing button, another user's order in your
11
+ list. It never touches your code. [Kane CLI](https://github.com/LambdaTest/kane-cli) replays your
12
+ suite against each broken version with healing off. Every bug the suite walks past goes to your
13
+ coding agent, which adds one plain-English assertion, and Kane proves it: the strengthened test
14
+ **passes on the real app and fails on the broken one**.
15
+
16
+ ![tripwire score](https://raw.githubusercontent.com/da-b0s/tripwire/main/demo/shop/.tripwire/report/badge.svg)
17
+
18
+ ## Results
19
+
20
+ Two apps, each with a suite written by a fresh Claude Code session that was never told about
21
+ Tripwire (Kane CLI 0.10.5, 18 to 20 Nov 2026). Every fix below was proven by two Kane runs: the
22
+ strengthened test passes on the real app and fails with the bug armed.
23
+
24
+ **Demo shop** (`demo/shop`, 6 tests, JSON API)
25
+
26
+ | Run | Mutants | Score | Killed | Survived | Masked by heal | Not reached |
27
+ |---|---|---|---|---|---|---|
28
+ | First-draft suite | 40 | **78.4%** | 29 | 7 | 1 | 3 |
29
+ | After `tripwire fix` (5 proven fixes) | 40 | **91.9%** | 34 | 2 | 1 | 3 |
30
+ | Fresh measured re-run of the strengthened suite, harder set (adds 8 saboteur bugs and the in-page operators) | 50 | **78.7%** | 37 | 10 | 0 | 3 |
31
+ | After 3 more proven fixes | 50 | **85.1%** | 40 | 7 | 0 | 3 |
32
+
33
+ 5 of the 7 remaining survivors are flagged *suspected equivalent*: the bug fired but no page ever
34
+ showed anything different (mostly saboteur bugs placed in write responses that the shop ignores
35
+ because it re-reads the data). They stay in the score: only a person can exclude a mutant.
36
+
37
+ **TodoMVC** (`demo/third-party`, the unmodified JavaScript ES5 example, 6 tests, no backend)
38
+
39
+ | Run | Mutants | Score | Killed | Survived | Masked by heal |
40
+ |---|---|---|---|---|---|
41
+ | First-draft suite | 18 | **77.8%** | 14 | 2 | 2 |
42
+ | After `tripwire fix` (4 proven fixes, including both masked bugs) | 18 | **100%** | 18 | 0 | 0 |
43
+ | Incremental re-check of the strengthened suite (`--since`, corrected operators) | 17 | **94.1%** | 16 | 1 | 0 |
44
+ | After 1 more proven fix | 17 | **100%** | 17 | 0 | 0 |
45
+
46
+ **What the runs found**
47
+
48
+ - **Another customer's order (#91002) in "My orders"**, and a product price 10% too high, both green
49
+ in the first-draft shop suite. Both now caught by one appended step each.
50
+ - **Default healing passed a bug Kane's own triage had just diagnosed.** With a TodoMVC row hidden,
51
+ strict replay failed and Kane's triage said "application issue, major: the page says 3 items left
52
+ but shows only 'Walk the dog' and 'Read a book'". With healing on, Kane re-authored the check,
53
+ read the hidden row from the DOM, and passed. For masked bugs the agent learned to write checks
54
+ that forbid re-entering data, and those failed on the broken app even with healing on.
55
+ - **A replayed "exactly three items" check passed with four rows on screen** (screenshot in the
56
+ report). The appended fix pins the row to directly above the footer.
57
+ - **Coverage, with a third state.** Of the shop's 21 acceptance criteria: 7 proven and guarded,
58
+ 4 *proven but unguarded* (tests check them, a bug that broke them got past), 3 untouched by any
59
+ mutant, 7 owed (no test checks them).
60
+
61
+ Reports: [shop](https://da-b0s.github.io/tripwire/) · [TodoMVC](https://da-b0s.github.io/tripwire/todomvc/)
62
+ (each survivor with a screenshot of the broken page the suite passed on, Kane's triage of every
63
+ failure, every fix and lesson). Full measurements and findings: [NOTES.md](https://github.com/da-b0s/tripwire/blob/main/NOTES.md).
64
+
65
+ **Cost:** a passing replay ≈ 0.7 credits per test; a failing one ≈ 5 (Kane investigates it); a heal
66
+ check 15 to 35; each proven fix ≈ 25.
67
+
68
+ ## Quickstart
69
+
70
+ You need Node 18+, Chrome, and a [TestMu AI](https://www.testmuai.com) account (free credits).
71
+
72
+ ```bash
73
+ npm install -g @testmuai/kane-cli tripwire-e2e
74
+ kane-cli login
75
+ ```
76
+
77
+ Point your `*_test.md` files at the proxy (`url: http://localhost:8080` in the frontmatter), start
78
+ your app, then:
79
+
80
+ ```bash
81
+ tripwire run # baseline, generate mutants, replay, score, report
82
+ tripwire fix # hand each survivor to your agent; Kane proves every new assertion
83
+ tripwire check # exit 1 below the threshold (for hooks and CI)
84
+ ```
85
+
86
+ More: `tripwire sabotage` (your agent proposes domain bugs from your acceptance criteria),
87
+ `tripwire coverage` (criteria as owed / proven and guarded / proven but unguarded),
88
+ `tripwire run --since <ref>` (only mutants whose tests changed), `tripwire doctor` (checks
89
+ kane-cli, the login, and leftover Kane browsers that can change a shared app's state).
90
+
91
+ Try it on the bundled demo shop (its Kane suite and recordings are committed):
92
+
93
+ ```bash
94
+ git clone https://github.com/da-b0s/tripwire && cd tripwire && npm install
95
+ npm run shop # terminal 1: the app, on :3000
96
+ ```
97
+
98
+ ```bash
99
+ cd demo/shop && npx tripwire run # terminal 2: starts the proxy on :8080 itself
100
+ ```
101
+
102
+ Without spending any credits you can inspect the committed results: `npx tripwire check`,
103
+ `npx tripwire list`, `npx tripwire run --dry-run` and `npx tripwire report` all work offline.
104
+
105
+ Long runs are safe to interrupt: `tripwire run --resume` continues from the last finished mutant,
106
+ `--retry-errors` re-runs only mutants that hit a Kane service error, and `--redo <id>` re-runs
107
+ named mutants. Kane service hiccups before a run starts are waited out automatically.
108
+
109
+ ## What a score means
110
+
111
+ | Status | Meaning | Counted |
112
+ |---|---|---|
113
+ | **killed** | at least one test failed while the bug was live | yes |
114
+ | **survived** | the bug fired and every test still passed | yes, against you |
115
+ | **masked** | strict replay caught it, but with Kane's default healing the test re-authored itself and passed on the broken app | yes, against you |
116
+ | **not reached** | the bug never fired in any test (e.g. no test submits invalid input) | no, listed separately |
117
+
118
+ Score = killed ÷ (killed + survived + masked). Kane errors and timeouts are retried and never
119
+ counted. A survivor whose pages never showed anything different from the clean run is flagged as a
120
+ *suspected equivalent*; it is excluded only when a person adds it to `.tripwire/equivalents.json`
121
+ with a reason, and every exclusion is listed in the report. A gate can set flagged ones aside
122
+ without changing the score: `tripwire check --allow-suspected-equivalents` (this repo's CI does).
123
+
124
+ ## The operators
125
+
126
+ Generated from the traffic and the pages your suite actually produced, so every mutant is
127
+ relevant to at least one test. Data mutants only change values that were on screen; interface
128
+ mutants target controls by their visible text, or by tag and class with their row for icon buttons
129
+ and checkboxes. Links to other sites are never mutated.
130
+
131
+ | Family | Operator | What breaks |
132
+ |---|---|---|
133
+ | data | number-drift | a price, total or count is off by one unit or 10% |
134
+ | data | item-drop / item-dup | a list loses or repeats an element |
135
+ | data | field-swap | two displayed fields of a record are exchanged |
136
+ | data | stale-read | a read after a write returns the old data |
137
+ | data | wrong-owner | another user's record appears in a list |
138
+ | data | rendered-number-drift | a number shown on the page is off by one, changed in the page (no JSON needed) |
139
+ | data | rendered-item-drop / -dup | a list row disappears or shows twice, changed in the page |
140
+ | behaviour | silent-fail | a write returns 500 and is dropped |
141
+ | behaviour | fake-success | a write answers with its usual success body but is never saved |
142
+ | behaviour | double-apply | a POST is applied twice |
143
+ | behaviour | validation-off | a 400/422 becomes 200 |
144
+ | behaviour | auth-drop | one request mid-flow returns 401 |
145
+ | interface | hide-control | a control the tests see but never use disappears |
146
+ | interface | dead-control | a control the tests click does nothing |
147
+ | interface | label-swap | two button labels are exchanged |
148
+ | interface | text-change | a heading or status shows the wrong words |
149
+ | interface | wrong-link | a link points to a different page |
150
+ | interface | missing-row-action | the first row loses its edit/delete/cancel action |
151
+ | saboteur | agent-proposed | domain rules broken on purpose, proposed by your agent (`tripwire sabotage`) |
152
+
153
+ ## Use it in your agent
154
+
155
+ - **Claude Code Stop hook**: [hooks/stop-hook.mjs](https://github.com/da-b0s/tripwire/blob/main/hooks/stop-hook.mjs) blocks "done" while tests
156
+ changed since the last run or the score is below the threshold, and names the bugs that got past.
157
+ Merge [hooks/claude-settings.json](https://github.com/da-b0s/tripwire/blob/main/hooks/claude-settings.json) into `.claude/settings.json`.
158
+ - **Any agent**: copy [hooks/AGENTS.md](https://github.com/da-b0s/tripwire/blob/main/hooks/AGENTS.md).
159
+ - **CI**: [hooks/tripwire.yml](https://github.com/da-b0s/tripwire/blob/main/hooks/tripwire.yml) runs incrementally (`--since`) on pull requests.
160
+ - **Memory**: `.tripwire/lessons.md` records each bug with the exact step that was proven to catch
161
+ it; the agent reads it before writing new tests (seen live in the hook session above).
162
+
163
+ ## What Kane does here
164
+
165
+ | Kane feature | Role in Tripwire |
166
+ |---|---|
167
+ | `_test.md` replay | the suite runs once per mutant without re-authoring |
168
+ | `--no-adaptive-heal` and heal events | strict verdicts; then a healing-on rerun detects masked bugs |
169
+ | Policies and `evidence verdict` | an inverted policy (`failed + broken >= 1`) judges every mutant run; a clean policy gates the baseline |
170
+ | `metrics.tests_without_checks` | assertion-free tests are reported first |
171
+ | Evidence packs | screenshots of the broken page for the report and for the agent |
172
+ | NDJSON events, exit codes, failure triage | machine-readable verdicts; Kane's own triage is shown next to each planted bug |
173
+ | Official skill | the test-writing agent uses TestMu's skill; Tripwire checks the result |
174
+
175
+ ## Limits
176
+
177
+ - Tripwire mutates traffic and the rendered page, not source code. It measures whether the suite
178
+ notices breakage a user would see. It does not replace unit-level mutation testing.
179
+ - JSON operators need a JSON API; the in-page operators and interface operators work on any page.
180
+ Websockets and static assets pass through untouched.
181
+ - Kane's checks are AI-judged and not perfectly repeatable: the same mutant was caught by a test in
182
+ one run and survived it in another, and one check failed with `analyzer_failed` and passed on the
183
+ next replay. Treat a single kill or survival as strong evidence, not proof.
184
+ - Equivalence is flagged by comparing page text, so it cannot see effects that never reach the
185
+ page, and older baselines cannot see duplicated rows (duplicating mutants are never flagged then).
186
+ - A Kane replay re-evaluates its AI checks, so it is cheap but not free. See [NOTES.md](https://github.com/da-b0s/tripwire/blob/main/NOTES.md).
187
+ - Only run it against apps you own or run locally.
188
+
189
+ ## For judges
190
+
191
+ - Everything runs locally against the two demos; you only need a Kane login.
192
+ - Both suites were written by separate Claude Code sessions in clean folders that never saw
193
+ Tripwire; transcripts are in `demo/*/agent-session.jsonl`, prompts and what happened in
194
+ `demo/*/WRITE_TESTS_PROMPT.md`.
195
+ - `demo/shop/stop-hook-session.jsonl` is a real Claude Code session blocked by the Stop hook.
196
+ - If you cannot run it: the committed reports, ledgers, fixes, lessons and screenshots in
197
+ `demo/*/.tripwire/` are the record of every run.
198
+
199
+ ## License
200
+
201
+ MIT
@@ -94,9 +94,22 @@ export function controls(profile) {
94
94
  }
95
95
  for (const c of t.clicks) { const k = keyOf(c); if (by.has(k)) by.get(k).clicked = true; }
96
96
  }
97
- return [...by.values()].map((c) => ({ ...c, tests: [...c.tests], pages: [...c.pages] }));
97
+ // Links to other sites (author credits, social links) are not part of the app under test.
98
+ return [...by.values()].filter((c) => !(c.role === 'link' && isExternal(c.href))).map((c) => ({ ...c, tests: [...c.tests], pages: [...c.pages] }));
98
99
  }
99
100
 
101
+ export const isExternal = (href) => /^(https?:)?\/\//i.test(href || '') && !/^(https?:)?\/\/(localhost|127\.0\.0\.1|\[::1\])(:\d+)?(\/|$)/i.test(href);
102
+
103
+ // How a control reads in a sentence. "[button.destroy]" (no visible text) becomes
104
+ // 'the "destroy" button on the "Buy milk" row'; a labelled one becomes 'the "Save" button'.
105
+ export function labelOf(c) {
106
+ const anon = /^\[([a-z0-9-]+)(?:\.([\w-]+))?\]$/i.exec(c.text || '');
107
+ const kind = c.role === 'link' ? 'link' : c.role === 'checkbox' ? 'checkbox' : c.role === 'heading' ? 'heading' : 'button';
108
+ const name = anon ? `the unlabelled "${anon[2] || anon[1]}" ${kind}` : `the "${c.text}" ${kind}`;
109
+ return c.row && c.inRow && c.row !== c.text ? `${name} on the "${c.row}" row` : name;
110
+ }
111
+ export const sentence = (s) => s.charAt(0).toUpperCase() + s.slice(1);
112
+
100
113
  // The target a DOM mutant uses to find a control again in the page.
101
114
  export const targetOf = (c) => (c.pattern ? { role: c.role, text: c.text, pattern: c.pattern } : { role: c.role, text: c.text });
102
115
 
@@ -1,23 +1,23 @@
1
- // Interface: a control the test clicks no longer does anything. If the test passes anyway,
2
- // it never checked the effect of the click.
3
- import { controls, mutant } from './_util.js';
4
- import { domMutant } from './hide-control.js';
5
-
6
- export default {
7
- name: 'dead-control',
8
- family: 'interface',
9
- summary: 'The click handler of a control is disabled by an injected script.',
10
- generate(profile) {
11
- return controls(profile)
12
- .filter((c) => c.role === 'button' && c.clicked)
13
- .map((c) => mutant({
14
- id: `dead-control:button:"${c.text}"`,
15
- family: 'interface', operator: 'dead-control',
16
- match: { document: true },
17
- action: domMutant('dead', c),
18
- touches_tests: c.tests,
19
- describe: `Clicking "${c.text}" does nothing`,
20
- expect: `The test checks what "${c.text}" is supposed to change`
21
- }));
22
- }
23
- };
1
+ // Interface: a control the test clicks no longer does anything. If the test passes anyway,
2
+ // it never checked the effect of the click.
3
+ import { controls, mutant, labelOf } from './_util.js';
4
+ import { domMutant } from './hide-control.js';
5
+
6
+ export default {
7
+ name: 'dead-control',
8
+ family: 'interface',
9
+ summary: 'The click handler of a control is disabled by an injected script.',
10
+ generate(profile) {
11
+ return controls(profile)
12
+ .filter((c) => (c.role === 'button' || c.role === 'checkbox') && c.clicked)
13
+ .map((c) => mutant({
14
+ id: `dead-control:${c.role}:"${c.text}"`,
15
+ family: 'interface', operator: 'dead-control',
16
+ match: { document: true },
17
+ action: domMutant('dead', c),
18
+ touches_tests: c.tests,
19
+ describe: `${c.role === 'checkbox' ? 'Ticking' : 'Clicking'} ${labelOf(c)} does nothing`,
20
+ expect: `The test checks what "${c.text}" is supposed to change`
21
+ }));
22
+ }
23
+ };
@@ -1,6 +1,6 @@
1
1
  // Interface: a button or link the tests saw but never clicked disappears.
2
2
  // Catches suites that never look at controls they do not use.
3
- import { controls, mutant, targetOf } from './_util.js';
3
+ import { controls, mutant, targetOf, labelOf, sentence } from './_util.js';
4
4
 
5
5
  const domMutant = (op, c, extra = {}) => ({ type: 'dom', dom: { op, target: targetOf(c), ...extra } });
6
6
 
@@ -21,8 +21,8 @@ export default {
21
21
  match: { document: true },
22
22
  action: domMutant('hide', c),
23
23
  touches_tests: c.tests,
24
- describe: `The "${c.text}" ${c.role} is missing`,
25
- expect: `The test checks that "${c.text}" is offered`
24
+ describe: `${sentence(labelOf(c))} is missing`,
25
+ expect: `The test checks that ${labelOf(c)} is offered`
26
26
  }));
27
27
  }
28
28
  };