openreader/tests/play.spec.ts
Richard Roberson 21870ed576 fix(api): stabilize DOCX to PDF conversion and cleanup
- Isolate concurrent LibreOffice runs with per-job profile directories
  (soffice -env:UserInstallation) and per-job temp folders
- Poll for generated PDF and verify stable file size before reading
- Consolidate temp artifacts under docstore/tmp and clean up via rm -r
- Add headless/nologo flags and improve error handling

ui(accessibility):
- ConfirmDialog exposes proper dialog roles
- DocumentFolder toggle adds type, aria-expanded, aria-controls, and title;
  associate content panel with an id
- HTMLViewer wraps content in .html-container for HTML/TXT views

test: add comprehensive Playwright specs and helpers
- Accessibility, API health, deletion flows, folders, navigation, playback,
  and upload scenarios
- Add sample.md and unsupported.xyz; update sample.pdf; extend helpers

ci: run Playwright workflow on version1.0.0 branch
2025-11-12 16:21:11 -07:00

73 lines
No EOL
2.3 KiB
TypeScript

import { test, expect } from '@playwright/test';
import {
setupTest,
playTTSAndWaitForASecond,
pauseTTSAndVerify,
openVoicesMenu,
selectVoiceAndAssertPlayback,
changeNativeSpeedAndAssert,
expectMediaState,
} from './helpers';
test.describe('Play/Pause Tests', () => {
test.beforeEach(async ({ page }) => {
await setupTest(page);
});
test.describe.configure({ mode: 'serial' });
test('plays and pauses TTS for a PDF document', async ({ page }) => {
// Play TTS for the PDF document
await playTTSAndWaitForASecond(page, 'sample.pdf');
// Pause TTS and verify paused state
await pauseTTSAndVerify(page);
});
test('plays and pauses TTS for an EPUB document', async ({ page }) => {
// Play TTS for the EPUB document
await playTTSAndWaitForASecond(page, 'sample.epub');
// Pause TTS and verify paused state
await pauseTTSAndVerify(page);
});
test('plays and pauses TTS for an DOCX document', async ({ page }) => {
// Play TTS for the DOCX document
await playTTSAndWaitForASecond(page, 'sample.docx');
// Pause TTS and verify paused state
await pauseTTSAndVerify(page);
});
test('plays and pauses TTS for a TXT document', async ({ page }) => {
// Play TTS for the TXT document
await playTTSAndWaitForASecond(page, 'sample.txt');
// Pause TTS and verify paused state
await pauseTTSAndVerify(page);
});
test('loads voices and switches voice with processing state then resumes play', async ({ page }) => {
// Start playback
await playTTSAndWaitForASecond(page, 'sample.pdf');
// Ensure basic TTS controls are present
await expect(page.getByRole('button', { name: 'Skip backward' })).toBeVisible();
await expect(page.getByRole('button', { name: 'Skip forward' })).toBeVisible();
// Open voices list and assert options render
await openVoicesMenu(page);
const options = page.getByRole('option');
expect(await options.count()).toBeGreaterThan(0);
// Switch to the first available voice and assert processing -> playing
await selectVoiceAndAssertPlayback(page, /.*/);
});
test('changing TTS native speed toggles processing and returns to playing', async ({ page }) => {
await playTTSAndWaitForASecond(page, 'sample.pdf');
await changeNativeSpeedAndAssert(page, 1.5);
await expectMediaState(page, 'playing');
});
});