Files
caddy-proxy-manager/tests/e2e/api-docs.spec.ts
akanealw 99819b70ff
Some checks failed
Build and Push Docker Images (Trusted) / build-and-push (., docker/caddy/Dockerfile, caddy) (push) Has been cancelled
Build and Push Docker Images (Trusted) / build-and-push (., docker/l4-port-manager/Dockerfile, l4-port-manager) (push) Has been cancelled
Build and Push Docker Images (Trusted) / build-and-push (., docker/web/Dockerfile, web) (push) Has been cancelled
Tests / test (push) Has been cancelled
added caddy-proxy-manager for testing
2026-04-21 22:49:08 +00:00

41 lines
1.4 KiB
TypeScript
Executable File

/**
* E2E tests: API Docs page (OpenAPI / Swagger UI).
*
* Verifies the page loads and Swagger UI renders the OpenAPI spec.
* The page requires admin role.
*/
import { test, expect } from '@playwright/test';
test.describe('API Docs page', () => {
test('page loads without error', async ({ page }) => {
await page.goto('/api-docs');
await expect(page).not.toHaveURL(/login/);
});
test('Swagger UI container is present on the page', async ({ page }) => {
await page.goto('/api-docs');
// The ApiDocsClient renders a div that Swagger UI mounts into.
// The CDN script may be blocked in test environments, so just verify
// the page loaded without error and the mount container exists.
await expect(page.locator('main')).toBeVisible({ timeout: 10_000 });
});
test('OpenAPI spec endpoint returns valid JSON', async ({ request }) => {
const response = await request.get('/api/v1/openapi.json');
expect(response.status()).toBe(200);
const body = await response.json();
expect(body).toHaveProperty('openapi');
expect(body).toHaveProperty('paths');
});
});
test.describe('API Docs page — unauthenticated access', () => {
test.use({ storageState: { cookies: [], origins: [] } });
test('unauthenticated access to /api-docs redirects to /login', async ({ page }) => {
await page.goto('/api-docs');
await expect(page).toHaveURL(/\/login/);
});
});