Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors snapshot tests to conditionally skip execution based on test options, improving efficiency and clarity.
- Introduces a conditional early return when both snapshot and zoom tests are marked to skip
- Refactors snapshot options by merging DEFAULT_SNAPSHOT_OPTIONS with provided options using a new SNAPSHOT_OPTIONS constant
- Applies zoom-specific snapshot options when running zoom tests
| if (options.snapshot?.skip === false) { | ||
| await expect(page).toHaveScreenshot(`${snapshotName}.png`, SNAPSHOT_OPTIONS); | ||
| } | ||
|
|
||
| // Skip unnecessary zoom tests | ||
| if (options.snapshot?.zoom?.skip === false) { |
There was a problem hiding this comment.
[nitpick] Consider revising the condition 'options.snapshot?.skip === false' to ensure that tests run by default when skip is not explicitly set to true. For instance, checking for '!== true' may help avoid inadvertently skipping tests when the option is undefined.
| if (options.snapshot?.skip === false) { | |
| await expect(page).toHaveScreenshot(`${snapshotName}.png`, SNAPSHOT_OPTIONS); | |
| } | |
| // Skip unnecessary zoom tests | |
| if (options.snapshot?.zoom?.skip === false) { | |
| if (options.snapshot?.skip !== true) { | |
| await expect(page).toHaveScreenshot(`${snapshotName}.png`, SNAPSHOT_OPTIONS); | |
| } | |
| // Skip unnecessary zoom tests | |
| if (options.snapshot?.zoom?.skip !== true) { |
| } | ||
|
|
||
| // Skip unnecessary zoom tests | ||
| if (options.snapshot?.zoom?.skip === false) { |
There was a problem hiding this comment.
[nitpick] Similarly, evaluate whether using 'options.snapshot?.zoom?.skip === false' is the best approach or if a check for '!== true' may be more robust, ensuring zoom tests execute by default unless explicitly skipped.
| if (options.snapshot?.zoom?.skip === false) { | |
| if (options.snapshot?.zoom?.skip !== true) { |
|
Netlify Draft Deployment |
fc8f33e to
d403785
Compare
…mline viewport size settings Refs: #7251
This pull request refines the visual testing logic in
theme-snapshots.spec.jsto improve flexibility and efficiency by introducing conditional checks for skipping specific tests and restructuring snapshot options. The most important changes include adding conditions to skip unnecessary tests, refining snapshot options, and ensuring zoom-specific options are applied correctly.Improvements to test skipping logic:
options.snapshot.skipandoptions.snapshot.zoom.skipare true. This avoids running unnecessary tests. ([packages/tools/visual-tests/tests/theme-snapshots.spec.jsR24-R26](https://github.com/public-ui/kolibri/pull/7674/files#diff-2d3c27d5e93c119802fb7d5d17d32ef870f9f86071c72dda4bcd60e19b85fa62R24-R26))Enhancements to snapshot options:
SNAPSHOT_OPTIONSconstant that mergesDEFAULT_SNAPSHOT_OPTIONSwithoptions.snapshot.options. This improves clarity and modularity. ([packages/tools/visual-tests/tests/theme-snapshots.spec.jsL48-R62](https://github.com/public-ui/kolibri/pull/7674/files#diff-2d3c27d5e93c119802fb7d5d17d32ef870f9f86071c72dda4bcd60e19b85fa62L48-R62))SNAPSHOT_OPTIONSwithoptions.snapshot.zoom.optionswhen generating zoomed snapshots. ([packages/tools/visual-tests/tests/theme-snapshots.spec.jsL60-R74](https://github.com/public-ui/kolibri/pull/7674/files#diff-2d3c27d5e93c119802fb7d5d17d32ef870f9f86071c72dda4bcd60e19b85fa62L60-R74))The A11y and PO reviews will only take place after all other DoD steps have been completed by the Developer: