Copilot commented on code in PR #6520:
URL: https://github.com/apache/texera/pull/6520#discussion_r3608101002


##########
frontend/src/app/workspace/component/agent/agent-panel/agent-registration/agent-registration.component.spec.ts:
##########
@@ -0,0 +1,186 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { ComponentFixture, TestBed } from "@angular/core/testing";
+import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
+import { HttpClientTestingModule } from "@angular/common/http/testing";
+import { of, throwError } from "rxjs";
+import { AgentRegistrationComponent } from "./agent-registration.component";
+import { AgentService, ModelType } from 
"../../../../service/agent/agent.service";
+import { NotificationService } from 
"../../../../../common/service/notification/notification.service";
+import { WorkflowActionService } from 
"../../../../service/workflow-graph/model/workflow-action.service";
+import { ComputingUnitStatusService } from 
"../../../../../common/service/computing-unit/computing-unit-status/computing-unit-status.service";
+import { ComputingUnitState } from 
"../../../../../common/type/computing-unit-connection.interface";
+import { commonTestProviders } from "../../../../../common/testing/test-utils";
+
+const MODEL: ModelType = { id: "gpt", name: "GPT", description: "desc", icon: 
"robot" };
+
+describe("AgentRegistrationComponent", () => {
+  let fixture: ComponentFixture<AgentRegistrationComponent>;
+  let component: AgentRegistrationComponent;
+
+  let fetchModelTypes: ReturnType<typeof vi.fn>;
+  let createAgent: ReturnType<typeof vi.fn>;
+  let notifyError: ReturnType<typeof vi.fn>;
+  let getWorkflowMetadata: ReturnType<typeof vi.fn>;
+  let getStatus: ReturnType<typeof vi.fn>;
+
+  beforeEach(async () => {
+    // Safe defaults so `ngOnInit` (run on the first detectChanges) always has
+    // observables to subscribe to; individual tests override before rendering.
+    fetchModelTypes = vi.fn().mockReturnValue(of([]));

Review Comment:
   The default stub for fetchModelTypes returns an empty array, which triggers 
the component’s ngOnInit “no models available” error path (sets hasLoadingError 
and calls NotificationService.error) in any test that calls detectChanges but 
doesn’t override fetchModelTypes. This adds unintended side effects to 
unrelated tests and can make the suite more brittle.
   
   Consider defaulting fetchModelTypes to return a non-empty list (and override 
it only in the specific empty/error tests).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to