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

Add interaction tests for pagelayout sticky #2241

Merged
merged 8 commits into from
Aug 31, 2022
Merged

Add interaction tests for pagelayout sticky #2241

merged 8 commits into from
Aug 31, 2022

Conversation

pksjce
Copy link
Collaborator

@pksjce pksjce commented Aug 18, 2022

Describe your changes here.

Add a couple of interactive tests

To test this, check PageLayout/interactions.stories

Taking over from #2224

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@pksjce pksjce requested review from broccolinisoup, colebemis and a team August 18, 2022 06:17
@changeset-bot
Copy link

changeset-bot bot commented Aug 18, 2022

⚠️ No Changeset found

Latest commit: 8a92caf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Maybe add a wait

Remove wait times
@pksjce pksjce added the skip changeset This change does not need a changelog label Aug 18, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Aug 18, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 76.26 KB (0%)
dist/browser.umd.js 76.87 KB (0%)

@pksjce
Copy link
Collaborator Author

pksjce commented Aug 18, 2022

@colebemis - This https://github.com/primer/react/runs/7892938558?check_suite_focus=true is where the tests will run on CI. Unfortunately it looks for tests in all stories.

@pksjce pksjce temporarily deployed to github-pages August 18, 2022 06:25 Inactive
@pksjce pksjce temporarily deployed to github-pages August 18, 2022 06:36 Inactive
const testId = `paragraph${i}`
return (
<Box key={i} as="p" sx={{margin: 0}}>
<span data-testid={testId}>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just adding some test ids to grab blocks


// fireEvent alternative?
const storyWindow = await canvas.getByTestId('story-window')
await fireEvent.scroll(storyWindow, {top: 600})
Copy link
Member

Choose a reason for hiding this comment

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

I wanted to give it a go to more descriptive event names, but can't seem to make this work :( See the doc Maybe I am missing something? @pksjce

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They don't yet have a descriptive name feature. However, storybook 7.0.0 is going to support sections within interaction tests I believe!

Copy link
Member

Choose a reason for hiding this comment

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

Ahh cool! I'll remove this then, and we can try later when available.

@broccolinisoup broccolinisoup temporarily deployed to github-pages August 22, 2022 07:55 Inactive
import {expect} from '@storybook/jest'
import {setTimeout} from 'timers/promises'
Copy link
Member

Choose a reason for hiding this comment

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

removed it in the next commit

CustomStickyHeader.play = async ({canvasElement}: {canvasElement: HTMLElement}) => {
const canvas = within(canvasElement)
const contentToScroll = await canvas.getByTestId('content3')
contentToScroll.scrollIntoView()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you need to scroll twice? The fireEvent.scroll below would be ideal. I would fix my tests to work on that if it works for you.

Copy link
Member

Choose a reason for hiding this comment

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

No it doesn't work :( This is what I mean here Maybe I am missing something?

Because the fireEvent.scroll didn't work I included contentToScroll. I'll give another go today and let you know if I make it work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah! I had the same experience. It would have been so much better if fireEvent scroll worked in this case.Maybe we aren't using the scrollcontainer effectively?

Copy link
Member

Choose a reason for hiding this comment

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

I tried it again but no luck 😢 I agree, I think it is about the scroll container. I tried the outer box, the page layout content as scroll containers but none of them are scrollable. (el.scrollHeight-el.clientHight is 0) and I tried giving auto overflow but that doesn't seem to work either. I'll remove this fireEvent for now and maybe down the track, it will be possible to do with user events from SB.

Copy link
Contributor

@colebemis colebemis left a comment

Choose a reason for hiding this comment

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

Thank you for setting this up, @pksjce

@broccolinisoup broccolinisoup temporarily deployed to github-pages August 30, 2022 00:00 Inactive
@pksjce pksjce temporarily deployed to github-pages August 30, 2022 10:31 Inactive
@pksjce pksjce enabled auto-merge (squash) August 31, 2022 03:01
@pksjce pksjce temporarily deployed to github-pages August 31, 2022 03:07 Inactive
@pksjce pksjce merged commit a348400 into main Aug 31, 2022
@pksjce pksjce deleted the pk/sticky-tests branch August 31, 2022 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changeset This change does not need a changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants