Skip to content

Commit d4d19d1

Browse files
authored
[FIX] Broken behavior of webview back arrow (#3587)
* Fix webview back arrow for webview history * Add e2e test
1 parent 43423e3 commit d4d19d1

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

e2e/webview_controls.spec.ts

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { expect, test } from '@playwright/test'
2+
import { electronTest } from './helpers'
3+
import { WebviewTag } from 'electron'
4+
5+
electronTest('webview', async (app) => {
6+
const page = await app.firstWindow()
7+
8+
await test.step('goes back and forth inside webview and also to heroic screens', async () => {
9+
// we have to do this or it fails, the icon also has the same text
10+
await page.locator('span').filter({ hasText: 'Documentation' }).click()
11+
12+
// we have to wait a bit for the webview to properly load these urls
13+
// it's not great to force a sleep, but without these it's too flaky
14+
await page.waitForTimeout(300)
15+
16+
await expect(page.locator('.WebviewControls__urlInput')).toHaveAttribute(
17+
'value',
18+
'https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/wiki'
19+
)
20+
await page.waitForTimeout(300)
21+
22+
// we have to force a src change since we can't really click something reliably
23+
// inside the webview programatically
24+
await page.$eval(
25+
'webview',
26+
(el: WebviewTag) => (el.src = 'https://www.google.com/')
27+
)
28+
await page.waitForTimeout(300)
29+
30+
await expect(page.locator('.WebviewControls__urlInput')).toHaveAttribute(
31+
'value',
32+
'https://www.google.com/'
33+
)
34+
35+
// go back to previous page in webview's history
36+
await page.getByTitle('Go back').click()
37+
await expect(page.locator('.WebviewControls__urlInput')).toHaveAttribute(
38+
'value',
39+
'https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/wiki'
40+
)
41+
42+
// go forward again to google.com
43+
await page.getByTitle('Go forward').click()
44+
await expect(page.locator('.WebviewControls__urlInput')).toHaveAttribute(
45+
'value',
46+
'https://www.google.com/'
47+
)
48+
49+
// go back twice to end up in the library
50+
await page.getByTitle('Go back').click()
51+
await page.getByTitle('Go back').click()
52+
await expect(page.getByText('All Games')).toBeVisible()
53+
})
54+
})

src/frontend/components/UI/WebviewControls/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default function WebviewControls({
7979
console.error(error)
8080
}
8181
},
82-
[webview]
82+
[webview, webviewGoBack]
8383
)
8484

8585
return (

0 commit comments

Comments
 (0)