chore(playwright): combine test configs for themes and modes#29206
chore(playwright): combine test configs for themes and modes#29206sean-perkins merged 7 commits intonextfrom
Conversation
mapsandapps
left a comment
There was a problem hiding this comment.
One idea for a comment. Implementation is good 👍🏻
| if (!isModeValidForTheme(mode, theme)) { | ||
| return; | ||
| } | ||
| if (mode === 'ios' || mode === 'md') { |
There was a problem hiding this comment.
I know we have a comment elsewhere, but it might be nice to note here that we're ignoring the md-ios and ios-md combos for testing.
There was a problem hiding this comment.
+1. Also good to document why we are ignoring those combos
| if (!isModeValidForTheme(mode, theme)) { | ||
| return; | ||
| } | ||
| if (mode === 'ios' || mode === 'md') { |
There was a problem hiding this comment.
I think we can simplify this (GitHub won't let me make a code suggestion because it would go across deleted lines)
processedModes.forEach((mode) => {
processedDirection.forEach((direction) => {
processedPalette.forEach((palette) => {
const [theme, modeName] = mode.split('-');
configs.push({ direction, palette, mode: (modeName ?? theme) as Mode, theme: theme as Theme });
});
});
});In both cases we need to iterate over directions and palettes, so having separate code paths here doesn't really save us much work. For the 'ios' and 'md' cases, modeName will be undefined which is why we fall back to theme setting the mode key in the config object.
There was a problem hiding this comment.
There's probably a way to simplify the types, but I didn't spend too much time thinking about that part.
There was a problem hiding this comment.
I took a slightly different approach, curious what you think: eb9f5d6.
I don't think we should suggest a theme can be a mode: (modeName ?? theme) as Mode. A mode can be a theme (for backwards compatibility), but a theme should not be a mode.
There was a problem hiding this comment.
The main problem here is we don't know if mode contains either a theme and a mode or a combined mode string ahead of time, so the naming in my original approach is confusing.
What you have works, but it's doing an additional indexOf check which will iterate through the mode input more than we need to.
Perhaps we can have something like this:
const [themeOrCombinedMode, modeName] = mode.split('-');
const parsedTheme = themeOrCombinedMode as Theme;
// If modeName is undefined then we have a combined mode string, so the first variable is actually the mode
const parsedMode = modeName ?? themeOrCombinedMode as Mode;This approach avoids the additional iteration through the string.
Co-authored-by: Liam DeBeasi <liamdebeasi@users.noreply.github.com>
Issue number: N/A
What is the current behavior?
Developers are not able to easily add the "ionic" theme to existing test cases, without running the test against both iOS and MD mode:
With the separation of
modeinto look and feel, the majority of test cases do not require testing the mode behavior and instead only need to test the visual theme that is applied to the component.What is the new behavior?
themesoption from theconfigstest generator object.themeandmodeinto the existingmodestest generator objectionic-iosandionic-md, to run the Ionic theme against the respective mode.Does this introduce a breaking change?
Other information
I do not have a strong preference on the semantics of
ionic-iosvs.ios-ionic(theme first vs. mode first). If anyone has an opinion or alternative suggestion, please add a comment.