-
-
Notifications
You must be signed in to change notification settings - Fork 835
Expand file tree
/
Copy pathtest-form-associated.js
More file actions
39 lines (31 loc) · 2.25 KB
/
test-form-associated.js
File metadata and controls
39 lines (31 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Simple test to verify form-associated boolean attribute behavior
const { MEMBER_FLAGS } = require('./build/internal/app-data/index.cjs');
const { parsePropertyValue } = require('./build/internal/client/index.js');
console.log('Testing form-associated boolean attribute parsing...');
// Test 1: Non-form-associated component (legacy behavior)
console.log('\n=== Non-form-associated component ===');
const normalResult1 = parsePropertyValue('false', MEMBER_FLAGS.Boolean, false);
const normalResult2 = parsePropertyValue('true', MEMBER_FLAGS.Boolean, false);
const normalResult3 = parsePropertyValue('', MEMBER_FLAGS.Boolean, false);
console.log('parsePropertyValue("false", Boolean, false):', normalResult1); // Should be false (legacy)
console.log('parsePropertyValue("true", Boolean, false):', normalResult2); // Should be true
console.log('parsePropertyValue("", Boolean, false):', normalResult3); // Should be true
// Test 2: Form-associated component (new behavior)
console.log('\n=== Form-associated component ===');
const formResult1 = parsePropertyValue('false', MEMBER_FLAGS.Boolean, true);
const formResult2 = parsePropertyValue('true', MEMBER_FLAGS.Boolean, true);
const formResult3 = parsePropertyValue('', MEMBER_FLAGS.Boolean, true);
console.log('parsePropertyValue("false", Boolean, true):', formResult1); // Should be true (new behavior!)
console.log('parsePropertyValue("true", Boolean, true):', formResult2); // Should be true
console.log('parsePropertyValue("", Boolean, true):', formResult3); // Should be true
// Test 3: Test with non-string values (should behave the same)
console.log('\n=== Non-string values ===');
const boolResult1 = parsePropertyValue(false, MEMBER_FLAGS.Boolean, true);
const boolResult2 = parsePropertyValue(true, MEMBER_FLAGS.Boolean, true);
console.log('parsePropertyValue(false, Boolean, true):', boolResult1); // Should be false
console.log('parsePropertyValue(true, Boolean, true):', boolResult2); // Should be true
// Summary
console.log('\n=== SUMMARY ===');
console.log('✅ Fix successful if form-associated "false" becomes true');
console.log('Form-associated disabled="false" result:', formResult1 === true ? '✅ FIXED' : '❌ BROKEN');
console.log('Legacy behavior preserved:', normalResult1 === false ? '✅ PRESERVED' : '❌ BROKEN');