Skip to content

chore(playwright): dark mode support - #28593

Merged
sean-perkins merged 7 commits into
mainfrom
sp/playwright-theme-support
Nov 29, 2023
Merged

sean-perkins merged 7 commits into
mainfrom
sp/playwright-theme-support

Conversation

@sean-perkins

@sean-perkins sean-perkins commented Nov 28, 2023 •

Copy link
Copy Markdown
Contributor

Issue number: N/A


What is the current behavior?

Testing dark mode is manual per test in Playwright. Ionic developer needs to setup the variables and assign them to a selector that applies in the class.

What is the new behavior?

  • The .setContent API will now work with a new config option to test dark mode automatically without additional configuration/test set-up.
  • Default theme is no theme (fallback theme)
  • Screenshot names and test titles remain the same for all existing tests. Only tests that opt into a theme will be pre-pended with -dark or -light (as an example for current themes).

Does this introduce a breaking change?

  • Yes
  • No

Other information

@github-actions github-actions Bot added the package: core @ionic/core package label Nov 28, 2023
@sean-perkins
sean-perkins marked this pull request as ready for review November 28, 2023 22:19
@sean-perkins
sean-perkins requested a review from a team as a code owner November 28, 2023 22:19
@sean-perkins
sean-perkins requested review from averyrousseau and removed request for a team November 28, 2023 22:19

@brandyscarney brandyscarney left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code makes sense, just a question on how we want to support multiple themes if we decide to add more in the future.

Comment thread core/scripts/testing/variables.css Resolved
Base automatically changed from sp/axe-playwright to main November 29, 2023 00:53
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
<link href="${baseUrl}/css/ionic.bundle.css" rel="stylesheet" />
<link href="${baseUrl}/scripts/testing/styles.css" rel="stylesheet" />
<link href="${baseUrl}/scripts/testing/themes/${theme}.css" rel="stylesheet" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we only be adding this import if theme is defined? Right now we default to light, but this could prevent someone from testing the fallback theme values such as the ones found in https://github.com/ionic-team/ionic-framework/blob/main/core/src/themes/ionic.theme.default.ios.scss. Right now it looks like we wouldn't have that problem, but it would be easy for someone to add --ion-color-step-* variables to the light.css file and suddenly have a bunch of screenshot tests fail.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

theme is currently always defined in this capacity since we assign a default of light when the test config doesn't specify an explicit theme to test against.

I'll rework this a bit so that default is an available option for the fallback state. If the theme is default it will opt-out of importing a theme stylesheet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed here: 54289d8 (both feedback comment)

@liamdebeasi liamdebeasi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One non-blocking comment. Otherwise looks good. Thanks for doing this!

* - `light`: The light theme values.
* - `dark`: The dark theme values.
*/
export type Theme = 'default' | 'light' | 'dark';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bikeshedding: I wonder if "none" or "fallback" would make more sense here? I think of light mode as the default theme. Not a blocker for me, so if you think "default" is still the best option I'm fine with that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not wedded to the naming here, also agree default isn't clear. I think none could make sense 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reworked once again after offline feedback with Brandy.

We opted for:

  1. "light" theme = fallback theme, no stylesheet imported
  2. "dark" theme = dark.css stylesheet is imported

There is no explicit "light.css" theme of the variables, because those are a duplicate of what the fallback styles should be.

@sean-perkins
sean-perkins force-pushed the sp/playwright-theme-support branch from 2a6383c to 1c8a3b1 Compare November 29, 2023 20:22
@sean-perkins
sean-perkins added this pull request to the merge queue Nov 29, 2023
Merged via the queue into main with commit 5c2a73b Nov 29, 2023
@sean-perkins
sean-perkins deleted the sp/playwright-theme-support branch November 29, 2023 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants