Skip to content

Commit 52c4198

Browse files
JeroenDeDauwclaude
andcommitted
Test relation-type trimming in RelationAttributesEditor
The editor trims the relation type before emitting and treats a whitespace-only value as empty (required error, no emit), but no test exercised the trimming, so dropping the trim would slip through. Add coverage for padded and whitespace-only input; both fail if the trim is removed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9e42559 commit 52c4198

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

resources/ext.neowiki/tests/components/SchemaEditor/Property/RelationAttributesEditor.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ describe( 'RelationAttributesEditor', () => {
107107
expect( wrapper.emitted( 'update:property' )?.[ 0 ] ).toEqual( [ { relation: 'Owns' } ] );
108108
} );
109109

110+
it( 'emits the relation trimmed of surrounding whitespace', async () => {
111+
const wrapper = newWrapper();
112+
113+
await wrapper.findComponent( CdxTextInput ).vm.$emit( 'update:modelValue', ' Owns ' );
114+
115+
expect( wrapper.emitted( 'update:property' )?.[ 0 ] ).toEqual( [ { relation: 'Owns' } ] );
116+
} );
117+
110118
it( 'emits targetSchema when the picker selects a schema', async () => {
111119
const wrapper = newWrapper();
112120

@@ -143,6 +151,17 @@ describe( 'RelationAttributesEditor', () => {
143151
expect( wrapper.emitted( 'update:property' ) ).toBeFalsy();
144152
} );
145153

154+
it( 'treats a whitespace-only relation as required and does not emit it', async () => {
155+
const wrapper = newWrapper();
156+
157+
await wrapper.findComponent( CdxTextInput ).vm.$emit( 'update:modelValue', ' ' );
158+
159+
const props = fieldProps( wrapper, '.relation-attributes__relation' );
160+
expect( props.status ).toBe( 'error' );
161+
expect( props.messages ).toEqual( { error: 'Relation type is required.' } );
162+
expect( wrapper.emitted( 'update:property' ) ).toBeFalsy();
163+
} );
164+
146165
it( 'shows a required error when the target schema is empty', () => {
147166
const wrapper = newWrapper( {
148167
property: relationProperty( { targetSchema: '' } ),

0 commit comments

Comments
 (0)