bemusic/bemuse

View on GitHub
e2e/tests/options.spec.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { expect, test } from '@playwright/test'

test('Options can be saved', async ({ page }) => {
  await page.goto('/')
  await page.getByTestId('enter-game').click()
  await page.getByTestId('keyboard-mode').click()
  await page.getByTestId('options-button').click()

  const getButton = (index: number) =>
    page.locator(`[data-testid="options-input-key"][data-n="${index + 1}"]`)

  getButton(0).click()

  for (const [index, key] of Array.from('qwertyu').entries()) {
    const button = getButton(index)
    await expect(button).toHaveAttribute('data-editing', 'true')
    await page.keyboard.down(key)
    await expect(button).toHaveAttribute('data-editing', 'false')
    await page.keyboard.up(key)
  }

  await page.reload()
  await page.getByTestId('enter-game').click()
  await page.getByTestId('keyboard-mode').click()
  await page.getByTestId('options-button').click()
  for (const [index, key] of Array.from('QWERTYU').entries()) {
    const button = getButton(index)
    await expect(button).toContainText(key)
  }
})

test('Speed can be increased', async ({ page }) => {
  await page.goto('/')
  await page.getByTestId('enter-game').click()
  await page.getByTestId('keyboard-mode').click()
  await page.getByTestId('options-button').click()
  expect(await page.locator('.OptionsSpeed > input').inputValue()).toBe('1.0')
  await page.locator('.OptionsSpeedのplus > button').click()
  expect(await page.locator('.OptionsSpeed > input').inputValue()).toBe('1.5')
})