@@ -96,7 +96,6 @@ import {
9696import { GetComponentDefinitionsRequestI } from '@/shared/queries/platform/componentDefinitions.queries' ;
9797import { render , screen , userEvent } from '@/shared/util/test-utils' ;
9898import { UseMutationResult , UseQueryResult } from '@tanstack/react-query' ;
99- import { Editor } from '@tiptap/react' ;
10099import * as React from 'react' ;
101100import { type Mock , describe , expect , test , vi } from 'vitest' ;
102101
@@ -139,125 +138,6 @@ describe('PropertyMentionsInput', () => {
139138 expect ( screen . getByText ( 'PropertyMentionsInput Label' ) ) . toBeInTheDocument ( ) ;
140139 } ) ;
141140
142- test . each ( [ [ 'TEXT' as const ] , [ 'TEXT_AREA' as const ] , [ 'RICH_TEXT' as const ] ] ) (
143- 'Backspace after a mention inserts $ (not @) in %s' ,
144- async ( controlType ) => {
145- // Ensure workflow id so guards inside the editor pass
146- useWorkflowDataStore . setState ( {
147- workflow : { id : 'wf-bksp' , nodeNames : [ 'trigger_1' ] } ,
148- } as unknown as Partial < ReturnType < typeof useWorkflowDataStore . getState > > ) ;
149-
150- const dummyMutation = { } as unknown as UseMutationResult < unknown , Error , unknown , unknown > ;
151- const updateWorkflowNodeParameterMutation = dummyMutation as unknown as UseMutationResult <
152- DeleteClusterElementParameter200Response ,
153- Error ,
154- UpdateWorkflowNodeParameterOperationRequest ,
155- unknown
156- > ;
157- const updateClusterElementParameterMutation = dummyMutation as unknown as UseMutationResult <
158- DeleteClusterElementParameter200Response ,
159- Error ,
160- UpdateClusterElementParameterOperationRequest ,
161- unknown
162- > ;
163-
164- const editorRef = React . createRef < Editor > ( ) ;
165-
166- render (
167- < WorkflowEditorProvider
168- value = { {
169- ConnectionKeys : {
170- connection : ( ) => [ ] ,
171- connectionTags : [ ] ,
172- connections : [ ] ,
173- filteredConnections : ( ) => [ ] ,
174- } ,
175- deleteClusterElementParameterMutation : dummyMutation as unknown as UseMutationResult <
176- DeleteClusterElementParameter200Response ,
177- Error ,
178- DeleteClusterElementParameterOperationRequest ,
179- unknown
180- > ,
181- deleteWorkflowNodeParameterMutation : dummyMutation as unknown as UseMutationResult <
182- DeleteClusterElementParameter200Response ,
183- Error ,
184- DeleteWorkflowNodeParameterRequest ,
185- unknown
186- > ,
187- invalidateWorkflowQueries : ( ) => { } ,
188- updateClusterElementParameterMutation,
189- updateWorkflowMutation : { } as unknown as UpdateWorkflowMutationType ,
190- updateWorkflowNodeParameterMutation,
191- useCreateConnectionMutation : ( ) =>
192- ( { } ) as unknown as UseMutationResult < number , Error , ConnectionI , unknown > ,
193- useGetComponentDefinitionsQuery : ( ) =>
194- ( { } ) as UseQueryResult < Array < ComponentDefinitionBasic > , Error > ,
195- useGetConnectionTagsQuery : ( ) => ( { } ) as unknown as UseQueryResult < Tag [ ] , Error > ,
196- useGetConnectionsQuery : ( ) => ( { } ) as unknown as UseQueryResult < ConnectionI [ ] , Error > ,
197- webhookTriggerTestApi : {
198- startWebhookTriggerTest : async ( ) => ( { } ) ,
199- stopWebhookTriggerTest : async ( ) => { } ,
200- } ,
201- } }
202- >
203- < WorkflowReadOnlyProvider
204- value = { {
205- useGetComponentDefinitionsQuery : ( ) =>
206- ( { } ) as UseQueryResult < Array < ComponentDefinitionBasic > , Error > ,
207- } }
208- >
209- < PropertyMentionsInput
210- controlType = { controlType }
211- label = { `Bksp ${ controlType } ` }
212- leadingIcon = "📄"
213- placeholder = ""
214- ref = { editorRef }
215- type = "STRING"
216- value = ""
217- />
218- </ WorkflowReadOnlyProvider >
219- </ WorkflowEditorProvider >
220- ) ;
221-
222- const textbox = screen . getByRole ( 'textbox' , { name : `Bksp ${ controlType } ` } ) ;
223- const user = userEvent . setup ( ) ;
224- await user . click ( textbox ) ;
225- await microtaskTick ( ) ;
226-
227- // Editor instance is created asynchronously by Tiptap; wait for it to be ready
228- await import ( '@testing-library/react' ) ;
229- const { waitFor} = await import ( '@testing-library/react' ) ;
230- await waitFor ( ( ) => {
231- expect ( editorRef . current ) . toBeTruthy ( ) ;
232- } ) ;
233- const editor = editorRef . current ! ;
234-
235- // Insert a mention node programmatically (simulate selected pill)
236- editor
237- . chain ( )
238- . focus ( )
239- . insertContent ( [
240- {
241- attrs : { id : 'trigger_1.output' , label : 'trigger_1.output' } ,
242- type : 'mention' ,
243- } ,
244- ] )
245- . run ( ) ;
246-
247- // Place caret after the mention and press Backspace once
248- editor . commands . setTextSelection ( editor . state . doc . content . size ) ;
249- await microtaskTick ( ) ;
250-
251- const backspaceEvent = new KeyboardEvent ( 'keydown' , { bubbles : true , key : 'Backspace' } ) ;
252- editor . view . dom . dispatchEvent ( backspaceEvent ) ;
253- await microtaskTick ( 2 ) ;
254-
255- const text = editor . state . doc . textBetween ( 0 , editor . state . doc . content . size , '\n' ) ;
256- expect ( text . includes ( '$' ) ) . toBe ( true ) ;
257- expect ( text . includes ( '@' ) ) . toBe ( false ) ;
258- }
259- ) ;
260-
261141 test ( 'coalesces saves and prevents parallel saveProperty calls; latest value wins' , async ( ) => {
262142 // Arrange: workflow id so guard passes
263143 useWorkflowDataStore . setState ( {
0 commit comments