| 12345678910111213141516171819202122232425262728293031323334 |
- import { TestGenerator } from './src/tools/autotest/test-generator.js';
- function assert(condition, message) {
- if (!condition) throw new Error(message);
- }
- console.log('\n── AutoTest Metadata Selector Preference ──');
- const generator = new TestGenerator(null);
- const cases = generator._preferMetadataIdsForActions(
- [{
- id: 'WF_001',
- page: '/CourseList',
- steps: [
- { action: 'click', selector: 'text=确定', description: 'Click 确定 to submit and create course' },
- { action: 'fill', selector: 'input[type="text"]', description: 'Fill 课程名称 field' },
- { action: 'assert_visible', selector: 'text=课程管理' },
- ],
- }],
- {
- interactiveElements: [
- { section: '/CourseList', instanceId: 'submitForm', type: 'button', label: '确定', name: 'SubmitForm' },
- { section: '/CourseList', instanceId: 'formTitleInput', type: 'input', label: '课程名称', name: 'FormTitleInput' },
- ],
- },
- [{ instanceId: 'navItem', text: '课程管理', position: 'sidebar' }]
- );
- assert(cases[0].steps[0].selector === 'vlid:submitForm', 'button click should prefer vlid selector from metadata');
- assert(cases[0].steps[1].selector === 'vlid:formTitleInput input', 'fill should prefer vlid input selector from metadata');
- assert(cases[0].steps[2].selector === 'text=课程管理', 'assertions should keep text selectors');
- console.log('PASS test-autotest-metadata-selector-preference.js');
|