import { filterUnreachableCasesForNavigation } from './src/tools/autotest-pipeline.js'; import { TestGenerator } from './src/tools/autotest/test-generator.js'; function assert(condition, message) { if (!condition) throw new Error(message); } console.log('\n── AutoTest Navigation Reachability ──'); const generator = new TestGenerator(null); const unchanged = generator._fixNavigation( [{ id: 'WF_002', page: '/TaskPublish', steps: [ { action: 'navigate', selector: 'https://example.test/app' }, { action: 'click', selector: 'vlid:taskPublish', description: 'Invented nav click' }, { action: 'assert_visible', selector: 'vlid:titleInput' }, ], }], { homePage: '/TaskList', pages: [ { path: '/TaskList', route: '/', navPath: [] }, { path: '/TaskPublish', route: '/publish', navPath: [] }, ], }, 'https://example.test/app', [] ); assert(unchanged[0].steps[1].selector === 'vlid:taskPublish', 'fixNavigation should not invent a fallback route click when navPath is empty'); const filtered = filterUnreachableCasesForNavigation(unchanged, { homePage: '/TaskList', pages: [ { path: '/TaskList', route: '/', navPath: [] }, { path: '/TaskPublish', route: '/publish', navPath: [] }, ], }); assert(filtered.testCases.length === 0, 'cases for non-home pages without reachable navPath should be dropped'); assert(filtered.dropped.length === 1 && filtered.dropped[0].reason === 'page_navigation_not_available', 'drop reason should explain missing page navigation'); console.log('PASS test-autotest-nav-reachability.js');