@@ -780,6 +780,37 @@ func TestCompileTemplate_AuthError(t *testing.T) {
780780 assert .ErrorIs (t , err , authErr , "Original auth error should be wrapped" )
781781}
782782
783+ func TestCompileTemplate_SystemCallBypassesAuth (t * testing.T ) {
784+ ctrl := gomock .NewController (t )
785+ defer ctrl .Finish ()
786+
787+ mockAuthService := domainmocks .NewMockAuthService (ctrl )
788+ mockRepo := domainmocks .NewMockTemplateRepository (ctrl )
789+ mockLogger := & MockLogger {}
790+
791+ svc := service .NewTemplateService (mockRepo , mockAuthService , mockLogger , "https://api.example.com" )
792+
793+ // Create a system context that should bypass authentication
794+ ctx := context .WithValue (context .Background (), "system_call" , true )
795+ workspaceID := "ws_123"
796+ testTree := createValidTestTree (createTestTextBlock ("txt1" , "Test" ))
797+
798+ // No auth service call expected since this is a system call
799+
800+ // --- Act ---
801+ resp , err := svc .CompileTemplate (ctx , domain.CompileTemplateRequest {
802+ WorkspaceID : workspaceID ,
803+ VisualEditorTree : testTree ,
804+ TemplateData : nil ,
805+ TrackingSettings : notifuse_mjml.TrackingSettings {},
806+ })
807+
808+ // --- Assert ---
809+ require .NoError (t , err )
810+ require .NotNil (t , resp )
811+ assert .True (t , resp .Success )
812+ }
813+
783814func TestCompileTemplate_InvalidTreeData (t * testing.T ) {
784815 ctrl := gomock .NewController (t )
785816 defer ctrl .Finish ()
0 commit comments