test-autotest-nav-reachability.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { filterUnreachableCasesForNavigation } from './src/tools/autotest-pipeline.js';
  2. import { TestGenerator } from './src/tools/autotest/test-generator.js';
  3. function assert(condition, message) {
  4. if (!condition) throw new Error(message);
  5. }
  6. console.log('\n── AutoTest Navigation Reachability ──');
  7. const generator = new TestGenerator(null);
  8. const unchanged = generator._fixNavigation(
  9. [{
  10. id: 'WF_002',
  11. page: '/TaskPublish',
  12. steps: [
  13. { action: 'navigate', selector: 'https://example.test/app' },
  14. { action: 'click', selector: 'vlid:taskPublish', description: 'Invented nav click' },
  15. { action: 'assert_visible', selector: 'vlid:titleInput' },
  16. ],
  17. }],
  18. {
  19. homePage: '/TaskList',
  20. pages: [
  21. { path: '/TaskList', route: '/', navPath: [] },
  22. { path: '/TaskPublish', route: '/publish', navPath: [] },
  23. ],
  24. },
  25. 'https://example.test/app',
  26. []
  27. );
  28. assert(unchanged[0].steps[1].selector === 'vlid:taskPublish', 'fixNavigation should not invent a fallback route click when navPath is empty');
  29. const filtered = filterUnreachableCasesForNavigation(unchanged, {
  30. homePage: '/TaskList',
  31. pages: [
  32. { path: '/TaskList', route: '/', navPath: [] },
  33. { path: '/TaskPublish', route: '/publish', navPath: [] },
  34. ],
  35. });
  36. assert(filtered.testCases.length === 0, 'cases for non-home pages without reachable navPath should be dropped');
  37. assert(filtered.dropped.length === 1 && filtered.dropped[0].reason === 'page_navigation_not_available', 'drop reason should explain missing page navigation');
  38. console.log('PASS test-autotest-nav-reachability.js');