-
-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] Broken behavior of webview back arrow (#3587)
* Fix webview back arrow for webview history * Add e2e test
- Loading branch information
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { expect, test } from '@playwright/test' | ||
import { electronTest } from './helpers' | ||
import { WebviewTag } from 'electron' | ||
|
||
electronTest('webview', async (app) => { | ||
const page = await app.firstWindow() | ||
|
||
await test.step('goes back and forth inside webview and also to heroic screens', async () => { | ||
// we have to do this or it fails, the icon also has the same text | ||
await page.locator('span').filter({ hasText: 'Documentation' }).click() | ||
|
||
// we have to wait a bit for the webview to properly load these urls | ||
// it's not great to force a sleep, but without these it's too flaky | ||
await page.waitForTimeout(300) | ||
|
||
await expect(page.locator('.WebviewControls__urlInput')).toHaveAttribute( | ||
'value', | ||
'https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/wiki' | ||
) | ||
await page.waitForTimeout(300) | ||
|
||
// we have to force a src change since we can't really click something reliably | ||
// inside the webview programatically | ||
await page.$eval( | ||
'webview', | ||
(el: WebviewTag) => (el.src = 'https://www.google.com/') | ||
) | ||
await page.waitForTimeout(300) | ||
|
||
await expect(page.locator('.WebviewControls__urlInput')).toHaveAttribute( | ||
'value', | ||
'https://www.google.com/' | ||
) | ||
|
||
// go back to previous page in webview's history | ||
await page.getByTitle('Go back').click() | ||
await expect(page.locator('.WebviewControls__urlInput')).toHaveAttribute( | ||
'value', | ||
'https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/wiki' | ||
) | ||
|
||
// go forward again to google.com | ||
await page.getByTitle('Go forward').click() | ||
await expect(page.locator('.WebviewControls__urlInput')).toHaveAttribute( | ||
'value', | ||
'https://www.google.com/' | ||
) | ||
|
||
// go back twice to end up in the library | ||
await page.getByTitle('Go back').click() | ||
await page.getByTitle('Go back').click() | ||
await expect(page.getByText('All Games')).toBeVisible() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters