| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import { TestRunner } from './src/tools/autotest/test-runner.js';
- function assert(condition, message) {
- if (!condition) throw new Error(message);
- }
- class MissingLocator {
- async count() {
- return 0;
- }
- async waitFor() {
- throw new Error('not attached');
- }
- async fill() {
- throw new Error('should not fill missing locator');
- }
- async click() {
- throw new Error('should not click missing locator');
- }
- locator() {
- return this;
- }
- first() {
- return this;
- }
- }
- console.log('\n── AutoTest Strict vlid Fill ──');
- const runner = new TestRunner({ baseUrl: 'https://example.test/app' });
- let typed = false;
- runner.page = {
- keyboard: {
- async type() {
- typed = true;
- },
- },
- };
- runner._resolveSelector = async () => new MissingLocator();
- let err = null;
- try {
- await runner._executeAction({
- action: 'fill',
- selector: 'vlid:formDescInput input',
- value: 'abc',
- });
- } catch (error) {
- err = error;
- }
- assert(err, 'strict vlid fill should fail when component id is missing');
- assert(
- String(err.message).includes('component id not found'),
- 'strict vlid fill should report missing component id'
- );
- assert(!typed, 'strict vlid fill must not fall back to keyboard typing on the active element');
- console.log('PASS test-autotest-strict-vlid-fill.js');
|