Skip to content

Commit

Permalink
fix: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arianrhodsandlot committed Oct 15, 2023
1 parent 595ffcc commit 94bf243
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 29 deletions.
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"name": "retro-assembly",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"build": "vite build",
"dev-test": "playwright test -c tests/e2e --headed --ui",
"dev:test": "playwright test -c tests/e2e --headed --ui",
"dev": "vite",
"lint": "eslint src",
"prepare-test": "node ./scripts/prepare-test.js",
Expand Down Expand Up @@ -36,7 +34,7 @@
"ky": "1.0.1",
"lodash-es": "4.17.21",
"mitt": "3.0.1",
"nostalgist": "0.4.0",
"nostalgist": "0.4.1",
"p-queue": "7.4.1",
"path-browserify": "1.0.1",
"query-string": "8.1.0",
Expand Down Expand Up @@ -68,7 +66,7 @@
"@types/wicg-file-system-access": "2023.10.1",
"@vitejs/plugin-react-swc": "3.4.0",
"autoprefixer": "10.4.16",
"browserfs": "^1.4.3",
"browserfs": "1.4.3",
"eslint": "8.51.0",
"is-ci": "3.0.1",
"mkdirp": "3.0.1",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 4 additions & 11 deletions src/core/classes/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@ interface EmulatorConstructorOptions {
}

const defaultStyle = {
backgroundColor: 'black',
backgroundImage:
'repeating-linear-gradient(45deg, #000 25%, transparent 25%, transparent 75%, #000 75%, #000), repeating-linear-gradient(45deg, #000 25%, #222 25%, #222 75%, #000 75%, #000)',
backgroundPosition: '0 0,15px 15px',
backgroundSize: '30px 30px',
cursor: 'default',
display: 'block',
imageRendering: 'pixelated', // this boosts performance!
inset: '0',
maxHeight: '100%',
maxWidth: '100%',
position: 'fixed',
inset: '0',
height: '100%',
width: '100%',
zIndex: '10',
}

Expand Down Expand Up @@ -60,14 +57,9 @@ export class Emulator {
this.additionalFiles = additionalFiles
this.core = core ?? ''
this.canvas = document.createElement('canvas')
this.canvas.id = 'canvas'
this.canvas.width = 900
this.canvas.height = 900
this.previousActiveElement = document.activeElement
this.canvas.tabIndex = 0
this.coreConfig = coreConfig
this.retroarchConfig = retroarchConfig
this.canvas.dataset.testid = 'emulator'
this.style = { ...defaultStyle, ...style }

this.resizeCanvas = this.resizeCanvas.bind(this)
Expand All @@ -92,6 +84,7 @@ export class Emulator {

this.nostalgist = await Nostalgist.launch({
style: this.style,
element: this.canvas,
core: this.core,
rom: [
{ fileName, fileContent },
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/homepage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test('navigate systems', async ({ page }) => {

test('launch game', async ({ page }) => {
const gameEntryButton = page.getByTestId('game-entry-button')
const emulator = page.getByTestId('emulator')
const emulator = page.locator('#canvas')
await expect(emulator).not.toBeAttached()

await gameEntryButton.click()
Expand Down
12 changes: 6 additions & 6 deletions tests/e2e/menu-overlay.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test.beforeEach(async ({ page }) => {
await expect(dialog).not.toBeVisible()

await page.getByTestId('game-entry-button').click()
await page.getByTestId('emulator').waitFor()
await page.locator('#canvas').waitFor()
})

test('open and close menu overlay', async ({ page }) => {
Expand All @@ -50,7 +50,7 @@ test('open and close menu overlay', async ({ page }) => {

test('resume', async ({ page }) => {
const menuOverlay = page.getByTestId('menu-overlay')
const emulator = page.getByTestId('emulator')
const emulator = page.locator('#canvas')

await page.keyboard.press('Escape')
await expect(menuOverlay).toBeVisible()
Expand All @@ -62,7 +62,7 @@ test('resume', async ({ page }) => {

test('restart', async ({ page }) => {
const menuOverlay = page.getByTestId('menu-overlay')
const emulator = page.getByTestId('emulator')
const emulator = page.locator('#canvas')

await page.keyboard.press('Escape')
await page.getByTestId('menu-item-restart').click()
Expand All @@ -76,7 +76,7 @@ test('save state', async ({ page }) => {
})

const menuOverlay = page.getByTestId('menu-overlay')
const emulator = page.getByTestId('emulator')
const emulator = page.locator('#canvas')
const loadingScreen = page.getByTestId('loading-screen')

await expect(loadingScreen).not.toBeAttached()
Expand All @@ -93,7 +93,7 @@ test('save state', async ({ page }) => {

test('load state', async ({ page }) => {
const menuOverlay = page.getByTestId('menu-overlay')
const emulator = page.getByTestId('emulator')
const emulator = page.locator('#canvas')

await page.keyboard.press('Escape')
await page.getByTestId('menu-item-load-state').click()
Expand All @@ -108,7 +108,7 @@ test('save and exit', async ({ page }) => {
})

const menuOverlay = page.getByTestId('menu-overlay')
const emulator = page.getByTestId('emulator')
const emulator = page.locator('#canvas')
const loadingScreen = page.getByTestId('loading-screen')

await expect(loadingScreen).not.toBeAttached()
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/single-rom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, test } from '@playwright/test'
test('play a single ROM file', async ({ page }) => {
await page.goto('/')

const emulator = page.getByTestId('emulator')
const emulator = page.locator('#canvas')
await expect(emulator).not.toBeAttached()

const fileChooserPromise = page.waitForEvent('filechooser')
Expand Down

0 comments on commit 94bf243

Please sign in to comment.