kwikqa 0.16.0-rc.2 → 0.16.0-rc.4

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/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ What's new in each release of the KwikQA CLI.
4
4
 
5
5
  ## 0.16.0 — 2026-12-05
6
6
 
7
+ ### Added
8
+
9
+ - Opt in to `analyze --confirm-state` for a failing Cypress test when its diagnosis asks for an
10
+ `aria-expanded` check. KwikQA records up to 12 ordered expansion changes and offers one
11
+ separately previewed follow-up only if the same failure reproduces with that observation; the
12
+ follow-up may incur a charge.
13
+
7
14
  ### Changed
8
15
 
9
16
  - When a failing Playwright attempt has no trace, `analyze` offers to re-run the failing tests once
@@ -18,7 +25,8 @@ What's new in each release of the KwikQA CLI.
18
25
  source, or a captured page, element, probe, or trace showing what the application does; an
19
26
  environment owner needs a browser or network failure. Without it, the owner is shown as a lean
20
27
  and the failure isn't repaired. The diagnosis prompt (1.8) says a test change can ask for
21
- something the application doesn't do yet.
28
+ something the application doesn't do yet. KwikQA withholds the test owner when all cited
29
+ evidence that supports test ownership also supports a plausible application regression.
22
30
 
23
31
  ## 0.15.0 — 2026-12-02
24
32
 
package/README.md CHANGED
@@ -236,6 +236,13 @@ with full tracing. Cypress and WebdriverIO re-run the failing specs with your co
236
236
  KwikQA's reporter and failure capture, recording each failed attempt's DOM, command log, console,
237
237
  and network. Explicit capture requires terminal approval or `--yes`.
238
238
 
239
+ Use `analyze --capture --confirm-state` to allow one extra Cypress run when a diagnosis
240
+ leaves ownership open and asks about `aria-expanded`. The follow-up records up to 12
241
+ expansion changes during the single failing test. If the same failure reproduces and a
242
+ change enters the evidence preview, KwikQA can request a second diagnosis. It uses a
243
+ revised owner only when the graded answer cites a recorded change for ownership.
244
+ The follow-up has its own run and evidence approvals, which `--yes` accepts.
245
+
239
246
  With Playwright 1.59+ and [Playwright CLI](https://www.npmjs.com/package/@playwright/cli) installed,
240
247
  capture can also pause locator failures at the failing line and ask Playwright for locators of
241
248
  nearby elements. `analyze --no-probe` skips this step.
@@ -82,6 +82,37 @@ function serialize(root) {
82
82
  let commands = [];
83
83
  let consoleEntries = [];
84
84
  let screenshots = [];
85
+ let expansionChanges = [];
86
+ let expansionObserver;
87
+ const MAX_EXPANSION_CHANGES = 12;
88
+
89
+ function observeExpansion(records) {
90
+ // Changes to one element can be delivered together. The next mutation's old value
91
+ // is the preceding mutation's new value, even if the element has since changed again.
92
+ const nextValue = new Map();
93
+ const changes = [];
94
+ const start = Math.max(0, records.length - MAX_LOG);
95
+ for (let index = records.length - 1; index >= start; index--) {
96
+ const { target, oldValue } = records[index];
97
+ const current = nextValue.has(target)
98
+ ? nextValue.get(target)
99
+ : target.getAttribute("aria-expanded");
100
+ nextValue.set(target, oldValue);
101
+ if (
102
+ oldValue !== current &&
103
+ (oldValue === "true" || oldValue === "false") &&
104
+ (current === "true" || current === "false")
105
+ ) {
106
+ changes.push({
107
+ control: (target.getAttribute("aria-label") || target.tagName).slice(0, 120),
108
+ before: oldValue === "true",
109
+ after: current === "true",
110
+ });
111
+ if (changes.length === MAX_EXPANSION_CHANGES) break;
112
+ }
113
+ }
114
+ expansionChanges = [...expansionChanges, ...changes.reverse()].slice(-MAX_EXPANSION_CHANGES);
115
+ }
85
116
 
86
117
  function brief(attributes) {
87
118
  const props = attributes.renderProps || {};
@@ -105,6 +136,8 @@ Cypress.on("test:before:run", () => {
105
136
  commands = [];
106
137
  consoleEntries = [];
107
138
  screenshots = [];
139
+ expansionChanges = [];
140
+ expansionObserver?.takeRecords();
108
141
  });
109
142
  Cypress.on("log:added", (attributes) => {
110
143
  if (commands.length < MAX_LOG) commands.push(brief(attributes));
@@ -114,6 +147,19 @@ Cypress.on("log:changed", (attributes) => {
114
147
  if (index >= 0) commands[index] = brief(attributes);
115
148
  });
116
149
  Cypress.on("window:before:load", (win) => {
150
+ if (settings.observeExpanded === true) {
151
+ if (expansionObserver !== undefined) {
152
+ observeExpansion(expansionObserver.takeRecords());
153
+ expansionObserver.disconnect();
154
+ }
155
+ expansionObserver = new win.MutationObserver(observeExpansion);
156
+ expansionObserver.observe(win.document, {
157
+ attributes: true,
158
+ attributeOldValue: true,
159
+ attributeFilter: ["aria-expanded"],
160
+ subtree: true,
161
+ });
162
+ }
117
163
  for (const level of ["error", "warn"]) {
118
164
  const original = win.console[level];
119
165
  win.console[level] = (...args) => {
@@ -153,6 +199,7 @@ afterEach(function kwikqaCapture() {
153
199
  typeof test.currentRetry === "function" ? test.currentRetry() : test._currentRetry || 0;
154
200
  const spec = Cypress.spec.relative;
155
201
  cy.document({ log: false }).then((doc) => {
202
+ if (expansionObserver !== undefined) observeExpansion(expansionObserver.takeRecords());
156
203
  const snapshot = serialize(doc.documentElement);
157
204
  const network = commands
158
205
  .filter(
@@ -183,6 +230,7 @@ afterEach(function kwikqaCapture() {
183
230
  dom: snapshot.tree,
184
231
  domTruncated: snapshot.truncated,
185
232
  commands: commands.map(({ id, ...rest }) => rest),
233
+ ...(expansionChanges.length === 0 ? {} : { expansionChanges }),
186
234
  console: consoleEntries,
187
235
  network,
188
236
  screenshots,