You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "mengw15 (via GitHub)" <gi...@apache.org> on 2026/07/18 09:32:55 UTC
[PR] test(frontend): add unit test coverage for AgentRegistrationComponent [texera]
mengw15 opened a new pull request, #6520:
URL: https://github.com/apache/texera/pull/6520
### What changes were proposed in this PR?
Adds a behavior-focused Vitest spec for `AgentRegistrationComponent`
(`frontend/src/app/workspace/component/agent/agent-panel/agent-registration/agent-registration.component.ts`),
previously without a spec (~11.5% coverage). `AgentService`,
`NotificationService`, `WorkflowActionService`, and `ComputingUnitStatusService`
are stubbed; the component renders with `detectChanges()`.
13 tests cover:
- `should create`, template renders, and `customAgentName` defaults to `"Texera Agent"`.
- `ngOnInit` — loads the fetched model types and clears `isLoadingModels`; flags `hasLoadingError` + notifies when no models are returned; flags the error + notifies when the fetch fails; and sets `computingUnitConnected` only when the status is `Running`.
- `selectModelType` updates `selectedModelType`.
- `createAgent` — emits `agentCreated` with the new id and resets the form on success; forwards the model, name (or `undefined` when blank), and workflow id to the service; is a no-op when no model is selected or a creation is already in progress; and notifies + clears `isCreating` on failure.
- `canCreate` requires a selected model, an idle form, and a connected computing unit.
No production code was changed.
### Any related issues, documentation, discussions?
Closes #6514
### How was this PR tested?
New unit tests, run locally in `frontend/` (all green; the failure path was
verified by deliberately breaking the `agentCreated` emit assertion to confirm
the suite goes red):
```
ng test --watch=false --include src/app/workspace/component/agent/agent-panel/agent-registration/agent-registration.component.spec.ts
# Test Files 1 passed (1) | Tests 13 passed (13)
prettier --write <spec> # formatted
eslint <spec> # clean
```
All four services are stubbed, so the suite makes no network calls (see
`frontend/TESTING.md`).
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8 [1M context])
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(frontend): add unit test coverage for AgentRegistrationComponent [texera]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #6520:
URL: https://github.com/apache/texera/pull/6520#issuecomment-5010785373
## [Codecov](https://app.codecov.io/gh/apache/texera/pull/6520?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 70.76%. Comparing base ([`39db110`](https://app.codecov.io/gh/apache/texera/commit/39db110e74b4bdcf0e4b0df961c25973e6bbb20c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`0669c78`](https://app.codecov.io/gh/apache/texera/commit/0669c78a0a14fb85d461c186d266e8e7302b2948?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #6520 +/- ##
============================================
+ Coverage 70.57% 70.76% +0.18%
Complexity 3425 3425
============================================
Files 1146 1146
Lines 45062 45062
Branches 4960 4960
============================================
+ Hits 31802 31887 +85
+ Misses 11613 11525 -88
- Partials 1647 1650 +3
```
| [Flag](https://app.codecov.io/gh/apache/texera/pull/6520/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | | *Carryforward flag |
|---|---|---|---|
| [access-control-service](https://app.codecov.io/gh/apache/texera/pull/6520/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.00% <ø> (ø)` | | Carriedforward from [39db110](https://app.codecov.io/gh/apache/texera/commit/39db110e74b4bdcf0e4b0df961c25973e6bbb20c?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [agent-service](https://app.codecov.io/gh/apache/texera/pull/6520/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `76.76% <ø> (ø)` | | Carriedforward from [39db110](https://app.codecov.io/gh/apache/texera/commit/39db110e74b4bdcf0e4b0df961c25973e6bbb20c?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [amber](https://app.codecov.io/gh/apache/texera/pull/6520/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `66.72% <ø> (ø)` | | Carriedforward from [39db110](https://app.codecov.io/gh/apache/texera/commit/39db110e74b4bdcf0e4b0df961c25973e6bbb20c?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [computing-unit-managing-service](https://app.codecov.io/gh/apache/texera/pull/6520/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `17.72% <ø> (ø)` | | Carriedforward from [39db110](https://app.codecov.io/gh/apache/texera/commit/39db110e74b4bdcf0e4b0df961c25973e6bbb20c?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [config-service](https://app.codecov.io/gh/apache/texera/pull/6520/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `52.30% <ø> (ø)` | | Carriedforward from [39db110](https://app.codecov.io/gh/apache/texera/commit/39db110e74b4bdcf0e4b0df961c25973e6bbb20c?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [file-service](https://app.codecov.io/gh/apache/texera/pull/6520/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `66.80% <ø> (ø)` | | Carriedforward from [39db110](https://app.codecov.io/gh/apache/texera/commit/39db110e74b4bdcf0e4b0df961c25973e6bbb20c?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [frontend](https://app.codecov.io/gh/apache/texera/pull/6520/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `69.80% <ø> (+0.44%)` | :arrow_up: | |
| [notebook-migration-service](https://app.codecov.io/gh/apache/texera/pull/6520/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `78.94% <ø> (ø)` | | Carriedforward from [39db110](https://app.codecov.io/gh/apache/texera/commit/39db110e74b4bdcf0e4b0df961c25973e6bbb20c?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [pyamber](https://app.codecov.io/gh/apache/texera/pull/6520/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `91.74% <ø> (ø)` | | Carriedforward from [39db110](https://app.codecov.io/gh/apache/texera/commit/39db110e74b4bdcf0e4b0df961c25973e6bbb20c?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [workflow-compiling-service](https://app.codecov.io/gh/apache/texera/pull/6520/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.14% <ø> (ø)` | | Carriedforward from [39db110](https://app.codecov.io/gh/apache/texera/commit/39db110e74b4bdcf0e4b0df961c25973e6bbb20c?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
*This pull request uses carry forward flags. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/texera/pull/6520?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(frontend): add unit test coverage for AgentRegistrationComponent [texera]
Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan merged PR #6520:
URL: https://github.com/apache/texera/pull/6520
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(frontend): add unit test coverage for AgentRegistrationComponent [texera]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #6520:
URL: https://github.com/apache/texera/pull/6520#issuecomment-5010767014
<!-- texera-reviewer-suggestion -->
### Automated Reviewer Suggestions
Based on the `git blame` history of the changed files, we recommend the following reviewers:
- No candidates found from `git blame` history.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(frontend): add unit test coverage for AgentRegistrationComponent [texera]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org