Skip to content

Commit 4d444be

Browse files
committed
[ZEPPELIN-6370] Upgrade playwright and change the method of installing Playwright browsers
#5107 https://github.com/apache/zeppelin/actions/runs/18662031473/job/53204596550?pr=5107 In the Playwright E2E tests of the above bump PR, the following issue occurred: ``` Error: browserType.launch: Executable doesn't exist at /home/runner/.cache/ms-playwright/webkit-2215/pw_run.sh ``` This issue seems to be caused by the Playwright browser installation step being version-locked in `zeppelin-web-angular/pom.xml`'s playwright-install execution. Instead of managing it in `pom.xml`, it would be better to add it to the `postinstall` script in `zeppelin-web-angular/package.json`, so that Playwright browsers are automatically installed when running `npm install`, either in CI and on a local environment. This PR addresses that change. 61ff629 Including the CI caching procedure as above, it seems optimized as previous approach(pom.xml). Improvement ZEPPELIN-6370 * Does the license files need to update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Closes #5108 from dididy/e2e/upgrade-playwright. Signed-off-by: ChanHo Lee <[email protected]>
1 parent e1495e3 commit 4d444be

File tree

6 files changed

+54
-56
lines changed

6 files changed

+54
-56
lines changed

.github/workflows/frontend.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ jobs:
7575
with:
7676
distribution: 'temurin'
7777
java-version: 11
78+
- name: Cache Playwright browsers
79+
uses: actions/cache@v4
80+
with:
81+
path: ~/.cache/ms-playwright
82+
key: ${{ runner.os }}-playwright-${{ hashFiles('zeppelin-web-angular/package-lock.json') }}
83+
restore-keys: |
84+
${{ runner.os }}-playwright-
7885
- name: Cache local Maven repository
7986
uses: actions/cache@v4
8087
with:

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test.describe('Dark Mode Theme Switching', () => {
2020

2121
test.beforeEach(async ({ page }) => {
2222
themePage = new ThemePage(page);
23-
await page.goto('/', { waitUntil: 'load' });
23+
await page.goto('/');
2424
await waitForZeppelinReady(page);
2525

2626
// Handle authentication if shiro.ini exists
@@ -30,7 +30,9 @@ 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 }) => {
33+
test('Scenario: User can switch to dark mode and persistence is maintained', async ({ page, context }) => {
34+
let currentPage = page;
35+
3436
// GIVEN: User is on the main page, which starts in 'system' mode by default (localStorage cleared).
3537
await test.step('GIVEN the page starts in system mode', async () => {
3638
await themePage.assertSystemTheme(); // Robot icon for system theme
@@ -47,19 +49,20 @@ test.describe('Dark Mode Theme Switching', () => {
4749
// WHEN: User switches to dark mode by setting localStorage and reloading.
4850
await test.step('WHEN the user switches to dark mode', async () => {
4951
await themePage.setThemeInLocalStorage('dark');
50-
await page.reload();
51-
await waitForZeppelinReady(page);
52-
});
52+
const newPage = await context.newPage();
53+
await newPage.goto(currentPage.url());
54+
await waitForZeppelinReady(newPage);
5355

54-
// THEN: The theme changes to dark mode.
55-
await test.step('THEN the page switches to dark mode', async () => {
56+
// Update themePage to use newPage and verify dark mode
57+
themePage = new ThemePage(newPage);
58+
currentPage = newPage;
5659
await themePage.assertDarkTheme();
5760
});
5861

5962
// AND: User refreshes the page.
6063
await test.step('AND the user refreshes the page', async () => {
61-
await page.reload();
62-
await waitForZeppelinReady(page);
64+
await currentPage.reload();
65+
await waitForZeppelinReady(currentPage);
6366
});
6467

6568
// THEN: Dark mode is maintained after refresh.
@@ -84,7 +87,7 @@ test.describe('Dark Mode Theme Switching', () => {
8487

8588
await test.step('GIVEN: No localStorage, System preference is Light', async () => {
8689
await page.emulateMedia({ colorScheme: 'light' });
87-
await page.goto('/', { waitUntil: 'load' });
90+
await page.goto('/');
8891
await waitForZeppelinReady(page);
8992
// When no explicit theme is set, it defaults to 'system' mode
9093
// Even in system mode with light preference, the icon should be robot
@@ -95,23 +98,23 @@ test.describe('Dark Mode Theme Switching', () => {
9598

9699
await test.step('GIVEN: No localStorage, System preference is Dark (initial system state)', async () => {
97100
await themePage.setThemeInLocalStorage('system');
98-
await page.goto('/', { waitUntil: 'load' });
101+
await page.goto('/');
99102
await waitForZeppelinReady(page);
100103
await themePage.assertSystemTheme(); // Robot icon for system theme
101104
});
102105

103106
await test.step("GIVEN: localStorage is 'dark', System preference is Light", async () => {
104107
await themePage.setThemeInLocalStorage('dark');
105108
await page.emulateMedia({ colorScheme: 'light' });
106-
await page.goto('/', { waitUntil: 'load' });
109+
await page.goto('/');
107110
await waitForZeppelinReady(page);
108111
await themePage.assertDarkTheme(); // localStorage should override system
109112
});
110113

111114
await test.step("GIVEN: localStorage is 'system', THEN: Emulate system preference change to Light", async () => {
112115
await themePage.setThemeInLocalStorage('system');
113116
await page.emulateMedia({ colorScheme: 'light' });
114-
await page.goto('/', { waitUntil: 'load' });
117+
await page.goto('/');
115118
await waitForZeppelinReady(page);
116119
await expect(themePage.rootElement).toHaveClass(/light/);
117120
await expect(themePage.rootElement).toHaveAttribute('data-theme', 'light');
@@ -121,7 +124,7 @@ test.describe('Dark Mode Theme Switching', () => {
121124
await test.step("GIVEN: localStorage is 'system', THEN: Emulate system preference change to Dark", async () => {
122125
await themePage.setThemeInLocalStorage('system');
123126
await page.emulateMedia({ colorScheme: 'dark' });
124-
await page.goto('/', { waitUntil: 'load' });
127+
await page.goto('/');
125128
await waitForZeppelinReady(page);
126129
await expect(themePage.rootElement).toHaveClass(/dark/);
127130
await expect(themePage.rootElement).toHaveAttribute('data-theme', 'dark');

zeppelin-web-angular/package-lock.json

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zeppelin-web-angular/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"scripts": {
55
"prepare": "cd .. && husky",
6-
"postinstall": "npm run build:projects && cd projects/zeppelin-react && npm install",
6+
"postinstall": "npm run build:projects && npx playwright install --with-deps && cd projects/zeppelin-react && npm install",
77
"ng": "./node_modules/.bin/ng",
88
"start": "concurrently \"npm run start:react\" \"npm run start:angular\"",
99
"start:angular": "ng serve --proxy-config proxy.conf.js",
@@ -75,7 +75,7 @@
7575
"@angular/cli": "~13.3.11",
7676
"@angular/compiler-cli": "~13.4.0",
7777
"@angular/language-service": "~13.4.0",
78-
"@playwright/test": "1.53.2",
78+
"@playwright/test": "1.56.1",
7979
"@types/angular": "^1.8.0",
8080
"@types/diff-match-patch": "^1.0.36",
8181
"@types/highlight.js": "^9.12.3",

zeppelin-web-angular/playwright.config.ts renamed to zeppelin-web-angular/playwright.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* limitations under the License.
1111
*/
1212

13-
import { defineConfig, devices } from '@playwright/test';
13+
const { defineConfig, devices } = require('@playwright/test');
1414

1515
// https://playwright.dev/docs/test-configuration
1616
export default defineConfig({
@@ -21,6 +21,10 @@ export default defineConfig({
2121
forbidOnly: !!process.env.CI,
2222
retries: process.env.CI ? 2 : 0,
2323
workers: 4,
24+
timeout: 120000,
25+
expect: {
26+
timeout: 60000
27+
},
2428
reporter: [
2529
[!!process.env.CI ? 'github' : 'list'],
2630
['html', { open: !!process.env.CI ? 'never' : 'always' }],

zeppelin-web-angular/pom.xml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -161,22 +161,6 @@
161161
</goals>
162162
</execution>
163163

164-
<execution>
165-
<id>playwright-install</id>
166-
<phase>pre-integration-test</phase>
167-
<configuration>
168-
<skip>${web.e2e.disabled}</skip>
169-
<target unless="skipTests">
170-
<exec executable="./node/npx" spawn="false">
171-
<arg line="[email protected] install --with-deps" />
172-
</exec>
173-
</target>
174-
</configuration>
175-
<goals>
176-
<goal>run</goal>
177-
</goals>
178-
</execution>
179-
180164
<execution>
181165
<id>stop-zeppelin</id>
182166
<phase>post-integration-test</phase>

0 commit comments

Comments
 (0)