dididy commented on code in PR #5131:
URL: https://github.com/apache/zeppelin/pull/5131#discussion_r2659736273


##########
zeppelin-web-angular/e2e/tests/theme/dark-mode.spec.ts:
##########
@@ -11,124 +11,118 @@
  */
 
 import { expect, test } from '@playwright/test';
-import { ThemePage } from '../../models/theme.page';
+import { DarkModePage } from '../../models/dark-mode-page';
 import { addPageAnnotationBeforeEach, performLoginIfRequired, 
waitForZeppelinReady, PAGES } from '../../utils';
 
 test.describe('Dark Mode Theme Switching', () => {
   addPageAnnotationBeforeEach(PAGES.SHARE.THEME_TOGGLE);
-  let themePage: ThemePage;
+  let darkModePage: DarkModePage;
 
   test.beforeEach(async ({ page }) => {
-    themePage = new ThemePage(page);
-    await page.goto('/');
+    darkModePage = new DarkModePage(page);
+    await page.goto('/#/');
     await waitForZeppelinReady(page);
 
     // Handle authentication if shiro.ini exists
     await performLoginIfRequired(page);
 
     // Ensure a clean localStorage for each test
-    await themePage.clearLocalStorage();
+    await darkModePage.clearLocalStorage();
   });
 
-  test('Scenario: User can switch to dark mode and persistence is maintained', 
async ({ page, context }) => {
-    let currentPage = page;
-
+  test('Scenario: User can switch to dark mode and persistence is maintained', 
async ({ page, browserName }) => {
     // GIVEN: User is on the main page, which starts in 'system' mode by 
default (localStorage cleared).
     await test.step('GIVEN the page starts in system mode', async () => {
-      await themePage.assertSystemTheme(); // Robot icon for system theme
+      await darkModePage.assertSystemTheme(); // Robot icon for system theme
     });
 
     // WHEN: Explicitly set theme to light mode for the rest of the test.
     await test.step('WHEN the user explicitly sets theme to light mode', async 
() => {
-      await themePage.setThemeInLocalStorage('light');
-      await page.reload();
+      await darkModePage.setThemeInLocalStorage('light');
+      await page.waitForTimeout(500);
+      if (browserName === 'webkit') {
+        const currentUrl = page.url();
+        await page.goto(currentUrl, { waitUntil: 'load' });
+      } else {
+        page.reload();
+      }
       await waitForZeppelinReady(page);
-      await themePage.assertLightTheme(); // Now it should be light mode with 
sun icon
+      await darkModePage.assertLightTheme(); // Now it should be light mode 
with sun icon
     });
 
     // WHEN: User switches to dark mode by setting localStorage and reloading.
-    await test.step('WHEN the user switches to dark mode', async () => {
-      await themePage.setThemeInLocalStorage('dark');
-      const newPage = await context.newPage();
-      await newPage.goto(currentPage.url());
-      await waitForZeppelinReady(newPage);
-
-      // Update themePage to use newPage and verify dark mode
-      themePage = new ThemePage(newPage);
-      currentPage = newPage;
-      await themePage.assertDarkTheme();
-    });
-
-    // AND: User refreshes the page.
-    await test.step('AND the user refreshes the page', async () => {
-      await currentPage.reload();
-      await waitForZeppelinReady(currentPage);
-    });
-
-    // THEN: Dark mode is maintained after refresh.
-    await test.step('THEN dark mode is maintained after refresh', async () => {
-      await themePage.assertDarkTheme();
+    await test.step('WHEN the user explicitly sets theme to dark mode', async 
() => {
+      await darkModePage.setThemeInLocalStorage('dark');
+      await page.waitForTimeout(500);
+      if (browserName === 'webkit') {
+        const currentUrl = page.url();
+        await page.goto(currentUrl, { waitUntil: 'load' });
+      } else {
+        page.reload();
+      }

Review Comment:
   This logic was originally added as a workaround for an issue that occurred 
only on WebKit after upgrading Playwright to a newer version. Since it is 
expected to work correctly on WebKit with the current Playwright version, I 
removed the conditional handling. I’ll verify the CI results and address any 
issues if needed. I also cleaned up other unused and unnecessary methods.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to