@@ -609,6 +609,38 @@ func TestBlockIsValid(t *testing.T) {
609609 require .ErrorIs (t , err , ErrBlockPropertiesInvalidType )
610610 })
611611
612+ t .Run ("Should accept block with empty fileId (no file attached)" , func (t * testing.T ) {
613+ block := & Block {
614+ ID : string (utils .IDTypeNone ) + mmModel .NewId (),
615+ BoardID : string (utils .IDTypeNone ) + mmModel .NewId (),
616+ CreatedBy : string (utils .IDTypeNone ) + mmModel .NewId (),
617+ ModifiedBy : string (utils .IDTypeNone ) + mmModel .NewId (),
618+ Schema : 1 ,
619+ Type : TypeImage ,
620+ Title : "Image with empty fileId" ,
621+ Fields : map [string ]interface {}{BlockFieldFileId : "" },
622+ CreateAt : 1234567890 ,
623+ UpdateAt : 1234567890 ,
624+ }
625+ require .NoError (t , block .IsValid ())
626+ })
627+
628+ t .Run ("Should accept block with empty attachmentId (no file attached)" , func (t * testing.T ) {
629+ block := & Block {
630+ ID : string (utils .IDTypeNone ) + mmModel .NewId (),
631+ BoardID : string (utils .IDTypeNone ) + mmModel .NewId (),
632+ CreatedBy : string (utils .IDTypeNone ) + mmModel .NewId (),
633+ ModifiedBy : string (utils .IDTypeNone ) + mmModel .NewId (),
634+ Schema : 1 ,
635+ Type : TypeAttachment ,
636+ Title : "Attachment with empty attachmentId" ,
637+ Fields : map [string ]interface {}{BlockFieldAttachmentId : "" },
638+ CreateAt : 1234567890 ,
639+ UpdateAt : 1234567890 ,
640+ }
641+ require .NoError (t , block .IsValid ())
642+ })
643+
612644 t .Run ("Should accept block with properties as map" , func (t * testing.T ) {
613645 block := & Block {
614646 ID : string (utils .IDTypeNone ) + mmModel .NewId (),
0 commit comments