Some checks failed
Add auth setup project, viewer session check, upload that posts a fixture, FastAPI login spec (skips without E2E_API_*), and repo ROADMAP.md.
47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
import { assertPublicHost, waitForUrlHost } from '@levkin/playkit';
|
|
import path from 'node:path';
|
|
import { test, expect } from '../fixtures';
|
|
|
|
const tinyPng = path.join(__dirname, '../fixtures/tiny.png');
|
|
|
|
test.describe('upload @smoke', () => {
|
|
test.use({ storageState: path.join(__dirname, '../.auth/admin.json') });
|
|
|
|
test('authenticated user can select a file and POST upload', async ({
|
|
page,
|
|
playkitConfig,
|
|
timings,
|
|
}) => {
|
|
assertPublicHost(playkitConfig.baseUrl);
|
|
|
|
await timings.measure('open_upload', async () => {
|
|
await page.goto(`${playkitConfig.baseUrl}/upload`);
|
|
await waitForUrlHost(page, playkitConfig.expectedHost);
|
|
});
|
|
|
|
expect(new URL(page.url()).pathname).toMatch(/\/upload/);
|
|
await expect(page.getByLabel('Account menu')).toBeVisible({ timeout: 20_000 });
|
|
|
|
await timings.measure('upload_file', async () => {
|
|
await page.locator('#file-upload').setInputFiles(tinyPng);
|
|
await expect(page.getByText(/tiny\.png/i).first()).toBeVisible({ timeout: 15_000 });
|
|
const submit = page.getByRole('button', { name: /Submit for Review/i });
|
|
await expect(submit).toBeEnabled({ timeout: 15_000 });
|
|
|
|
const uploadRespPromise = page.waitForResponse(
|
|
(r) => r.url().includes('/api/photos/upload') && r.request().method() === 'POST',
|
|
{ timeout: 60_000 },
|
|
);
|
|
await submit.click();
|
|
const uploadResp = await uploadRespPromise;
|
|
expect(uploadResp.request().method()).toBe('POST');
|
|
|
|
// Success banner or inline error/alert — either proves the submit path ran.
|
|
const outcome = page
|
|
.getByText(/submitted successfully|failed|error|not authorized|permission/i)
|
|
.first();
|
|
await expect(outcome).toBeVisible({ timeout: 30_000 });
|
|
});
|
|
});
|
|
});
|