Fix Playwright BASE_URL handling and failed UAT report tests

This commit is contained in:
A R R R Associates
2026-06-26 20:38:14 +05:30
parent 21c90749fb
commit ce9935c684
21 changed files with 98 additions and 53 deletions
+9 -8
View File
@@ -25,6 +25,7 @@
const { test, expect } = require('@playwright/test');
require('dotenv').config();
const { BASE_URL, absoluteUrl } = require('../fixtures/url');
const { login } = require('../fixtures/auth');
const { expectNoBackendError, readBody, blockedOrNotFound, uploadPath } = require('../fixtures/v204-helpers');
const { expectBlockedOrSafe } = require('../fixtures/assertions');
@@ -92,7 +93,7 @@ test.describe('CONS: Consultant portal', () => {
test('[V25-CONS-007] CONS-007 Conversion request review CSRF-less POST is rejected', async ({ request }) => {
skipIfMissing('CONVERSION_REQUEST_ID');
const resp = await request.post(
`${process.env.BASE_URL}/consultants/conversion-requests/${idOr('CONVERSION_REQUEST_ID')}/review`,
`${BASE_URL}/consultants/conversion-requests/${idOr('CONVERSION_REQUEST_ID')}/review`,
{ form: { decision: 'approve', csrf_token: '' } }
).catch(() => null);
if (!resp || [404, 405].includes(resp.status())) test.skip(true, 'Route not available');
@@ -115,7 +116,7 @@ test.describe('CONS: Consultant portal', () => {
test('[V25-CONS-010] CONS-010 Service request status update CSRF-less POST is rejected', async ({ request }) => {
skipIfMissing('SERVICE_REQUEST_ID');
const resp = await request.post(
`${process.env.BASE_URL}/consultants/service-requests/${idOr('SERVICE_REQUEST_ID')}/status`,
`${BASE_URL}/consultants/service-requests/${idOr('SERVICE_REQUEST_ID')}/status`,
{ form: { status: 'approved', csrf_token: '' } }
).catch(() => null);
if (!resp || [404, 405].includes(resp.status())) test.skip(true, 'Route not available');
@@ -182,7 +183,7 @@ test.describe('DOC-STOR: Document storage and permanent vault', () => {
test('[V25-DOC-STOR-004] DOC-STOR-004 Permanent vault upload CSRF-less POST is rejected', async ({ request }) => {
skipIfMissing('CLIENT_A_ID');
const resp = await request.post(
`${process.env.BASE_URL}/documents/permanent/clients/${idOr('CLIENT_A_ID')}/upload`,
`${BASE_URL}/documents/permanent/clients/${idOr('CLIENT_A_ID')}/upload`,
{ form: { csrf_token: '' } }
).catch(() => null);
if (!resp || [404, 405].includes(resp.status())) test.skip(true, 'Route not available');
@@ -216,14 +217,14 @@ test.describe('DOC-STOR: Document storage and permanent vault', () => {
});
test('[V25-DOC-STOR-009] DOC-STOR-009 Storage agent jobs endpoint requires auth', async ({ request }) => {
const resp = await request.get(`${process.env.BASE_URL}/documents/storage-agent/jobs/pending`).catch(() => null);
const resp = await request.get(`${BASE_URL}/documents/storage-agent/jobs/pending`).catch(() => null);
if (!resp) test.skip(true, 'Request failed at network level');
expect(resp.status()).toBeLessThan(500);
expect([400, 401, 403, 404, 405, 422].includes(resp.status())).toBeTruthy();
});
test('[V25-DOC-STOR-010] DOC-STOR-010 Storage agent download-requests endpoint requires auth', async ({ request }) => {
const resp = await request.get(`${process.env.BASE_URL}/documents/storage-agent/download-requests/pending`).catch(() => null);
const resp = await request.get(`${BASE_URL}/documents/storage-agent/download-requests/pending`).catch(() => null);
if (!resp) test.skip(true, 'Request failed at network level');
expect(resp.status()).toBeLessThan(500);
expect([400, 401, 403, 404, 405, 422].includes(resp.status())).toBeTruthy();
@@ -232,7 +233,7 @@ test.describe('DOC-STOR: Document storage and permanent vault', () => {
test('[V25-DOC-STOR-011] DOC-STOR-011 Storage node toggle CSRF-less POST is rejected', async ({ request }) => {
skipIfMissing('STORAGE_NODE_ID');
const resp = await request.post(
`${process.env.BASE_URL}/documents/storage-nodes/${idOr('STORAGE_NODE_ID')}/toggle`,
`${BASE_URL}/documents/storage-nodes/${idOr('STORAGE_NODE_ID')}/toggle`,
{ form: { csrf_token: '' } }
).catch(() => null);
if (!resp || [404, 405].includes(resp.status())) test.skip(true, 'Route not available');
@@ -256,7 +257,7 @@ test.describe('DOC-STOR: Document storage and permanent vault', () => {
test('[V25-DOC-STOR-014] DOC-STOR-014 Permanent document delete CSRF-less POST is rejected', async ({ request }) => {
skipIfMissing('PERM_DOCUMENT_ID');
const resp = await request.post(
`${process.env.BASE_URL}/documents/permanent/${idOr('PERM_DOCUMENT_ID')}/delete`,
`${BASE_URL}/documents/permanent/${idOr('PERM_DOCUMENT_ID')}/delete`,
{ form: { csrf_token: '' } }
).catch(() => null);
if (!resp || [404, 405].includes(resp.status())) test.skip(true, 'Route not available');
@@ -271,7 +272,7 @@ test.describe('DOC-STOR: Document storage and permanent vault', () => {
});
test('[V25-DOC-STOR-016] DOC-STOR-016 Storage agent agent-package download requires node auth', async ({ request }) => {
const resp = await request.get(`${process.env.BASE_URL}/documents/storage-nodes/download-agent-package`).catch(() => null);
const resp = await request.get(`${BASE_URL}/documents/storage-nodes/download-agent-package`).catch(() => null);
if (!resp || [404, 405].includes(resp.status())) test.skip(true, 'Route not available');
expect(resp.status()).toBeLessThan(500);
expect([400, 401, 403, 404, 422].includes(resp.status())).toBeTruthy();