From 3bcb6ed093ed8b438678237148ec082273c63c27 Mon Sep 17 00:00:00 2001 From: A R R R Associates Date: Tue, 30 Jun 2026 23:18:42 +0530 Subject: [PATCH] latest error resolved --- fixtures/v204-helpers.js | 10 +++++++++- tests/fy-lock-backup.spec.js | 16 ++++++++++++---- tests/v204-security-additions.spec.js | 4 ++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/fixtures/v204-helpers.js b/fixtures/v204-helpers.js index 0838911..44a3b06 100644 --- a/fixtures/v204-helpers.js +++ b/fixtures/v204-helpers.js @@ -35,8 +35,16 @@ async function switchFinancialYearIfPossible(page, yearCode) { ]; for (const sel of selectors) { + if (page.isClosed()) return false; const loc = page.locator(sel).first(); - if (await loc.count()) { + let found = 0; + try { + found = await loc.count(); + } catch (_) { + if (page.isClosed()) return false; + found = 0; + } + if (found) { try { await loc.selectOption({ value: yearCode }); } catch (_) { diff --git a/tests/fy-lock-backup.spec.js b/tests/fy-lock-backup.spec.js index 65bdb3a..a05a05c 100644 --- a/tests/fy-lock-backup.spec.js +++ b/tests/fy-lock-backup.spec.js @@ -187,7 +187,7 @@ async function generateBackupAndGetDownloadHref(page, yearCode = TEST_FY) { await page.locator(`form[action="${FY_BASE}/${fyId}/backup/export"] button[type="submit"], form[action="${FY_BASE}/${fyId}/backup/export"] button`).first().click(); await page.waitForLoadState('domcontentloaded').catch(() => {}); await expectNoBackendError(page); - await expect(page.getByText(/Backup export generated successfully|Generated At|Completed|Download/i)).toBeVisible(); + await expect(page.locator('body')).toContainText(/Backup export generated successfully|Generated At|Completed|Download/i); const href = await page.locator(`a[href*="${FY_BASE}/backups/"][href$="/download"]`).first().getAttribute('href'); expect(href).toBeTruthy(); return href; @@ -320,12 +320,20 @@ test.describe('UAT_FY_Lock_Backup', () => { test('FY-012 :: Direct URL cross-FY task update', async ({ page }) => { await switchToFY(page, TEST_FY); - const href = await getFirstHrefMatching(page, WORK_TRACKER_ROUTE, `${WORK_TRACKER_ROUTE}/tasks/`) || await getFirstHrefMatching(page, WORK_TRACKER_FALLBACK_ROUTE, `${WORK_TRACKER_FALLBACK_ROUTE}/tasks/`); - expect(href, 'Expected at least one seeded task link for cross-FY direct URL test').toBeTruthy(); - const resp = await safeGoto(page, href); + + const taskId = process.env.ACTIVE_FY_TASK_ID || process.env.TASK_A_ID; + expect(taskId, 'ACTIVE_FY_TASK_ID or TASK_A_ID must be configured').toBeTruthy(); + + const resp = await safeGoto(page, `/services/work-tracker/tasks/${taskId}/edit`); if (resp) expect(resp.status()).toBeLessThan(500); + const body = await readBody(page); + + // Cross-FY direct access must be handled safely. + // It may redirect, show Work Tracker, show no task, or block access, + // but it must not crash the ERP. expect(body).not.toMatch(/Traceback|Internal Server Error|Exception in ASGI application/i); + expect(body).toMatch(/Work Tracker|No execution tasks found|Financial Year|Access denied|Forbidden|Task/i); }); test('FY-013 :: Task/engagement document FY path', async ({ page }) => { diff --git a/tests/v204-security-additions.spec.js b/tests/v204-security-additions.spec.js index 47f0615..5ca2813 100644 --- a/tests/v204-security-additions.spec.js +++ b/tests/v204-security-additions.spec.js @@ -178,7 +178,7 @@ test.describe('v2.0.4 additional security / FY / context checks', () => { test('V204-FY-002 switching FY does not crash core transactional pages', async ({ page }) => { await login(page, 'System Admin'); await page.goto('/system-settings'); - await switchFinancialYearIfPossible(page, activeFY); + await page.goto(`/system-settings/context/financial-year/${encodeURIComponent(activeFY)}`); for (const route of ['/services/engagements', '/documents', '/notice-cases', '/billing', '/billing/payments']) { const resp = await page.goto(route).catch(() => null); if (resp && [404,405].includes(resp.status())) continue; @@ -191,7 +191,7 @@ test.describe('v2.0.4 additional security / FY / context checks', () => { if (!process.env.LOCKED_FY) test.skip(true, 'Set LOCKED_FY in .env after locking a financial year'); await login(page, 'System Admin'); await page.goto('/system-settings'); - await switchFinancialYearIfPossible(page, process.env.LOCKED_FY); + await page.goto(`/system-settings/context/financial-year/${encodeURIComponent(process.env.LOCKED_FY)}`); await page.goto('/notice-cases/new'); await page.waitForLoadState('domcontentloaded').catch(() => {}); const csrf = await extractCsrfFromPage(page);