@@ -671,6 +671,134 @@ describe('App', () => {
671671 } )
672672 } )
673673
674+ describe ( 'Row Context Menu' , ( ) => {
675+ it ( 'should be available when there is data and no running experiments' , async ( ) => {
676+ render ( < App /> )
677+
678+ fireEvent (
679+ window ,
680+ new MessageEvent ( 'message' , {
681+ data : {
682+ data : {
683+ ...tableDataFixture ,
684+ hasRunningExperiment : false
685+ } ,
686+ type : MessageToWebviewType . SET_DATA
687+ }
688+ } )
689+ )
690+
691+ const target = screen . getByTestId ( 'workspace-row' )
692+ fireEvent . contextMenu ( target , { bubbles : true } )
693+
694+ const menu = await screen . findByTestId ( 'messages-menu' )
695+ expect ( menu ) . toBeDefined ( )
696+ } )
697+
698+ it ( 'should present the correct options for the workspace row with no checkpoints' , async ( ) => {
699+ render ( < App /> )
700+
701+ fireEvent (
702+ window ,
703+ new MessageEvent ( 'message' , {
704+ data : {
705+ data : deeplyNestedTableDataFixture ,
706+ type : MessageToWebviewType . SET_DATA
707+ }
708+ } )
709+ )
710+
711+ const target = screen . getByTestId ( 'workspace-row' )
712+ fireEvent . contextMenu ( target , { bubbles : true } )
713+
714+ const menuitems = await screen . findAllByRole ( 'menuitem' )
715+ const itemLabels = menuitems . map ( item => item . textContent )
716+ expect ( itemLabels ) . toStrictEqual ( [ 'Modify and Run' , 'Modify and Queue' ] )
717+ } )
718+
719+ it ( 'should present the correct options for the main row with checkpoints' , async ( ) => {
720+ render ( < App /> )
721+
722+ fireEvent (
723+ window ,
724+ new MessageEvent ( 'message' , {
725+ data : {
726+ data : {
727+ ...tableDataFixture ,
728+ hasRunningExperiment : false
729+ } ,
730+ type : MessageToWebviewType . SET_DATA
731+ }
732+ } )
733+ )
734+
735+ const target = screen . getByText ( 'main' )
736+ fireEvent . contextMenu ( target , { bubbles : true } )
737+
738+ const menuitems = await screen . findAllByRole ( 'menuitem' )
739+ const itemLabels = menuitems . map ( item => item . textContent )
740+ expect ( itemLabels ) . toStrictEqual ( [
741+ 'Modify and Resume' ,
742+ 'Modify, Reset and Run' ,
743+ 'Modify and Queue'
744+ ] )
745+ } )
746+
747+ it ( 'should present the Remove experiment option for the checkpoint tips' , async ( ) => {
748+ render ( < App /> )
749+
750+ fireEvent (
751+ window ,
752+ new MessageEvent ( 'message' , {
753+ data : {
754+ data : {
755+ ...tableDataFixture ,
756+ hasRunningExperiment : false
757+ } ,
758+ type : MessageToWebviewType . SET_DATA
759+ }
760+ } )
761+ )
762+
763+ const target = screen . getByText ( '4fb124a' )
764+ fireEvent . contextMenu ( target , { bubbles : true } )
765+
766+ const menuitems = await screen . findAllByRole ( 'menuitem' )
767+ const itemLabels = menuitems . map ( item => item . textContent )
768+ expect ( itemLabels ) . toContain ( 'Remove' )
769+ } )
770+
771+ it ( 'should present the Remove option if multiple checkpoint tip rows are selected' , async ( ) => {
772+ render ( < App /> )
773+
774+ fireEvent (
775+ window ,
776+ new MessageEvent ( 'message' , {
777+ data : {
778+ data : {
779+ ...tableDataFixture ,
780+ hasRunningExperiment : false
781+ } ,
782+ type : MessageToWebviewType . SET_DATA
783+ }
784+ } )
785+ )
786+
787+ const firstRow = screen . getByTestId ( 'timestamp___1.exp-e7a67' )
788+ fireEvent . click ( firstRow )
789+
790+ const secondRow = screen . getByTestId ( 'timestamp___1.test-branch' )
791+ fireEvent . click ( secondRow )
792+
793+ const target = await screen . findByText ( '4fb124a' )
794+ fireEvent . contextMenu ( target , { bubbles : true } )
795+
796+ const menuitems = await screen . findAllByRole ( 'menuitem' )
797+ const itemLabels = menuitems . map ( item => item . textContent )
798+ expect ( itemLabels ) . toContain ( 'Remove Selected Rows' )
799+ } )
800+ } )
801+
674802 describe ( 'Context Menu Suppression' , ( ) => {
675803 it ( 'Suppresses the context menu on a table with no data' , ( ) => {
676804 render ( < App /> )
0 commit comments