Repository navigation
feat(actor): chain step options on helper actions - #5788
Merged
Merged
Conversation
I.click('a').first() selects a match without step.opts(), and overrides
strict mode like elementIndex does. Puppeteer forceClick now honours strict
mode and the selected index, matching the other helpers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WebDriver grabValueFromAll drops empty values, so the array comparison could not tell which field was filled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
I.see('x').retry(3) and I.click('a').first().timeout(5) now share one path
with step.opts(), through applyStepConfig. The recorder reads a step timeout
when the task starts, so a chained timeout applies. A step retry rule is
removed when that step finishes, instead of popping the last rule.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous commit only contains the test file rename. This one has the implementation: applyStepConfig shared with step.opts(), the recorder reading a step timeout when the task starts, per-step retry rule cleanup, typings and docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sets step options by chaining them to the action, without
step.opts():This works because
recordSteponly queues the step, so a chained call runs before the step does. Selection overrides strict mode the same wayelementIndexdoes. Passingstep.opts(),step.timeout()orstep.retry()as an argument keeps working, so nothing breaks at runtime.Changes
lib/step/record.js: extractsapplyStepConfig, used by both argument configs and the chain. Options now merge instead of replace.lib/actor.js: addsstepConfig()to the promise of every helper action.first,last,at,timeoutandretryare built on it. Calling any of them after the step has run throws an error.lib/recorder.js:recorder.addalso accepts its timeout as a function, read when the task starts. It was passed by value at queue time, so a chained timeout was ignored.lib/step/retry.js: a step's retry rule is removed when that step finishes, instead ofretries.pop()on the next finished step. A chained retry would otherwise leak onto the next step, andpop()could remove a rule added by something else.lib/helper/Puppeteer.js:forceClickhardcodedels[0], ignoring strict mode and the index. It now usesselectElement.CodeceptJS.StepPromise(stepConfig,timeout,retry) for action mustaches, andCodeceptJS.ElementStepPromise(addsfirst,last,at) for actions that enforce strict mode.element-selection,locators,migration-4,retryandtimeouts.Behaviour to review
Default typings: 91 action mustaches now return a promise type instead of
void, so projects usingno-floating-promisesget warnings on unawaited calls. This is the largest visible effect of the PR.Grabbers: methods that return values keep their existing types, so
.retry()on them works at runtime but doesn't compile in TypeScript.Selection is ignored where selection isn't used:
amOnPageswitchTomoveCursorTo,focus,blur,scrollTo,forceRightClicksaveElementScreenshot,clickXYNone of these throw in strict mode on those helpers.
Custom steps and page object methods don't get the chain.
Testing
test/acceptance/step_chain_test.js: for each strict action, the step throwsMultipleElementsFoundwithout the chain, passes with.first(), and rejects.at(100). Also covers field position,timeout(),retry()and combined chains.test/unit/actor_test.js: chain behaviour, including retry rule cleanup on pass and on failure, and keeping a global rule.withinandsessionpassed on Playwright.clickXY ... first()with a 10s test timeout. It then passed 6 of 6 alone and 59 of 59 in two full runs. I didn't find a cause; the local single-threadedphp -Sserver is my guess.tsdlocally reports only 2 cross-fileConfigconflict errors, unrelated to this change. TheTypings testsworkflow doesn't start on any branch, including4.x, because of a workflow file issue, so CI hasn't checked the typings.🤖 Generated with Claude Code