test(e2e): replace E2E_BASE_URL absolute URL construction with relative paths
All page.goto() calls in documents.spec.ts now use relative paths (/documents/{id})
so Playwright's configured baseURL is the single source of truth. Removes the
fragility of keeping process.env.E2E_BASE_URL in sync with playwright.config.ts.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -209,8 +209,6 @@ test.describe('PDF viewer', () => {
|
|||||||
let noFileDocHref: string;
|
let noFileDocHref: string;
|
||||||
|
|
||||||
test.beforeAll(async ({ request }) => {
|
test.beforeAll(async ({ request }) => {
|
||||||
const baseURL = process.env.E2E_BASE_URL ?? 'http://localhost:3000';
|
|
||||||
|
|
||||||
// Create a document with a PDF file.
|
// Create a document with a PDF file.
|
||||||
const createRes = await request.post('/api/documents', {
|
const createRes = await request.post('/api/documents', {
|
||||||
multipart: { title: 'E2E PDF Viewer Test' }
|
multipart: { title: 'E2E PDF Viewer Test' }
|
||||||
@@ -229,7 +227,7 @@ test.describe('PDF viewer', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!uploadRes.ok()) throw new Error(`Upload PDF failed: ${uploadRes.status()}`);
|
if (!uploadRes.ok()) throw new Error(`Upload PDF failed: ${uploadRes.status()}`);
|
||||||
pdfDocHref = `${baseURL}/documents/${doc.id}`;
|
pdfDocHref = `/documents/${doc.id}`;
|
||||||
|
|
||||||
// Create a document WITHOUT a file — used to verify no canvas is rendered.
|
// Create a document WITHOUT a file — used to verify no canvas is rendered.
|
||||||
const noFileRes = await request.post('/api/documents', {
|
const noFileRes = await request.post('/api/documents', {
|
||||||
@@ -237,7 +235,7 @@ test.describe('PDF viewer', () => {
|
|||||||
});
|
});
|
||||||
if (!noFileRes.ok()) throw new Error(`Create no-file document failed: ${noFileRes.status()}`);
|
if (!noFileRes.ok()) throw new Error(`Create no-file document failed: ${noFileRes.status()}`);
|
||||||
const noFileDoc = await noFileRes.json();
|
const noFileDoc = await noFileRes.json();
|
||||||
noFileDocHref = `${baseURL}/documents/${noFileDoc.id}`;
|
noFileDocHref = `/documents/${noFileDoc.id}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
test('PDF renders in the custom viewer — canvas is present instead of iframe', async ({
|
test('PDF renders in the custom viewer — canvas is present instead of iframe', async ({
|
||||||
@@ -306,8 +304,7 @@ test.describe('PDF annotations — admin', () => {
|
|||||||
});
|
});
|
||||||
if (!uploadRes.ok()) throw new Error(`Upload PDF failed: ${uploadRes.status()}`);
|
if (!uploadRes.ok()) throw new Error(`Upload PDF failed: ${uploadRes.status()}`);
|
||||||
|
|
||||||
const baseURL = process.env.E2E_BASE_URL ?? 'http://localhost:3000';
|
annotationDocHref = `/documents/${doc.id}`;
|
||||||
annotationDocHref = `${baseURL}/documents/${doc.id}`;
|
|
||||||
sharedAnnotationDocId = doc.id;
|
sharedAnnotationDocId = doc.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -404,7 +401,6 @@ test.describe('PDF annotations — admin', () => {
|
|||||||
// ─── PDF Annotations — file hash (version awareness) ─────────────────────────
|
// ─── PDF Annotations — file hash (version awareness) ─────────────────────────
|
||||||
|
|
||||||
test.describe('PDF annotations — file hash versioning', () => {
|
test.describe('PDF annotations — file hash versioning', () => {
|
||||||
const baseURL = process.env.E2E_BASE_URL ?? 'http://localhost:3000';
|
|
||||||
const PDF_FIXTURE2 = path.resolve(__dirname, 'fixtures/minimal2.pdf');
|
const PDF_FIXTURE2 = path.resolve(__dirname, 'fixtures/minimal2.pdf');
|
||||||
|
|
||||||
test('annotations are hidden after a different file is uploaded', async ({ page, request }) => {
|
test('annotations are hidden after a different file is uploaded', async ({ page, request }) => {
|
||||||
@@ -436,7 +432,7 @@ test.describe('PDF annotations — file hash versioning', () => {
|
|||||||
if (!annotRes.ok()) throw new Error(`Create annotation failed: ${annotRes.status()}`);
|
if (!annotRes.ok()) throw new Error(`Create annotation failed: ${annotRes.status()}`);
|
||||||
|
|
||||||
// 3. Verify annotation appears before re-upload
|
// 3. Verify annotation appears before re-upload
|
||||||
await page.goto(`${baseURL}/documents/${doc.id}`);
|
await page.goto(`/documents/${doc.id}`);
|
||||||
await page.waitForSelector('[data-hydrated]');
|
await page.waitForSelector('[data-hydrated]');
|
||||||
await page.locator('canvas').first().waitFor({ state: 'visible', timeout: 20000 });
|
await page.locator('canvas').first().waitFor({ state: 'visible', timeout: 20000 });
|
||||||
await expect(page.locator('[data-testid^="annotation-"]').first()).toBeVisible({
|
await expect(page.locator('[data-testid^="annotation-"]').first()).toBeVisible({
|
||||||
@@ -520,7 +516,7 @@ test.describe('PDF annotations — file hash versioning', () => {
|
|||||||
if (!restoreRes.ok()) throw new Error(`Restore failed: ${restoreRes.status()}`);
|
if (!restoreRes.ok()) throw new Error(`Restore failed: ${restoreRes.status()}`);
|
||||||
|
|
||||||
// 5. Verify annotation reappears and notice is gone
|
// 5. Verify annotation reappears and notice is gone
|
||||||
await page.goto(`${baseURL}/documents/${doc.id}`);
|
await page.goto(`/documents/${doc.id}`);
|
||||||
await page.waitForSelector('[data-hydrated]');
|
await page.waitForSelector('[data-hydrated]');
|
||||||
await page.locator('canvas').first().waitFor({ state: 'visible', timeout: 20000 });
|
await page.locator('canvas').first().waitFor({ state: 'visible', timeout: 20000 });
|
||||||
|
|
||||||
@@ -548,8 +544,7 @@ test.describe('PDF annotations — read-only user', () => {
|
|||||||
await page.waitForURL('/');
|
await page.waitForURL('/');
|
||||||
|
|
||||||
// Navigate directly to the PDF document created by the admin beforeAll.
|
// Navigate directly to the PDF document created by the admin beforeAll.
|
||||||
const baseURL = process.env.E2E_BASE_URL ?? 'http://localhost:3000';
|
await page.goto(`/documents/${sharedAnnotationDocId}`);
|
||||||
await page.goto(`${baseURL}/documents/${sharedAnnotationDocId}`);
|
|
||||||
await page.waitForSelector('[data-hydrated]');
|
await page.waitForSelector('[data-hydrated]');
|
||||||
|
|
||||||
// Reader users do not have ANNOTATE_ALL permission — the button must not be shown at all.
|
// Reader users do not have ANNOTATE_ALL permission — the button must not be shown at all.
|
||||||
|
|||||||
Reference in New Issue
Block a user