Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Broken behavior of webview back arrow #3587

Merged
merged 2 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions e2e/webview_controls.spec.ts
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()
})
})
2 changes: 1 addition & 1 deletion src/frontend/components/UI/WebviewControls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function WebviewControls({
console.error(error)
}
},
[webview]
[webview, webviewGoBack]
)

return (
Expand Down
Loading