Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose setViewport on window #624

Open
Jamie5 opened this issue Jul 13, 2022 · 2 comments
Open

Expose setViewport on window #624

Jamie5 opened this issue Jul 13, 2022 · 2 comments

Comments

@Jamie5
Copy link
Contributor

Jamie5 commented Jul 13, 2022

The request is to, in https://github.com/reg-viz/storycap/blob/master/packages/storycap/src/node/capturing-browser.ts , add to expose() another function, something like setViewport: (vp) => this.page.setViewport(vp), so that a test could do await window.setViewport(...)

Why?

We now have play functions, and hence UI interactions. These UI interactions may differ due to the size of the UI (i.e. responsive design might hide text when the window is narrow), which fundamentally goes to the window size. So it would be nice to be able to set the window size at the beginning of the test, rather than only when the screenshot happens. Otherwise play functions might become flaky and confusing.

Note that any other solution to the problem would be fine too - only that it would be strongly preferred for it to be possible to resize the viewport dynamically, rather than e.g. declaring in a test's parameters that it should have a given set of dimensions.

It might be possible to pass arguments to storycap to have a given viewport, but such a global option would not be preferred as individual tests might have individual viewports.

@Jamie5
Copy link
Contributor Author

Jamie5 commented Jul 14, 2022

Jamie5@cff4d38 works, though I imagine you would prefer to not just expose things on window itself. If this general feature is something you'd like to have I can work on something that is more wrapped properly, as it would be nice not to have to maintain forks and stuff.

@throwandgo
Copy link

I'm also interested in the ability to set the window size at the beginning of the test -- would it be possible to merge Jamie's change linked above?

throwandgo added a commit to remix/storycap that referenced this issue Oct 4, 2023
Pull in new changes from reg-viz/storycap, including the ability to shard screenshot captures across machines. We anticipate using this feature to ease the burden placed on individual CircleCI instances, since screenshot captures can be resource- and time-intensive.

Resolved conflicts on:
- packages/storycap/package.json
- packages/storycap/src/node/capturing-browser.ts
- packages/storycap/src/shared/screenshot-options-helper.ts

Since we last synced from upstream, the following changes have been accepted:
- Add the ability to screenshot a part of the screen (reg-viz#722)
- Fixed exposeFunction not being awaited (reg-viz#632)

We continue to maintain this fork because we're waiting for this issue to be addressed:
- Expose setViewport on window reg-viz#624

This sync is reflected in a version bump of our fork from 1.0.4 to 1.1.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants