Remove _getChangeUrlAnd methods This methods obscure the actual calls unnecessarily. As can be seen from this change, making direct call to restApiHelper is almost the same amount of code. Most of the implementation was just forwarding parameters, which is not necessary, since we can construct the "input object" right away. Additionally replace send with fetch. Part of the difference that existed in the past between send() (with parsed: false) and fetchRawJSON() is that send() used to also check the status of the response. That's why when we replace send() with fetch(), we set reportServerError to true. Moving to fetch removes semantics of send(), where it sometimes returns parsed response and sometimes plain Response. As evident from usage in corresponding tests, this used to lead to confusion. Developers would expect parsed response, where in fact no parsing is being done. reportEndpointAsId is likely just a typo that existed previously in the codebase. It's never read (only set), and the used in the same places where reportEndpointAsIs makes sense. So we treat it as such. Similarly reportUrlAsIs is likely a mistake due to this being a parameter that is used by fetchRawJSON, but not by send(). It would previously be dropped without being used, with this change we treat it as reportEndpointAsIs. The setChangeTopic and setChangeHashtags can return undefined (and could return 'null' in the past). The return type annotation is wrong here. There was an issue of undefined result not being processed correctly, but that has been addressed in previous change While converting _getDiffComments, i've noticed _getDiffCommentsFetchUrl is unused. Likely it became unused from edits in the past. Removed. Google-Bug-Id: b/297849592 Release-Notes: skip Change-Id: I699a3bb79e3b1e44a70de6b770539708ff156fda
diff --git a/polygerrit-ui/app/test/mocks/gr-rest-api_mock.ts b/polygerrit-ui/app/test/mocks/gr-rest-api_mock.ts index 299d9ac..3314ce4 100644 --- a/polygerrit-ui/app/test/mocks/gr-rest-api_mock.ts +++ b/polygerrit-ui/app/test/mocks/gr-rest-api_mock.ts
@@ -135,7 +135,7 @@ deleteChangeCommitMessage(): Promise<Response> { return Promise.resolve(new Response()); }, - deleteComment(): Promise<CommentInfo> { + deleteComment(): Promise<CommentInfo | undefined> { throw new Error('deleteComment() not implemented by RestApiMock.'); }, deleteDiffDraft(): Promise<Response> { @@ -165,7 +165,7 @@ deleteWatchedProjects(): Promise<Response> { return Promise.resolve(new Response()); }, - executeChangeAction(): Promise<Response | undefined> { + executeChangeAction(): Promise<Response> { return Promise.resolve(new Response()); }, finalize(): void {},