Add end to end tests for Fit Text#72406
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: 0 B Total Size: 2.2 MB ℹ️ View Unchanged
|
8018e91 to
d7a1bd3
Compare
|
Flaky tests detected in a07c89d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18654985615
|
mcsf
left a comment
There was a problem hiding this comment.
I left some questions. I'm optimistically approving the PR assuming the questions don't require follow-up, but that's your call :)
| const fontSize = await heading.evaluate( ( el ) => { | ||
| return window.getComputedStyle( el ).fontSize; | ||
| } ); | ||
|
|
||
| expect( fontSize ).toBeTruthy(); | ||
| expect( parseFloat( fontSize ) ).toBeGreaterThan( 0 ); |
There was a problem hiding this comment.
Are we testing anything meaningful here? getComputedStyle returns a resolved value, and I can't think of a case in which we won't get a positive in this test.
For example, in this very browser tab's console, querying GitHub, I get:
window.getComputedStyle( document.querySelector('head') ).fontSize // "16px"
window.getComputedStyle( document.querySelector('meta') ).fontSize // "16px"Seems like a better test could be to verify that the computed size property matches the contents of styleElement, or at the very least that the size is greater than the document's base font size.
There was a problem hiding this comment.
You are right this assertion is not meaningful, I updated the test to assert that computed font size matches the contents of styleElement as suggested.
| // Wait for fit text to calculate initially | ||
| await page.waitForFunction( | ||
| ( styleId ) => { | ||
| const style = document.getElementById( styleId ); | ||
| return style && style.textContent.trim().length > 0; | ||
| }, | ||
| `fit-text-${ fitTextId }`, | ||
| { timeout: 5000 } | ||
| ); |
There was a problem hiding this comment.
Why do we need this manual waiting here, but not in other tests? In particular, the next test is also running in the front end.
There was a problem hiding this comment.
This the only test in the front end where fit text dynamically changes the font size (after the window resize), on the other tests we just load the post fit text computes and there are not additional changes. But we only need the second waitForFunction after the resize not this initial one so I removed it.
97eecc2 to
9e8921f
Compare
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org> Co-authored-by: mcsf <mcsf@git.wordpress.org>
…2e tests (#72584) * Add end to end tests for Fit Text (#72406) Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org> Co-authored-by: mcsf <mcsf@git.wordpress.org> * Update: Disable font size when fit text is enabled and the opposite. (#72533) Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> --------- Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org> Co-authored-by: mcsf <mcsf@git.wordpress.org>
Implements end to end tests for Fit Text.
Testing
Verify the end to end test is passing
npm run test:e2e -- fit-textApply this patch:
Rerun the end to end test
npm run test:e2e -- fit-textverify all the front end tests fail.Apply this patch:
Rerun the end to end test
npm run test:e2e -- fit-textverify all the editor tests fail.