openreader/tests/upload.spec.ts
2025-03-04 22:47:37 -07:00

43 lines
No EOL
1.8 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { test, expect } from '@playwright/test';
import { uploadFile, uploadAndDisplay, setupTest } from './helpers';
test.describe('Document Upload Tests', () => {
test.beforeEach(async ({ page }) => {
await setupTest(page);
});
test('uploads a PDF document', async ({ page }) => {
await uploadFile(page, 'sample.pdf');
await expect(page.getByText('sample.pdf')).toBeVisible({ timeout: 10000 });
});
test('uploads an EPUB document', async ({ page }) => {
await uploadFile(page, 'sample.epub');
await expect(page.getByText('sample.epub')).toBeVisible({ timeout: 10000 });
});
test('uploads and converts a DOCX document', async ({ page }) => {
// This test only runs in development mode
test.skip(process.env.NODE_ENV === 'production', 'DOCX upload is only available in development mode');
await uploadFile(page, 'sample.docx');
// Should see the converting message
await expect(page.getByText('Converting DOCX to PDF...')).toBeVisible();
// After conversion, should see the PDF with the same name
await expect(page.getByText('sample.pdf')).toBeVisible({ timeout: 15000 });
});
test('displays a PDF document', async ({ page }) => {
await uploadAndDisplay(page, 'sample.pdf');
await expect(page.locator('.react-pdf__Document')).toBeVisible();
await expect(page.locator('.react-pdf__Page')).toBeVisible();
await expect(page.getByText('Sample PDF')).toBeVisible();
});
test('displays an EPUB document', async ({ page }) => {
await uploadAndDisplay(page, 'sample.epub');
await expect(page.locator('.epub-container')).toBeVisible({ timeout: 10000 });
await expect(page.getByRole('button', { name: '' })).toBeVisible();
await expect(page.getByRole('button', { name: '' })).toBeVisible();
});
});