@@ -4041,6 +4041,57 @@ public async Task OnAddAsync_Ok(EditMode mode)
40414041 }
40424042 }
40434043
4044+ [ Theory ]
4045+ [ InlineData ( InsertRowMode . First ) ]
4046+ [ InlineData ( InsertRowMode . Last ) ]
4047+ public void OnAddAsync_IsTracking_Ok ( InsertRowMode mode )
4048+ {
4049+ var localizer = Context . Services . GetRequiredService < IStringLocalizer < Foo > > ( ) ;
4050+ var items = Foo . GenerateFoo ( localizer , 2 ) ;
4051+ var added = false ;
4052+ var cut = Context . RenderComponent < BootstrapBlazorRoot > ( pb =>
4053+ {
4054+ pb . AddChildContent < Table < Foo > > ( pb =>
4055+ {
4056+ pb . Add ( a => a . RenderMode , TableRenderMode . Table ) ;
4057+ pb . Add ( a => a . Items , items ) ;
4058+ pb . Add ( a => a . IsMultipleSelect , true ) ;
4059+ pb . Add ( a => a . ShowToolbar , true ) ;
4060+ pb . Add ( a => a . IsTracking , true ) ;
4061+ pb . Add ( a => a . ShowExtendButtons , true ) ;
4062+ pb . Add ( a => a . EditMode , EditMode . EditForm ) ;
4063+ pb . Add ( a => a . InsertRowMode , mode ) ;
4064+ pb . Add ( a => a . OnAddAsync , ( ) =>
4065+ {
4066+ added = true ;
4067+ return Task . FromResult ( new Foo ( ) { Name = "test" } ) ;
4068+ } ) ;
4069+ pb . Add ( a => a . OnSaveAsync , ( foo , changedType ) =>
4070+ {
4071+ return Task . FromResult ( true ) ;
4072+ } ) ;
4073+ pb . Add ( a => a . TableColumns , foo => builder =>
4074+ {
4075+ builder . OpenComponent < TableColumn < Foo , string > > ( 0 ) ;
4076+ builder . AddAttribute ( 1 , "Field" , "Name" ) ;
4077+ builder . AddAttribute ( 2 , "FieldExpression" , Utility . GenerateValueExpression ( foo , "Name" , typeof ( string ) ) ) ;
4078+ builder . CloseComponent ( ) ;
4079+ } ) ;
4080+ } ) ;
4081+ } ) ;
4082+
4083+ // test add button
4084+ var button = cut . FindComponent < TableToolbarButton < Foo > > ( ) ;
4085+ cut . InvokeAsync ( ( ) => button . Instance . OnClick . InvokeAsync ( ) ) ;
4086+ Assert . True ( added ) ;
4087+
4088+ var input = cut . Find ( "tbody form input" ) ;
4089+ cut . InvokeAsync ( ( ) => input . Change ( "test_name" ) ) ;
4090+
4091+ var form = cut . Find ( "tbody form" ) ;
4092+ cut . InvokeAsync ( ( ) => form . Submit ( ) ) ;
4093+ }
4094+
40444095 [ Fact ]
40454096 public async Task OnEditAsync_Ok ( )
40464097 {
@@ -4648,8 +4699,10 @@ public void ShowExtendDeleteButton_Ok()
46484699 Assert . Contains ( "fa-solid fa-xmark" , table . Find ( "tbody" ) . ToMarkup ( ) ) ;
46494700 }
46504701
4651- [ Fact ]
4652- public async Task EditAsync_Ok ( )
4702+ [ Theory ]
4703+ [ InlineData ( true ) ]
4704+ [ InlineData ( false ) ]
4705+ public async Task EditAsync_Ok ( bool isTracking )
46534706 {
46544707 var localizer = Context . Services . GetRequiredService < IStringLocalizer < Foo > > ( ) ;
46554708 var items = Foo . GenerateFoo ( localizer , 2 ) ;
@@ -4662,6 +4715,7 @@ public async Task EditAsync_Ok()
46624715 pb . Add ( a => a . Items , items ) ;
46634716 pb . Add ( a => a . IsMultipleSelect , true ) ;
46644717 pb . Add ( a => a . ShowToolbar , true ) ;
4718+ pb . Add ( a => a . IsTracking , isTracking ) ;
46654719 pb . Add ( a => a . TableColumns , foo => builder =>
46664720 {
46674721 builder . OpenComponent < TableColumn < Foo , string > > ( 0 ) ;
0 commit comments