-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64fba1a
commit b91213c
Showing
16 changed files
with
249 additions
and
462 deletions.
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,119 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
export function tests() { | ||
test('save state', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('nes', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await page.getByText('saveState', { exact: true }).click() | ||
const event = await page.waitForEvent('console', (consoleMessage) => consoleMessage.type() === 'info') | ||
const [message] = event.args() | ||
expect(message.toString()).toBe('{state: Blob, thumbnail: Blob}') | ||
}) | ||
|
||
test('load state', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('gbc', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await expect(canvas).toHaveScreenshot('load-state-pristine.png') | ||
|
||
await canvas.press('Enter', { delay: 500 }) | ||
await expect(canvas).toHaveScreenshot('load-state-touched.png') | ||
|
||
await page.getByText('saveState', { exact: true }).click() | ||
await page.waitForEvent('console', (consoleMessage) => consoleMessage.type() === 'info') | ||
|
||
await page.getByText('restart', { exact: true }).click() | ||
await expect(canvas).toHaveScreenshot('load-state-pristine.png') | ||
|
||
await page.getByText('loadState', { exact: true }).click() | ||
await page.waitForTimeout(1000) // loading state can be slow | ||
await expect(canvas).toHaveScreenshot('load-state-touched.png') | ||
}) | ||
|
||
test('restart', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('nes', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await expect(canvas).toHaveScreenshot('restart-pristine.png') | ||
|
||
await canvas.press('Enter', { delay: 500 }) | ||
await expect(canvas).not.toHaveScreenshot('restart-pristine.png') | ||
|
||
await page.getByText('restart', { exact: true }).click() | ||
|
||
await page.waitForTimeout(500) | ||
await expect(canvas).toHaveScreenshot('restart-pristine.png') | ||
}) | ||
|
||
test('pause and resume', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('megadrive', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await canvas.press('Enter', { delay: 800 }) | ||
|
||
await page.getByText('pause', { exact: true }).click() | ||
await expect(canvas).toHaveScreenshot('pause-and-resume.png') | ||
await page.waitForTimeout(500) | ||
await expect(canvas).toHaveScreenshot('pause-and-resume.png') | ||
|
||
await page.getByText('resume', { exact: true }).click() | ||
await page.waitForTimeout(1000) | ||
await expect(canvas).not.toHaveScreenshot('pause-and-resume.png') | ||
}) | ||
|
||
test('press', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('megadrive', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await expect(canvas).toHaveScreenshot('press-pristine.png') | ||
|
||
// show the game info | ||
await page.getByText('pressA', { exact: true }).click() | ||
await page.waitForTimeout(300) | ||
await expect(canvas).toHaveScreenshot('press-a.png') | ||
|
||
// hide the game info | ||
await page.getByText('pressA', { exact: true }).click() | ||
await page.waitForTimeout(300) | ||
await expect(canvas).toHaveScreenshot('press-pristine.png') | ||
|
||
// enter the game | ||
await page.getByText('pressStart', { exact: true }).click() | ||
await page.waitForTimeout(300) | ||
await expect(canvas).toHaveScreenshot('press-start.png') | ||
}) | ||
|
||
test('screenshot', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
const screenshot = page.locator('#screenshot') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('megadrive', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await page.getByText('screenshot', { exact: true }).click() | ||
await expect(screenshot).toHaveScreenshot('screenshot.png') | ||
}) | ||
} |
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 |
---|---|---|
@@ -1,123 +1,10 @@ | ||
import { expect, test } from '@playwright/test' | ||
import { test } from '@playwright/test' | ||
import { tests } from './instance-ra-common' | ||
|
||
test.describe('instance methods with retroarch esm', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto('/tests/e2e/test-page/esm.html') | ||
await page.goto('/tests/e2e/test-page') | ||
}) | ||
|
||
test('save state', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('nes', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await page.getByText('saveState', { exact: true }).click() | ||
const event = await page.waitForEvent('console', (consoleMessage) => consoleMessage.type() === 'info') | ||
const [message] = event.args() | ||
expect(message.toString()).toBe('{state: Blob, thumbnail: Blob}') | ||
}) | ||
|
||
test('load state', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('gbc', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await expect(canvas).toHaveScreenshot('load-state-pristine.png') | ||
|
||
await canvas.press('Enter', { delay: 500 }) | ||
await expect(canvas).toHaveScreenshot('load-state-touched.png') | ||
|
||
await page.getByText('saveState', { exact: true }).click() | ||
await page.waitForEvent('console', (consoleMessage) => consoleMessage.type() === 'info') | ||
|
||
await page.getByText('restart', { exact: true }).click() | ||
await expect(canvas).toHaveScreenshot('load-state-pristine.png') | ||
|
||
await page.getByText('loadState', { exact: true }).click() | ||
await page.waitForTimeout(1000) // loading state can be slow | ||
await expect(canvas).toHaveScreenshot('load-state-touched.png') | ||
}) | ||
|
||
test('restart', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('nes', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await expect(canvas).toHaveScreenshot('restart-pristine.png') | ||
|
||
await canvas.press('Enter', { delay: 500 }) | ||
await expect(canvas).not.toHaveScreenshot('restart-pristine.png') | ||
|
||
await page.getByText('restart', { exact: true }).click() | ||
|
||
await page.waitForTimeout(500) | ||
await expect(canvas).toHaveScreenshot('restart-pristine.png') | ||
}) | ||
|
||
test('pause and resume', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('megadrive', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await canvas.press('Enter', { delay: 800 }) | ||
|
||
await page.getByText('pause', { exact: true }).click() | ||
await expect(canvas).toHaveScreenshot('pause-and-resume.png') | ||
await page.waitForTimeout(500) | ||
await expect(canvas).toHaveScreenshot('pause-and-resume.png') | ||
|
||
await page.getByText('resume', { exact: true }).click() | ||
await page.waitForTimeout(1000) | ||
await expect(canvas).not.toHaveScreenshot('pause-and-resume.png') | ||
}) | ||
|
||
test('press', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('megadrive', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await expect(canvas).toHaveScreenshot('press-pristine.png') | ||
|
||
// show the game info | ||
await page.getByText('pressA', { exact: true }).click() | ||
await page.waitForTimeout(300) | ||
await expect(canvas).toHaveScreenshot('press-a.png') | ||
|
||
// hide the game info | ||
await page.getByText('pressA', { exact: true }).click() | ||
await page.waitForTimeout(300) | ||
await expect(canvas).toHaveScreenshot('press-pristine.png') | ||
|
||
// enter the game | ||
await page.getByText('pressStart', { exact: true }).click() | ||
await page.waitForTimeout(300) | ||
await expect(canvas).toHaveScreenshot('press-start.png') | ||
}) | ||
|
||
test('screenshot', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
const screenshot = page.locator('#screenshot') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('megadrive', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await page.getByText('screenshot', { exact: true }).click() | ||
await expect(screenshot).toHaveScreenshot('screenshot.png') | ||
}) | ||
tests() | ||
}) |
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 |
---|---|---|
@@ -1,123 +1,10 @@ | ||
import { expect, test } from '@playwright/test' | ||
import { test } from '@playwright/test' | ||
import { tests } from './instance-ra-common' | ||
|
||
test.describe('instance methods with retroarch legacy', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto('/tests/e2e/test-page/legacy.html') | ||
await page.goto('/tests/e2e/test-page?legacy') | ||
}) | ||
|
||
test('save state', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('nes', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await page.getByText('saveState', { exact: true }).click() | ||
const event = await page.waitForEvent('console', (consoleMessage) => consoleMessage.type() === 'info') | ||
const [message] = event.args() | ||
expect(message.toString()).toBe('{state: Blob, thumbnail: Blob}') | ||
}) | ||
|
||
test('load state', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('gbc', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await expect(canvas).toHaveScreenshot('load-state-pristine.png') | ||
|
||
await canvas.press('Enter', { delay: 500 }) | ||
await expect(canvas).toHaveScreenshot('load-state-touched.png') | ||
|
||
await page.getByText('saveState', { exact: true }).click() | ||
await page.waitForEvent('console', (consoleMessage) => consoleMessage.type() === 'info') | ||
|
||
await page.getByText('restart', { exact: true }).click() | ||
await expect(canvas).toHaveScreenshot('load-state-pristine.png') | ||
|
||
await page.getByText('loadState', { exact: true }).click() | ||
await page.waitForTimeout(1000) // loading state can be slow | ||
await expect(canvas).toHaveScreenshot('load-state-touched.png') | ||
}) | ||
|
||
test('restart', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('nes', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await expect(canvas).toHaveScreenshot('restart-pristine.png') | ||
|
||
await canvas.press('Enter', { delay: 500 }) | ||
await expect(canvas).not.toHaveScreenshot('restart-pristine.png') | ||
|
||
await page.getByText('restart', { exact: true }).click() | ||
|
||
await page.waitForTimeout(500) | ||
await expect(canvas).toHaveScreenshot('restart-pristine.png') | ||
}) | ||
|
||
test('pause and resume', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('megadrive', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await canvas.press('Enter', { delay: 800 }) | ||
|
||
await page.getByText('pause', { exact: true }).click() | ||
await expect(canvas).toHaveScreenshot('pause-and-resume.png') | ||
await page.waitForTimeout(500) | ||
await expect(canvas).toHaveScreenshot('pause-and-resume.png') | ||
|
||
await page.getByText('resume', { exact: true }).click() | ||
await page.waitForTimeout(1000) | ||
await expect(canvas).not.toHaveScreenshot('pause-and-resume.png') | ||
}) | ||
|
||
test('press', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('megadrive', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await expect(canvas).toHaveScreenshot('press-pristine.png') | ||
|
||
// show the game info | ||
await page.getByText('pressA', { exact: true }).click() | ||
await page.waitForTimeout(300) | ||
await expect(canvas).toHaveScreenshot('press-a.png') | ||
|
||
// hide the game info | ||
await page.getByText('pressA', { exact: true }).click() | ||
await page.waitForTimeout(300) | ||
await expect(canvas).toHaveScreenshot('press-pristine.png') | ||
|
||
// enter the game | ||
await page.getByText('pressStart', { exact: true }).click() | ||
await page.waitForTimeout(300) | ||
await expect(canvas).toHaveScreenshot('press-start.png') | ||
}) | ||
|
||
test('screenshot', async ({ page }) => { | ||
const canvas = page.locator('#canvas') | ||
const screenshot = page.locator('#screenshot') | ||
await expect(canvas).not.toBeAttached() | ||
|
||
await page.getByText('megadrive', { exact: true }).click() | ||
await page.waitForLoadState('networkidle') | ||
await page.waitForTimeout(500) | ||
|
||
await page.getByText('screenshot', { exact: true }).click() | ||
await expect(screenshot).toHaveScreenshot('screenshot.png') | ||
}) | ||
tests() | ||
}) |
Oops, something went wrong.