@@ -241,6 +241,9 @@ describe('ChainConfigurationForm', () => {
241241 tonKeys : {
242242 results : [ ] ,
243243 } ,
244+ suiKeys : {
245+ results : [ ] ,
246+ } ,
244247 } )
245248
246249 const chainType = getByRole ( 'button' , { name : 'EVM' } )
@@ -287,6 +290,131 @@ describe('ChainConfigurationForm', () => {
287290 } )
288291 } )
289292
293+ test ( 'should able to create SUI chain config (with selection)' , async ( ) => {
294+ const handleSubmit = jest . fn ( )
295+ const initialValues = emptyFormValues ( )
296+ initialValues . chainType = ChainTypes . EVM
297+ initialValues . adminAddr = '0x1234567'
298+
299+ const { container } = renderChainConfigurationForm (
300+ initialValues ,
301+ handleSubmit ,
302+ )
303+
304+ const chainType = getByRole ( 'button' , { name : 'EVM' } )
305+ userEvent . click ( chainType )
306+ userEvent . click ( getByRole ( 'option' , { name : 'SUI' } ) )
307+ await screen . findByRole ( 'button' , { name : 'SUI' } )
308+
309+ await selectChainIdOnUI ( container , '6666' )
310+
311+ const address = container . querySelector ( '#select-accountAddr' )
312+ expect ( address ) . toBeInTheDocument ( )
313+ address && userEvent . click ( address )
314+ userEvent . click ( getByRole ( 'option' , { name : '0x123' } ) )
315+ await screen . findByRole ( 'button' , { name : '0x123' } )
316+
317+ await userEvent . click ( getByRole ( 'button' , { name : / s u b m i t / i } ) )
318+
319+ await waitFor ( ( ) => {
320+ expect ( handleSubmit ) . toHaveBeenCalledWith ( {
321+ accountAddr : '0x123' ,
322+ accountAddrPubKey : '' ,
323+ adminAddr : '0x1234567' ,
324+ chainID : '6666' ,
325+ chainType : 'SUI' ,
326+ fluxMonitorEnabled : false ,
327+ ocr1Enabled : false ,
328+ ocr1IsBootstrap : false ,
329+ ocr1KeyBundleID : '' ,
330+ ocr1Multiaddr : '' ,
331+ ocr1P2PPeerID : '' ,
332+ ocr2CommitPluginEnabled : false ,
333+ ocr2Enabled : false ,
334+ ocr2ExecutePluginEnabled : false ,
335+ ocr2ForwarderAddress : '' ,
336+ ocr2IsBootstrap : false ,
337+ ocr2KeyBundleID : '' ,
338+ ocr2MedianPluginEnabled : false ,
339+ ocr2MercuryPluginEnabled : false ,
340+ ocr2Multiaddr : '' ,
341+ ocr2P2PPeerID : '' ,
342+ ocr2RebalancerPluginEnabled : false ,
343+ } )
344+ expect ( handleSubmit ) . toHaveBeenCalledTimes ( 1 )
345+ } )
346+ } )
347+
348+ test ( 'should able to create SUI chain config (with manual input)' , async ( ) => {
349+ const handleSubmit = jest . fn ( )
350+ const initialValues = emptyFormValues ( )
351+ initialValues . chainType = ChainTypes . EVM
352+
353+ renderChainConfigurationForm ( initialValues , handleSubmit , [ ] , {
354+ aptosKeys : {
355+ results : [ ] ,
356+ } ,
357+ solanaKeys : {
358+ results : [ ] ,
359+ } ,
360+ starknetKeys : {
361+ results : [ ] ,
362+ } ,
363+ tronKeys : {
364+ results : [ ] ,
365+ } ,
366+ tonKeys : {
367+ results : [ ] ,
368+ } ,
369+ suiKeys : {
370+ results : [ ] ,
371+ } ,
372+ } )
373+
374+ const chainType = getByRole ( 'button' , { name : 'EVM' } )
375+ userEvent . click ( chainType )
376+ userEvent . click ( getByRole ( 'option' , { name : 'SUI' } ) )
377+ await screen . findByRole ( 'button' , { name : 'SUI' } )
378+
379+ const chainIdTextBox = getByRole ( 'textbox' , { name : / c h a i n i d \* / i } )
380+ userEvent . type ( chainIdTextBox , '6666' )
381+
382+ const accountAddrTextBox = getByRole ( 'textbox' , {
383+ name : / a c c o u n t a d d r e s s \* / i,
384+ } )
385+ userEvent . type ( accountAddrTextBox , '0x123' )
386+
387+ await userEvent . click ( getByRole ( 'button' , { name : / s u b m i t / i } ) )
388+
389+ await waitFor ( ( ) => {
390+ expect ( handleSubmit ) . toHaveBeenCalledWith ( {
391+ accountAddr : '0x123' ,
392+ accountAddrPubKey : '' ,
393+ adminAddr : '' ,
394+ chainID : '6666' ,
395+ chainType : 'SUI' ,
396+ fluxMonitorEnabled : false ,
397+ ocr1Enabled : false ,
398+ ocr1IsBootstrap : false ,
399+ ocr1KeyBundleID : '' ,
400+ ocr1Multiaddr : '' ,
401+ ocr1P2PPeerID : '' ,
402+ ocr2CommitPluginEnabled : false ,
403+ ocr2Enabled : false ,
404+ ocr2ExecutePluginEnabled : false ,
405+ ocr2ForwarderAddress : '' ,
406+ ocr2IsBootstrap : false ,
407+ ocr2KeyBundleID : '' ,
408+ ocr2MedianPluginEnabled : false ,
409+ ocr2MercuryPluginEnabled : false ,
410+ ocr2Multiaddr : '' ,
411+ ocr2P2PPeerID : '' ,
412+ ocr2RebalancerPluginEnabled : false ,
413+ } )
414+ expect ( handleSubmit ) . toHaveBeenCalledTimes ( 1 )
415+ } )
416+ } )
417+
290418 test ( 'should able to create Solana chain config' , async ( ) => {
291419 const handleSubmit = jest . fn ( )
292420 const initialValues = emptyFormValues ( )
@@ -478,6 +606,9 @@ test('should be able to select OCR2 Job Type with Key Bundle ID', async () => {
478606 tonKeys : {
479607 results : [ ] ,
480608 } ,
609+ suiKeys : {
610+ results : [ ] ,
611+ } ,
481612 } ,
482613 )
483614
@@ -548,6 +679,11 @@ function renderChainConfigurationForm(
548679 enabled : true ,
549680 network : 'ton' ,
550681 } ,
682+ {
683+ id : '6666' ,
684+ enabled : true ,
685+ network : 'sui' ,
686+ } ,
551687 ] ,
552688 accountsNonEvm : FetchNonEvmKeys | undefined = {
553689 aptosKeys : {
@@ -565,6 +701,9 @@ function renderChainConfigurationForm(
565701 tonKeys : {
566702 results : [ { addressBase64 : '123' , rawAddress : '0:456' , id : 'ton_xxxx' } ] ,
567703 } ,
704+ suiKeys : {
705+ results : [ { account : '0x123' , id : '6666' } ] ,
706+ } ,
568707 } ,
569708) {
570709 return render (
0 commit comments