Skip to content

Commit c4d1a62

Browse files
committed
fix broken tests
1 parent 4c1519d commit c4d1a62

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

zeppelin-web-angular/e2e/tests/theme/dark-mode.spec.ts

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test.describe('Dark Mode Theme Switching', () => {
1818
addPageAnnotationBeforeEach(PAGES.SHARE.THEME_TOGGLE);
1919
let themePage: ThemePage;
2020

21-
test.beforeEach(async ({ page, browserName }) => {
21+
test.beforeEach(async ({ page }) => {
2222
themePage = new ThemePage(page);
2323
await page.goto('/');
2424
await waitForZeppelinReady(page);
@@ -30,9 +30,7 @@ test.describe('Dark Mode Theme Switching', () => {
3030
await themePage.clearLocalStorage();
3131
});
3232

33-
test('Scenario: User can switch to dark mode and persistence is maintained', async ({ page, context }) => {
34-
let currentPage = page;
35-
33+
test('Scenario: User can switch to dark mode and persistence is maintained', async ({ page, browserName }) => {
3634
// GIVEN: User is on the main page, which starts in 'system' mode by default (localStorage cleared).
3735
await test.step('GIVEN the page starts in system mode', async () => {
3836
await themePage.assertSystemTheme(); // Robot icon for system theme
@@ -41,32 +39,28 @@ test.describe('Dark Mode Theme Switching', () => {
4139
// WHEN: Explicitly set theme to light mode for the rest of the test.
4240
await test.step('WHEN the user explicitly sets theme to light mode', async () => {
4341
await themePage.setThemeInLocalStorage('light');
44-
await page.reload();
42+
await page.waitForTimeout(500);
43+
if (browserName === 'webkit') {
44+
const currentUrl = page.url();
45+
await page.goto(currentUrl, { waitUntil: 'load' });
46+
} else {
47+
page.reload();
48+
}
4549
await waitForZeppelinReady(page);
4650
await themePage.assertLightTheme(); // Now it should be light mode with sun icon
4751
});
4852

4953
// WHEN: User switches to dark mode by setting localStorage and reloading.
50-
await test.step('WHEN the user switches to dark mode', async () => {
54+
await test.step('WHEN the user explicitly sets theme to dark mode', async () => {
5155
await themePage.setThemeInLocalStorage('dark');
52-
const newPage = await context.newPage();
53-
await newPage.goto(currentPage.url(), { waitUntil: 'networkidle' });
54-
await waitForZeppelinReady(newPage);
55-
56-
// Update themePage to use newPage and verify dark mode
57-
themePage = new ThemePage(newPage);
58-
currentPage = newPage;
59-
await themePage.assertDarkTheme();
60-
});
61-
62-
// AND: User refreshes the page.
63-
await test.step('AND the user refreshes the page', async () => {
64-
await currentPage.reload();
65-
await waitForZeppelinReady(currentPage);
66-
});
67-
68-
// THEN: Dark mode is maintained after refresh.
69-
await test.step('THEN dark mode is maintained after refresh', async () => {
56+
await page.waitForTimeout(500);
57+
if (browserName === 'webkit') {
58+
const currentUrl = page.url();
59+
await page.goto(currentUrl, { waitUntil: 'load' });
60+
} else {
61+
page.reload();
62+
}
63+
await waitForZeppelinReady(page);
7064
await themePage.assertDarkTheme();
7165
});
7266

0 commit comments

Comments
 (0)