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

Create a screenshots page that will allow us to do screenshot testing #19385

Closed
wants to merge 6 commits into from

Conversation

andybalaam
Copy link
Contributor

@andybalaam andybalaam commented Oct 13, 2021

Signed-off-by: Andy Balaam andyb@element.io

Notes: Create a screenshots page that will allow us to do screenshot testing

I am working on a change that will modify the code of some pages without any visible effect in a visual browser. (The change is to use more table elements to make the UI easier to navigate in screen readers.)

I want to be able to check that my changes do not alter the appearance at all, so I think screenshot tests would be a good way to do this. The contributing guide mentions screenshot tests, but when I talked about this to the team we figured out that none actually exist yet.

So, this change is a draft proposal of how we could start to provide consistent renders of various components. It creates a page where we can choose a component and see it rendered:

image

The dropdown at the top allows choosing various different components. The list of components and how to render them is defined in src/vector/screenshots.tsx

This change is intended to be combined with a related change in matrix-react-sdk which will load this page in Puppeteer, and take a screenshot of each component.

I'm posting this to ask for feedback about whether this could be a useful feature, and whether the implementation strategy I've developed looks reasonable.

Thanks!


This PR currently has no changelog labels, so will not be included in changelogs.

A reviewer can add one of: T-Deprecation, T-Enhancement, T-Defect, T-Task to indicate what type of change this is, or add Type: [enhancement/defect/task] to the description and I'll add them for you.

Signed-off-by: Andy Balaam <andyb@element.io>
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

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

This looks like a good approach for ease of use. In the future, something like storybook or similar library functionality will prove useful, but given we need to mock out a ton of application state it seems wise to go custom.

Architecturally, I think it'd be good if we broke the mocks out to their own files somewhere. Ie: a bunch of JSON files for web responses and such that we can just import in for setting up application state. In particular, the push rules taking up a large part of the TS file isn't great.

src/vector/screenshots.tsx Outdated Show resolved Hide resolved
src/vector/screenshots.tsx Outdated Show resolved Hide resolved
src/vector/screenshots.tsx Outdated Show resolved Hide resolved
src/vector/screenshots.tsx Outdated Show resolved Hide resolved
@andybalaam
Copy link
Contributor Author

I broke each screenshot into its own file - what do you think @turt2live ?

@Palid
Copy link
Contributor

Palid commented Oct 15, 2021

This looks like a good approach for ease of use. In the future, something like storybook or similar library functionality will prove useful, but given we need to mock out a ton of application state it seems wise to go custom.

Architecturally, I think it'd be good if we broke the mocks out to their own files somewhere. Ie: a bunch of JSON files for web responses and such that we can just import in for setting up application state. In particular, the push rules taking up a large part of the TS file isn't great.

In the past I usually had a fake-server setup with things like fetch-mock or similar that was imported based on some env vars. That makes both testing and development without server a breeze, cause things will behave like you expect them to, with delays and such.

@andybalaam andybalaam marked this pull request as ready for review October 18, 2021 13:20
@andybalaam
Copy link
Contributor Author

Closing in favour of #20417

@andybalaam andybalaam closed this Jan 6, 2022
@andybalaam andybalaam deleted the screenshots-page branch January 6, 2022 10:56
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

Successfully merging this pull request may close these issues.

None yet

3 participants