latest error resolved

This commit is contained in:
A R R R Associates
2026-06-30 23:18:42 +05:30
parent f84777ed4f
commit 3bcb6ed093
3 changed files with 23 additions and 7 deletions
+9 -1
View File
@@ -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 (_) {
+12 -4
View File
@@ -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 }) => {
+2 -2
View File
@@ -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);