test-autotest-pagination-case-filter.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { filterInapplicableCasesForVisibility } from './src/tools/autotest-pipeline.js';
  2. function assert(condition, message) {
  3. if (!condition) throw new Error(message);
  4. }
  5. console.log('\n── AutoTest Pagination Case Filter ──');
  6. const cases = [
  7. {
  8. id: 'WF_001',
  9. page: '/CourseList',
  10. steps: [
  11. { action: 'click', selector: 'vlid:nextPage' },
  12. { action: 'screenshot' },
  13. ],
  14. },
  15. {
  16. id: 'WF_002',
  17. page: '/CourseList',
  18. steps: [
  19. { action: 'click', selector: 'vlid:editBtn' },
  20. { action: 'click', selector: 'vlid:deleteBtn' },
  21. ],
  22. },
  23. ];
  24. const result = filterInapplicableCasesForVisibility(cases, {
  25. '/courselist': {
  26. visibleIds: ['addButton', 'editBtn', 'deleteBtn'],
  27. },
  28. });
  29. assert(result.testCases.length === 1, 'should keep only applicable cases');
  30. assert(result.testCases[0].id === 'WF_002', 'should keep non-pagination case');
  31. assert(result.dropped.length === 1 && result.dropped[0].id === 'WF_001', 'should drop pagination case when controls are absent');
  32. console.log('PASS test-autotest-pagination-case-filter.js');