Skip to content

Commit f0ee0b3

Browse files
committed
docs(set-content): add comment
1 parent 968782a commit f0ee0b3

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

core/src/utils/test/playwright/page/utils/set-content.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,30 @@ export const setContent = async (page: Page, html: string, testInfo: TestInfo, o
6868
`;
6969
}
7070

71+
/**
72+
* This object is CRITICAL for Playwright stability.
73+
*
74+
* WHY IT'S NEEDED:
75+
* 1. Bypasses Dynamic Loading: It avoids the consistent import
76+
* failure 'await import(...)' when the global theme needed to be
77+
* re-applied after the initial Ionic framework load.
78+
* 2. Prevents Incorrect Palettes: It directly initializes with the
79+
* required 'enabled: "always"' palette before any scripts run. This guarantees that correct CSS variables are loaded from the start.
80+
* Otherwise, it would load the default light palette.
81+
*
82+
* These issues were only happening in Playwright Firefox tests
83+
* that use `setContent`.
84+
*/
7185
const customTheme = {
7286
palette: {
7387
dark: {
74-
enabled: palette === 'dark' ? 'always' : 'never'
88+
enabled: palette === 'dark' ? 'always' : 'never',
7589
},
7690
highContrast: {
77-
enabled: palette === 'high-contrast' ? 'always' : 'never'
91+
enabled: palette === 'high-contrast' ? 'always' : 'never',
7892
},
7993
highContrastDark: {
80-
enabled: palette === 'high-contrast-dark' ? 'always' : 'never'
94+
enabled: palette === 'high-contrast-dark' ? 'always' : 'never',
8195
},
8296
},
8397
};

0 commit comments

Comments
 (0)