You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "Ma77Ball (via GitHub)" <gi...@apache.org> on 2026/07/16 10:36:33 UTC
[PR] test(frontend): add unit tests for AdminUserService [texera]
Ma77Ball opened a new pull request, #6467:
URL: https://github.com/apache/texera/pull/6467
### What changes were proposed in this PR?
- Adds admin-user.service.spec.ts covering AdminUserService; no production code changed.
- Verifies the user list/update/add endpoints and the per-user quota GET endpoints.
- Asserts which endpoints send the user_id query param and which do not.
### Any related issues, documentation, discussions?
Closes: #6455
### How was this PR tested?
- Run `cd frontend && npx nx test gui --include="**/admin-user.service.spec.ts"`, expect 11 passed.
- Full frontend suite runs in CI via `yarn test:ci`, selected by the auto-applied `frontend` label.
### Was this PR authored or co-authored using generative AI tooling?
Co-authored with Claude Opus 4.8 in compliance with ASF
--
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 tests for AdminUserService [texera]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #6467:
URL: https://github.com/apache/texera/pull/6467#issuecomment-4990934475
## [Codecov](https://app.codecov.io/gh/apache/texera/pull/6467?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.21%. Comparing base ([`c7473a1`](https://app.codecov.io/gh/apache/texera/commit/c7473a1d8c8bf68f5cfab4ec4968982173ac5ae2?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`5cffe2b`](https://app.codecov.io/gh/apache/texera/commit/5cffe2b09717daae8c1db966810531834b1f98cf?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 #6467 +/- ##
=========================================
Coverage 70.20% 70.21%
Complexity 3390 3390
=========================================
Files 1142 1142
Lines 44844 44844
Branches 4949 4949
=========================================
+ Hits 31484 31486 +2
+ Misses 11725 11724 -1
+ Partials 1635 1634 -1
```
| [Flag](https://app.codecov.io/gh/apache/texera/pull/6467/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/6467/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 [c7473a1](https://app.codecov.io/gh/apache/texera/commit/c7473a1d8c8bf68f5cfab4ec4968982173ac5ae2?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/6467/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 [c7473a1](https://app.codecov.io/gh/apache/texera/commit/c7473a1d8c8bf68f5cfab4ec4968982173ac5ae2?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/6467/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `66.68% <ø> (ø)` | | Carriedforward from [c7473a1](https://app.codecov.io/gh/apache/texera/commit/c7473a1d8c8bf68f5cfab4ec4968982173ac5ae2?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/6467/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `9.97% <ø> (ø)` | | Carriedforward from [c7473a1](https://app.codecov.io/gh/apache/texera/commit/c7473a1d8c8bf68f5cfab4ec4968982173ac5ae2?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/6467/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 [c7473a1](https://app.codecov.io/gh/apache/texera/commit/c7473a1d8c8bf68f5cfab4ec4968982173ac5ae2?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/6467/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `65.63% <ø> (ø)` | | Carriedforward from [c7473a1](https://app.codecov.io/gh/apache/texera/commit/c7473a1d8c8bf68f5cfab4ec4968982173ac5ae2?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/6467/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `68.98% <ø> (+0.02%)` | :arrow_up: | |
| [notebook-migration-service](https://app.codecov.io/gh/apache/texera/pull/6467/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 [c7473a1](https://app.codecov.io/gh/apache/texera/commit/c7473a1d8c8bf68f5cfab4ec4968982173ac5ae2?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/6467/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `91.19% <ø> (ø)` | | Carriedforward from [c7473a1](https://app.codecov.io/gh/apache/texera/commit/c7473a1d8c8bf68f5cfab4ec4968982173ac5ae2?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/6467/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 [c7473a1](https://app.codecov.io/gh/apache/texera/commit/c7473a1d8c8bf68f5cfab4ec4968982173ac5ae2?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/6467?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 tests for AdminUserService [texera]
Posted by "Ma77Ball (via GitHub)" <gi...@apache.org>.
Ma77Ball commented on code in PR #6467:
URL: https://github.com/apache/texera/pull/6467#discussion_r3627119843
##########
frontend/src/app/dashboard/service/admin/user/admin-user.service.spec.ts:
##########
@@ -0,0 +1,150 @@
+/**
+ * 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 { HttpClientTestingModule, HttpTestingController } from "@angular/common/http/testing";
+import { TestBed } from "@angular/core/testing";
+import {
+ AdminUserService,
+ USER_LIST_URL,
+ USER_UPDATE_URL,
+ USER_ADD_URL,
+ USER_CREATED_FILES,
+ USER_CREATED_DATASETS,
+ USER_CREATED_WORKFLOWS,
+ USER_ACCESS_FILES,
+ USER_ACCESS_WORKFLOWS,
+ USER_QUOTA_SIZE,
+ USER_DELETE_EXECUTION_COLLECTION,
+} from "./admin-user.service";
+import { Role } from "../../../../common/type/user";
+
+describe("AdminUserService", () => {
+ let service: AdminUserService;
+ let httpMock: HttpTestingController;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ imports: [HttpClientTestingModule],
+ providers: [AdminUserService],
+ });
+ service = TestBed.inject(AdminUserService);
+ httpMock = TestBed.inject(HttpTestingController);
+ });
+
+ afterEach(() => {
+ httpMock.verify();
+ });
+
+ it("should be created", () => {
+ expect(service).toBeTruthy();
+ });
+
+ it("getUserList() GETs the list endpoint", () => {
+ const users = [{ uid: 1 } as any];
+ let result: readonly any[] | undefined;
+ service.getUserList().subscribe(r => (result = r));
+
+ const req = httpMock.expectOne(USER_LIST_URL);
+ expect(req.request.method).toEqual("GET");
+ req.flush(users);
+
+ expect(result).toEqual(users);
+ });
+
+ it("updateUser() PUTs the full user record", () => {
+ service.updateUser(1, "Alice", "alice@x.com", Role.ADMIN, "vip").subscribe();
+
+ const req = httpMock.expectOne(USER_UPDATE_URL);
+ expect(req.request.method).toEqual("PUT");
+ expect(req.request.body).toEqual({
+ uid: 1,
+ name: "Alice",
+ email: "alice@x.com",
+ role: Role.ADMIN,
+ comment: "vip",
+ });
+ req.flush(null);
+ });
+
+ it("addUser() POSTs an empty body to the trailing-slash add endpoint", () => {
+ service.addUser().subscribe();
+
+ const req = httpMock.expectOne(`${USER_ADD_URL}/`);
+ expect(req.request.method).toEqual("POST");
+ expect(req.request.body).toEqual({});
+ req.flush({});
+ });
+
+ it("getUploadedFiles() sends the uid as a user_id query param", () => {
+ service.getUploadedFiles(9).subscribe();
+
+ const req = httpMock.expectOne(r => r.url === USER_CREATED_FILES);
+ expect(req.request.params.get("user_id")).toEqual("9");
+ req.flush([]);
+ });
+
+ it("getCreatedDatasets() GETs without a query param", () => {
+ service.getCreatedDatasets(9).subscribe();
+
+ const req = httpMock.expectOne(USER_CREATED_DATASETS);
+ expect(req.request.method).toEqual("GET");
+ expect(req.request.params.keys().length).toEqual(0);
+ req.flush([]);
+ });
+
+ it("getCreatedWorkflows() sends the uid as a user_id query param", () => {
+ service.getCreatedWorkflows(3).subscribe();
+
+ const req = httpMock.expectOne(r => r.url === USER_CREATED_WORKFLOWS);
+ expect(req.request.params.get("user_id")).toEqual("3");
+ req.flush([]);
+ });
+
+ it("getAccessFiles() sends the uid as a user_id query param", () => {
+ service.getAccessFiles(3).subscribe();
+
+ const req = httpMock.expectOne(r => r.url === USER_ACCESS_FILES);
+ expect(req.request.params.get("user_id")).toEqual("3");
+ req.flush([]);
+ });
+
+ it("getAccessWorkflows() sends the uid as a user_id query param", () => {
+ service.getAccessWorkflows(3).subscribe();
+
+ const req = httpMock.expectOne(r => r.url === USER_ACCESS_WORKFLOWS);
+ expect(req.request.params.get("user_id")).toEqual("3");
+ req.flush([]);
+ });
+
+ it("getExecutionQuota() sends the uid as a user_id query param", () => {
+ service.getExecutionQuota(3).subscribe();
+
+ const req = httpMock.expectOne(r => r.url === USER_QUOTA_SIZE);
+ expect(req.request.params.get("user_id")).toEqual("3");
+ req.flush([]);
+ });
+
+ it("deleteExecutionCollection() DELETEs the per-execution endpoint", () => {
+ service.deleteExecutionCollection(77).subscribe();
+
+ const req = httpMock.expectOne(`${USER_DELETE_EXECUTION_COLLECTION}/77`);
+ expect(req.request.method).toEqual("DELETE");
+ req.flush(null);
+ });
+});
Review Comment:
Added an error-propagation block that flushes a 500 for every live-route method and asserts the error reaches the subscriber. I left the three orphaned methods out of these error cases per the note below.
##########
frontend/src/app/dashboard/service/admin/user/admin-user.service.spec.ts:
##########
@@ -0,0 +1,150 @@
+/**
+ * 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 { HttpClientTestingModule, HttpTestingController } from "@angular/common/http/testing";
+import { TestBed } from "@angular/core/testing";
+import {
+ AdminUserService,
+ USER_LIST_URL,
+ USER_UPDATE_URL,
+ USER_ADD_URL,
+ USER_CREATED_FILES,
+ USER_CREATED_DATASETS,
+ USER_CREATED_WORKFLOWS,
+ USER_ACCESS_FILES,
+ USER_ACCESS_WORKFLOWS,
+ USER_QUOTA_SIZE,
+ USER_DELETE_EXECUTION_COLLECTION,
+} from "./admin-user.service";
+import { Role } from "../../../../common/type/user";
+
+describe("AdminUserService", () => {
+ let service: AdminUserService;
+ let httpMock: HttpTestingController;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ imports: [HttpClientTestingModule],
+ providers: [AdminUserService],
+ });
+ service = TestBed.inject(AdminUserService);
+ httpMock = TestBed.inject(HttpTestingController);
+ });
+
+ afterEach(() => {
+ httpMock.verify();
+ });
+
+ it("should be created", () => {
+ expect(service).toBeTruthy();
+ });
+
+ it("getUserList() GETs the list endpoint", () => {
+ const users = [{ uid: 1 } as any];
+ let result: readonly any[] | undefined;
+ service.getUserList().subscribe(r => (result = r));
+
+ const req = httpMock.expectOne(USER_LIST_URL);
+ expect(req.request.method).toEqual("GET");
+ req.flush(users);
+
+ expect(result).toEqual(users);
+ });
+
+ it("updateUser() PUTs the full user record", () => {
+ service.updateUser(1, "Alice", "alice@x.com", Role.ADMIN, "vip").subscribe();
+
+ const req = httpMock.expectOne(USER_UPDATE_URL);
+ expect(req.request.method).toEqual("PUT");
+ expect(req.request.body).toEqual({
+ uid: 1,
+ name: "Alice",
+ email: "alice@x.com",
+ role: Role.ADMIN,
+ comment: "vip",
+ });
+ req.flush(null);
+ });
+
+ it("addUser() POSTs an empty body to the trailing-slash add endpoint", () => {
+ service.addUser().subscribe();
+
+ const req = httpMock.expectOne(`${USER_ADD_URL}/`);
+ expect(req.request.method).toEqual("POST");
+ expect(req.request.body).toEqual({});
+ req.flush({});
+ });
+
+ it("getUploadedFiles() sends the uid as a user_id query param", () => {
Review Comment:
You are right that `getUploadedFiles`, `getCreatedDatasets`, and `getAccessFiles` hit routes that no longer exist. I will drop those three methods, their tests, and the unused URL constants in a follow-up PR so this one stays scoped to test coverage.
--
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 tests for AdminUserService [texera]
Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan merged PR #6467:
URL: https://github.com/apache/texera/pull/6467
--
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 tests for AdminUserService [texera]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #6467:
URL: https://github.com/apache/texera/pull/6467#discussion_r3598560400
##########
frontend/src/app/dashboard/service/admin/user/admin-user.service.spec.ts:
##########
@@ -0,0 +1,150 @@
+/**
+ * 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 { HttpClientTestingModule, HttpTestingController } from "@angular/common/http/testing";
+import { TestBed } from "@angular/core/testing";
+import {
+ AdminUserService,
+ USER_LIST_URL,
+ USER_UPDATE_URL,
+ USER_ADD_URL,
+ USER_CREATED_FILES,
+ USER_CREATED_DATASETS,
+ USER_CREATED_WORKFLOWS,
+ USER_ACCESS_FILES,
+ USER_ACCESS_WORKFLOWS,
+ USER_QUOTA_SIZE,
+ USER_DELETE_EXECUTION_COLLECTION,
+} from "./admin-user.service";
+import { Role } from "../../../../common/type/user";
+
+describe("AdminUserService", () => {
+ let service: AdminUserService;
+ let httpMock: HttpTestingController;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ imports: [HttpClientTestingModule],
+ providers: [AdminUserService],
+ });
+ service = TestBed.inject(AdminUserService);
+ httpMock = TestBed.inject(HttpTestingController);
+ });
+
+ afterEach(() => {
+ httpMock.verify();
+ });
+
+ it("should be created", () => {
+ expect(service).toBeTruthy();
+ });
+
+ it("getUserList() GETs the list endpoint", () => {
+ const users = [{ uid: 1 } as any];
+ let result: readonly any[] | undefined;
+ service.getUserList().subscribe(r => (result = r));
+
+ const req = httpMock.expectOne(USER_LIST_URL);
+ expect(req.request.method).toEqual("GET");
+ req.flush(users);
+
+ expect(result).toEqual(users);
+ });
+
+ it("updateUser() PUTs the full user record", () => {
+ service.updateUser(1, "Alice", "alice@x.com", Role.ADMIN, "vip").subscribe();
+
+ const req = httpMock.expectOne(USER_UPDATE_URL);
+ expect(req.request.method).toEqual("PUT");
+ expect(req.request.body).toEqual({
+ uid: 1,
+ name: "Alice",
+ email: "alice@x.com",
+ role: Role.ADMIN,
+ comment: "vip",
+ });
+ req.flush(null);
+ });
+
+ it("addUser() POSTs an empty body to the trailing-slash add endpoint", () => {
+ service.addUser().subscribe();
+
+ const req = httpMock.expectOne(`${USER_ADD_URL}/`);
+ expect(req.request.method).toEqual("POST");
+ expect(req.request.body).toEqual({});
+ req.flush({});
+ });
+
+ it("getUploadedFiles() sends the uid as a user_id query param", () => {
+ service.getUploadedFiles(9).subscribe();
+
+ const req = httpMock.expectOne(r => r.url === USER_CREATED_FILES);
+ expect(req.request.params.get("user_id")).toEqual("9");
+ req.flush([]);
+ });
+
+ it("getCreatedDatasets() GETs without a query param", () => {
+ service.getCreatedDatasets(9).subscribe();
+
+ const req = httpMock.expectOne(USER_CREATED_DATASETS);
+ expect(req.request.method).toEqual("GET");
+ expect(req.request.params.keys().length).toEqual(0);
+ req.flush([]);
+ });
+
+ it("getCreatedWorkflows() sends the uid as a user_id query param", () => {
+ service.getCreatedWorkflows(3).subscribe();
+
+ const req = httpMock.expectOne(r => r.url === USER_CREATED_WORKFLOWS);
+ expect(req.request.params.get("user_id")).toEqual("3");
+ req.flush([]);
+ });
+
+ it("getAccessFiles() sends the uid as a user_id query param", () => {
+ service.getAccessFiles(3).subscribe();
+
+ const req = httpMock.expectOne(r => r.url === USER_ACCESS_FILES);
+ expect(req.request.params.get("user_id")).toEqual("3");
+ req.flush([]);
+ });
+
+ it("getAccessWorkflows() sends the uid as a user_id query param", () => {
+ service.getAccessWorkflows(3).subscribe();
+
+ const req = httpMock.expectOne(r => r.url === USER_ACCESS_WORKFLOWS);
+ expect(req.request.params.get("user_id")).toEqual("3");
+ req.flush([]);
+ });
+
+ it("getExecutionQuota() sends the uid as a user_id query param", () => {
+ service.getExecutionQuota(3).subscribe();
+
+ const req = httpMock.expectOne(r => r.url === USER_QUOTA_SIZE);
+ expect(req.request.params.get("user_id")).toEqual("3");
+ req.flush([]);
+ });
+
+ it("deleteExecutionCollection() DELETEs the per-execution endpoint", () => {
+ service.deleteExecutionCollection(77).subscribe();
+
+ const req = httpMock.expectOne(`${USER_DELETE_EXECUTION_COLLECTION}/77`);
+ expect(req.request.method).toEqual("DELETE");
+ req.flush(null);
+ });
+});
Review Comment:
The linked issue (#6455) calls for exercising both success and error paths, but this spec only covers success responses. Add tests that verify each AdminUserService method propagates HTTP errors (e.g., a 500 response reaches the subscriber's error handler).
--
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 tests for AdminUserService [texera]
Posted by "Ma77Ball (via GitHub)" <gi...@apache.org>.
Ma77Ball commented on PR #6467:
URL: https://github.com/apache/texera/pull/6467#issuecomment-4995439853
/request-review @mengw15
--
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 tests for AdminUserService [texera]
Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 commented on code in PR #6467:
URL: https://github.com/apache/texera/pull/6467#discussion_r3598699393
##########
frontend/src/app/dashboard/service/admin/user/admin-user.service.spec.ts:
##########
@@ -0,0 +1,150 @@
+/**
+ * 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 { HttpClientTestingModule, HttpTestingController } from "@angular/common/http/testing";
+import { TestBed } from "@angular/core/testing";
+import {
+ AdminUserService,
+ USER_LIST_URL,
+ USER_UPDATE_URL,
+ USER_ADD_URL,
+ USER_CREATED_FILES,
+ USER_CREATED_DATASETS,
+ USER_CREATED_WORKFLOWS,
+ USER_ACCESS_FILES,
+ USER_ACCESS_WORKFLOWS,
+ USER_QUOTA_SIZE,
+ USER_DELETE_EXECUTION_COLLECTION,
+} from "./admin-user.service";
+import { Role } from "../../../../common/type/user";
+
+describe("AdminUserService", () => {
+ let service: AdminUserService;
+ let httpMock: HttpTestingController;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ imports: [HttpClientTestingModule],
+ providers: [AdminUserService],
+ });
+ service = TestBed.inject(AdminUserService);
+ httpMock = TestBed.inject(HttpTestingController);
+ });
+
+ afterEach(() => {
+ httpMock.verify();
+ });
+
+ it("should be created", () => {
+ expect(service).toBeTruthy();
+ });
+
+ it("getUserList() GETs the list endpoint", () => {
+ const users = [{ uid: 1 } as any];
+ let result: readonly any[] | undefined;
+ service.getUserList().subscribe(r => (result = r));
+
+ const req = httpMock.expectOne(USER_LIST_URL);
+ expect(req.request.method).toEqual("GET");
+ req.flush(users);
+
+ expect(result).toEqual(users);
+ });
+
+ it("updateUser() PUTs the full user record", () => {
+ service.updateUser(1, "Alice", "alice@x.com", Role.ADMIN, "vip").subscribe();
+
+ const req = httpMock.expectOne(USER_UPDATE_URL);
+ expect(req.request.method).toEqual("PUT");
+ expect(req.request.body).toEqual({
+ uid: 1,
+ name: "Alice",
+ email: "alice@x.com",
+ role: Role.ADMIN,
+ comment: "vip",
+ });
+ req.flush(null);
+ });
+
+ it("addUser() POSTs an empty body to the trailing-slash add endpoint", () => {
+ service.addUser().subscribe();
+
+ const req = httpMock.expectOne(`${USER_ADD_URL}/`);
+ expect(req.request.method).toEqual("POST");
+ expect(req.request.body).toEqual({});
+ req.flush({});
+ });
+
+ it("getUploadedFiles() sends the uid as a user_id query param", () => {
Review Comment:
Not blocking — a note on the three methods this and the two tests below pin: `getUploadedFiles`, `getCreatedDatasets`, and `getAccessFiles` are orphaned dead code calling endpoints that no longer exist. `AdminUserResource` (`/admin/user`) only defines `list / update / add / created_workflows / access_workflows / user_quota_size / deleteCollection`; a repo-wide search finds no `uploaded_files` or `access_files` route anywhere (`created_datasets` exists only under the session-scoped `/quota` resource); and no frontend component calls any of the three — calling them would 404. They were live once, but #2781 (Remove File-Related Components) deleted their callers and backend routes and left the service methods behind. Since `HttpTestingController` intercepts everything, these tests stay green while the methods themselves are unusable.
Same situation as #6289/#6305: consider dropping these three tests and deleting the three methods (+ URL constants) in a follow-up instead of cementing them. The other eight tests all target real routes and look good.
--
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 tests for AdminUserService [texera]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #6467:
URL: https://github.com/apache/texera/pull/6467#issuecomment-4990873907
<!-- 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