import { filterInapplicableCasesForVisibility } from './src/tools/autotest-pipeline.js';

function assert(condition, message) {
  if (!condition) throw new Error(message);
}

console.log('\n── AutoTest Pagination Case Filter ──');

const cases = [
  {
    id: 'WF_001',
    page: '/CourseList',
    steps: [
      { action: 'click', selector: 'vlid:nextPage' },
      { action: 'screenshot' },
    ],
  },
  {
    id: 'WF_002',
    page: '/CourseList',
    steps: [
      { action: 'click', selector: 'vlid:editBtn' },
      { action: 'click', selector: 'vlid:deleteBtn' },
    ],
  },
];

const result = filterInapplicableCasesForVisibility(cases, {
  '/courselist': {
    visibleIds: ['addButton', 'editBtn', 'deleteBtn'],
  },
});

assert(result.testCases.length === 1, 'should keep only applicable cases');
assert(result.testCases[0].id === 'WF_002', 'should keep non-pagination case');
assert(result.dropped.length === 1 && result.dropped[0].id === 'WF_001', 'should drop pagination case when controls are absent');

console.log('PASS test-autotest-pagination-case-filter.js');
