@ggui-ai/ui-visual-tester 0.16.0 → 0.17.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/dist/validate.js CHANGED
@@ -58,8 +58,13 @@ function parseRunOutcome(value) {
58
58
  diagnostic: typeof diagnostic === 'string' ? diagnostic : 'unknown',
59
59
  };
60
60
  }
61
- case 'action-not-rendered':
62
- return { status: 'action-not-rendered' };
61
+ case 'action-not-rendered': {
62
+ const diagnostic = value.diagnostic;
63
+ return {
64
+ status: 'action-not-rendered',
65
+ diagnostic: typeof diagnostic === 'string' ? diagnostic : 'no clickable control in the rendered DOM',
66
+ };
67
+ }
63
68
  case 'action-no-effect': {
64
69
  const diagnostic = value.diagnostic;
65
70
  return {
@@ -67,6 +72,21 @@ function parseRunOutcome(value) {
67
72
  diagnostic: typeof diagnostic === 'string' ? diagnostic : 'no signal',
68
73
  };
69
74
  }
75
+ case 'action-unreachable': {
76
+ const diagnostic = value.diagnostic;
77
+ const reason = value.reason;
78
+ if (reason !== 'disabled-after-priming' && reason !== 'behind-navigation') {
79
+ return {
80
+ status: 'render-failed',
81
+ diagnostic: `fixture returned action-unreachable with an unknown reason: ${JSON.stringify(reason)}`,
82
+ };
83
+ }
84
+ return {
85
+ status: 'action-unreachable',
86
+ reason,
87
+ diagnostic: typeof diagnostic === 'string' ? diagnostic : 'the action could not be reached',
88
+ };
89
+ }
70
90
  case 'ok': {
71
91
  const dispatchFired = value.dispatchFired === true;
72
92
  const domChanged = value.domChanged === true;
@@ -83,6 +103,7 @@ async function runOne(page, input) {
83
103
  const serialized = {
84
104
  componentCode: input.componentCode,
85
105
  contractJson: JSON.stringify(input.contract),
106
+ samplePropsJson: JSON.stringify(input.sampleProps ?? {}),
86
107
  actionName: input.actionName,
87
108
  classification: input.classification,
88
109
  settleMs: input.settleMs,
@@ -96,6 +117,7 @@ async function runOne(page, input) {
96
117
  return await fn({
97
118
  componentCode: arg.componentCode,
98
119
  contract: JSON.parse(arg.contractJson),
120
+ sampleProps: JSON.parse(arg.samplePropsJson),
99
121
  actionName: arg.actionName,
100
122
  classification: arg.classification,
101
123
  settleMs: arg.settleMs,
@@ -118,7 +140,7 @@ function classify(actionName, outcome) {
118
140
  return {
119
141
  kind: 'action-not-rendered',
120
142
  actionName,
121
- diagnostic: `no button found matching actionSpec.${actionName}.label`,
143
+ diagnostic: outcome.diagnostic,
122
144
  };
123
145
  case 'action-no-effect':
124
146
  return {
@@ -127,6 +149,13 @@ function classify(actionName, outcome) {
127
149
  diagnostic: `clicking actionSpec.${actionName} produced no required signal — ` +
128
150
  outcome.diagnostic,
129
151
  };
152
+ case 'action-unreachable':
153
+ return {
154
+ kind: 'action-unreachable',
155
+ actionName,
156
+ reason: outcome.reason,
157
+ diagnostic: `actionSpec.${actionName} could not be reached by the static probe (not measured) — ${outcome.diagnostic}`,
158
+ };
130
159
  }
131
160
  }
132
161
  /**
@@ -173,6 +202,7 @@ export async function validateContractBehavior(input) {
173
202
  const outcome = await runOne(page, {
174
203
  componentCode: input.componentCode,
175
204
  contract: input.contract,
205
+ ...(input.sampleProps !== undefined ? { sampleProps: input.sampleProps } : {}),
176
206
  actionName: name,
177
207
  classification,
178
208
  settleMs: SETTLE_MS,