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


##########
frontend/src/app/workspace/component/left-panel/settings/settings.component.spec.ts:
##########
@@ -16,3 +16,143 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
+import { ComponentFixture, TestBed } from "@angular/core/testing";
+import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
+import { FormsModule, ReactiveFormsModule } from "@angular/forms";
+import { HttpClientTestingModule } from "@angular/common/http/testing";
+import { of, throwError } from "rxjs";
+
+import { SettingsComponent } from "./settings.component";
+import { WorkflowActionService } from 
"../../../service/workflow-graph/model/workflow-action.service";
+import { WorkflowPersistService } from 
"../../../../common/service/workflow-persist/workflow-persist.service";
+import { UserService } from "../../../../common/service/user/user.service";
+import { StubUserService } from 
"../../../../common/service/user/stub-user.service";
+import { NotificationService } from 
"../../../../common/service/notification/notification.service";
+import { ExecutionMode } from "../../../../common/type/workflow";
+import { commonTestProviders } from "../../../../common/testing/test-utils";
+
+describe("SettingsComponent", () => {
+  let component: SettingsComponent;
+  let fixture: ComponentFixture<SettingsComponent>;
+  let workflowActionService: WorkflowActionService;
+  let userService: StubUserService;
+  let workflowPersistSpy: { persistWorkflow: ReturnType<typeof vi.fn> };
+  let notificationSpy: { error: ReturnType<typeof vi.fn> };
+
+  beforeEach(async () => {
+    workflowPersistSpy = { persistWorkflow: vi.fn().mockReturnValue(of({})) };
+    notificationSpy = { error: vi.fn() };
+
+    await TestBed.configureTestingModule({
+      providers: [
+        WorkflowActionService,
+        { provide: UserService, useClass: StubUserService },
+        { provide: WorkflowPersistService, useValue: workflowPersistSpy },
+        { provide: NotificationService, useValue: notificationSpy },
+        ...commonTestProviders,
+      ],
+      imports: [

Review Comment:
   This spec instantiates the real WorkflowActionService, which in turn 
constructs OperatorMetadataService (and friends). OperatorMetadataService 
eagerly issues an HttpClient GET in its constructor, so these tests end up 
creating an unused pending HTTP request and coupling the component unit tests 
to a large part of the workflow graph stack. Consider providing a lightweight 
stub/mock WorkflowActionService (covering only the methods SettingsComponent 
uses), or mocking OperatorMetadataService / flushing the request via 
HttpTestingController, to keep the spec fast and isolated.



-- 
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