Skip to content

Commit bda3b6e

Browse files
cursoragente-fisher
andcommitted
fix: Uncheck action is never generated in browser test scripts
CheckExpression.checked was typed as Expression (an IR AST node object) but used in a boolean context to decide between 'check' and 'uncheck' method names. Since an object is always truthy, the uncheck branch was unreachable and locator.uncheck() was never emitted in generated scripts. Change CheckExpression.checked from Expression to boolean so the ternary in emitCheckExpression works correctly. Update the intermediate emitter to pass the boolean directly and fix the variable substitution pass to preserve the boolean instead of calling substituteExpression. The test snapshot for uncheck-element was also wrong (showed .check() instead of .uncheck()), confirming the bug existed since the snapshot was first captured. Co-authored-by: Edgar Fisher <e-fisher@users.noreply.github.com>
1 parent 555be75 commit bda3b6e

File tree

4 files changed

+4
-7
lines changed

4 files changed

+4
-7
lines changed

src/codegen/browser/__snapshots__/browser/uncheck-element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default async function () {
1515
const page = await browser.newPage();
1616

1717
try {
18-
await page.locator('input[type="checkbox"]').check();
18+
await page.locator('input[type="checkbox"]').uncheck();
1919
} finally {
2020
await page?.close();
2121
}

src/codegen/browser/intermediate/ast.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export interface ClickExpression {
9696
export interface CheckExpression {
9797
type: 'CheckExpression'
9898
locator: Expression
99-
checked: Expression
99+
checked: boolean
100100
}
101101

102102
export interface SelectOptionsExpression {

src/codegen/browser/intermediate/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,7 @@ function emitCheckNode(context: IntermediateContext, node: m.CheckNode) {
243243
expression: {
244244
type: 'CheckExpression',
245245
locator,
246-
checked: {
247-
type: 'StringLiteral',
248-
value: node.checked ? 'checked' : 'unchecked',
249-
},
246+
checked: node.checked,
250247
},
251248
})
252249
}

src/codegen/browser/intermediate/variables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ function substituteExpression(
149149
case 'CheckExpression':
150150
return {
151151
type: 'CheckExpression',
152-
checked: substituteExpression(node.checked, substitutions),
152+
checked: node.checked,
153153
locator: substituteExpression(node.locator, substitutions),
154154
}
155155

0 commit comments

Comments
 (0)