|
| 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 | +}) |
0 commit comments