-
Notifications
You must be signed in to change notification settings - Fork 25
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
switch to @brightspace-ui/testing fixture #3764
Conversation
Thanks for the PR! 🎉 We've deployed an automatic preview for this PR - you can see your changes here:
|
@@ -17,7 +17,8 @@ describe('d2l-dialog', () => { | |||
describe('focus management', () => { | |||
|
|||
it('should focus on close button if no focusable elements inside', async() => { | |||
const el = await fixture(html`<d2l-dialog opened>not focusable</d2l-dialog>`); | |||
const el = await fixture(html`<d2l-dialog>not focusable</d2l-dialog>`); | |||
el.opened = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed previously, these types of tests where an event is fired as part of boot-up need to be adjusted to control when the event gets fired themselves.
@@ -62,7 +61,6 @@ describe('d2l-dropdown', () => { | |||
beforeEach(async() => { | |||
dropdown = await fixture(normalFixture); | |||
content = dropdown.querySelector('d2l-dropdown-content'); | |||
await content.updateComplete; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do more of this kind of thing in a follow-up PR.
@@ -24,7 +24,6 @@ describe('d2l-hierarchical-view', () => { | |||
const el = await fixture(viewsFixture); | |||
view1 = el.querySelector('#view1'); | |||
view2 = el.querySelector('#view2'); | |||
await oneEvent(view1, 'd2l-hierarchical-view-resize'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This event has already been fired by the time fixture
resolves.
@@ -103,7 +103,7 @@ describe('d2l-input-search', () => { | |||
|
|||
let clock; | |||
beforeEach(() => { | |||
clock = useFakeTimers(); | |||
clock = useFakeTimers({ toFake: ['clearTimeout', 'setTimeout'] }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new fixture
relies on await nextFrame()
when it resets stuff, so we need to be more targeted with our mocking otherwise requestAnimationFrame
gets mocked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be good to note on the eventual README docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I've already included it in the draft upgrade guide, but I could definitely see it going into a README as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests were VERY flaky in Firefox. I spent the entire day trying to figure out why occasionally the handle loses focus before the keys can be sent to it but got nowhere. So I ended up implementing a "retry".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll have to keep an eye on these, to see if one retry tends to be enough. Longer tests make flake that much more painful
actionArea.dispatchEvent(new Event('click')); | ||
}); | ||
await oneEvent(actionArea, 'click'); | ||
element.activateKeyboardMode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Activating keyboard mode does everything that clicking the button does.
} | ||
); | ||
|
||
const elem = await fixture(` | ||
const elemPromise = fixture(` | ||
<d2l-menu> | ||
<d2l-menu-item text="fast"></d2l-menu-item> | ||
<${delayedUpdateMenuItem}></${delayedUpdateMenuItem}> | ||
<span>not a menu item</span> | ||
</d2l-menu> | ||
`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to rework how this "slow element" works since fixture
now won't resolve until everything is ready anyway.
bubbles: false, | ||
composed: false | ||
})) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer needed now that fixture
waits for this for us.
@@ -92,7 +91,7 @@ describe('LabelledMixin', () => { | |||
const labelledElem = elem.querySelector('[labelled-by="label1"]'); | |||
const labelElem = elem.querySelector('#label1'); | |||
labelElem.textContent = 'new label value'; | |||
await nextFrame(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was really flaky so I switched it to use an event instead of rely on rAF.
b2b9802
to
dab2506
Compare
@@ -21,7 +21,7 @@ jobs: | |||
run: npm run lint:style | |||
playwright: | |||
name: Accessibility and Unit Tests | |||
timeout-minutes: 10 | |||
timeout-minutes: 15 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've re-run this many times locally and in CI.
- Locally, these changes are 1.1x (aXe) to 1.5x (unit) slower, which is barely noticeable
- In CI however, these changes are 1.3x (aXe) to 1.8x (unit) slower, which is adding ~3.5 minutes to this job. It's still quicker than the visual-diff tests though! 😅
It's admittedly not great, but also not shocking since we're now await
-ing all nested Lit components for ~1650 tests, and doing a lot more resetting of the browser state between tests. If the slowness becomes a problem, there's a lot of tests using timeouts that we could look into fixing up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think it's worth doing some cleanup to get a better sense of the real timing
@@ -21,7 +21,7 @@ jobs: | |||
run: npm run lint:style | |||
playwright: | |||
name: Accessibility and Unit Tests | |||
timeout-minutes: 10 | |||
timeout-minutes: 15 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think it's worth doing some cleanup to get a better sense of the real timing
@@ -103,7 +103,7 @@ describe('d2l-input-search', () => { | |||
|
|||
let clock; | |||
beforeEach(() => { | |||
clock = useFakeTimers(); | |||
clock = useFakeTimers({ toFake: ['clearTimeout', 'setTimeout'] }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be good to note on the eventual README docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll have to keep an eye on these, to see if one retry tends to be enough. Longer tests make flake that much more painful
Co-authored-by: Stacey Van Herk <[email protected]>
🎉 This PR is included in version 2.131.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
The vast majority of the changes here are just adjusting the import location, however having
fixture
now wait for everything to be ready did require adjusting a few tests that were dependent on it not doing that.Once this is merged I'll do a separate pull request to remove all the test code that's manually waiting for nested element
updateComplete
s.