Skip to content

Conversation

@anupriyakkumari
Copy link

What?

Worked on #5305

This PR partially moves Sobek option parsing to the mapping layer, removing parsing logic from the business logic layers.

Specifically, this PR includes moving the following option parsers:

  • ElementHandle{...}Options
  • Frame options dependent on element options

This has resulted in changes across multiple mapping layers in the browser package.

Why?

  • Separation of concerns.
  • Option parsing is only required by the mapping layer.
  • To simplify and make the code and tests easy to reason about.

Related

This change is part of the ongoing effort outlined in the epic issue:
Move Sobek entirely out of the business logic #4219


Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas. (no such necessary comments)
  • I have added tests for my changes. (didn't require adding tests)
  • I have run linter (some warnings couldn't be resolved) and tests locally (make check) and all pass.

@anupriyakkumari anupriyakkumari requested a review from a team as a code owner October 21, 2025 22:49
@anupriyakkumari anupriyakkumari requested review from ankur22 and codebien and removed request for a team October 21, 2025 22:49
@CLAassistant
Copy link

CLAassistant commented Oct 21, 2025

CLA assistant check
All committers have signed the CLA.

@inancgumus inancgumus requested review from inancgumus and removed request for ankur22 October 22, 2025 18:15
Copy link
Contributor

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall. Thanks a lot ❤️

We should also fix the linter and test errors. You can fix these locally using make. Please also remove the merge commit and squash it. Please split your changes into different commits if possible.

@anupriyakkumari anupriyakkumari force-pushed the move-ElementHandleBaseOptions-mapping-layer branch from 52bf2b8 to df02a1d Compare October 24, 2025 10:39
@anupriyakkumari anupriyakkumari force-pushed the move-ElementHandleBaseOptions-mapping-layer branch 3 times, most recently from 6679d1d to 16cab73 Compare October 24, 2025 13:19
Copy link
Contributor

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes 🙇 It's currently difficult to review this PR, and we might miss something without knowing it. Please split the current large commit into separate commits for each option (as long as they don't depend on each other). We should also resolve conflicts and make sure tests pass.

}

// parseElementHandleBaseOptions parses ElementHandleBaseOptions from opts
//nolint:unparam // keeping error for consistency with other parse functions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove error returns from all functions that don't return errors, as we don't need them now. We can add errors later if needed. We don't need to be consistent here.

Comment on lines +21 to +24
optionModifiers = "modifiers"
)

const noWaitAfterOption = "noWaitAfter"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this into the same const block and prefix it with option:

Suggested change
optionModifiers = "modifiers"
)
const noWaitAfterOption = "noWaitAfter"
optionModifiers = "modifiers"
optionNoWaitAfter = "noWaitAfter"
)

Comment on lines +26 to +29
var imageFormatToID = map[string]common.ImageFormat{ //nolint:gochecknoglobals
"jpeg": common.ImageFormatJPEG,
"png": common.ImageFormatPNG,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove nolint and move this to parseElementHandleScreenshotOptions, as it's only used there.

"selectText": func(opts sobek.Value) (*sobek.Promise, error) {
popts := common.NewElementHandleBaseOptions(eh.DefaultTimeout())
if err := popts.Parse(vu.Context(), opts); err != nil {
popts, err := parseElementHandleBaseOptions(vu.Context(), opts)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should take a timeout as a parameter, as before. Please apply this logic to other parse functions as well.

We don't want to change any existing behavior.

parsed := &common.ElementHandleBaseOptions{
Force: false,
NoWaitAfter: false,
Timeout: 0,
Copy link
Contributor

@inancgumus inancgumus Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should get Timeout from an input. Applies to other functions as well.

@inancgumus
Copy link
Contributor

@anupriyakkumari We'll release k6 1.4.0 in two weeks. Please continue working on this PR if you want it merged into k6 1.4.0. Otherwise, we'll have to postpone merging your PR until k6 1.5.0. I might work on some of the parts of #5305 even if you can't continue working on it.

@anupriyakkumari
Copy link
Author

@anupriyakkumari We'll release k6 1.4.0 in two weeks. Please continue working on this PR if you want it merged into k6 1.4.0. Otherwise, we'll have to postpone merging your PR until k6 1.5.0. I might work on some of the parts of #5305 even if you can't continue working on it.

Hi @inancgumus. Sorry for the delay, I am caught up in some work till 30th but I will trying my best to at least finish work on this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants