aglinxinyuan opened a new issue, #6260:
URL: https://github.com/apache/texera/issues/6260

   ### Task Summary
   
   Add `admin-settings.service.spec.ts` covering `AdminSettingsService`, the 
thin REST client for site-wide key/value settings. Use Angular's 
`HttpTestingController` to assert the request each method makes.
   
   ## Background
   
   
`frontend/src/app/dashboard/service/admin/settings/admin-settings.service.ts` 
wraps three endpoints under `/api/admin/settings`. Its `getSetting` 
response-mapping (`resp?.value ?? null`) is untested.
   
   ```ts
   getSetting(key: string): Observable<string> {
     return this.http.get<{ key: string; value: string 
}>(`${this.BASE_URL}/${key}`).pipe(map(resp => resp?.value ?? null));
   }
   updateSetting(key: string, value: string) { return 
this.http.put(`${this.BASE_URL}/${key}`, { value }, { withCredentials: true }); 
}
   resetSetting(key: string) { return 
this.http.post(`${this.BASE_URL}/reset/${key}`, {}); }
   ```
   
   ## Behavior to pin
   
   | Method | Contract (assert with `HttpTestingController`) |
   | --- | --- |
   | `getSetting(k)` | issues `GET /api/admin/settings/{k}`; a `{ value }` body 
maps to that value; an empty/absent body maps to `null` |
   | `updateSetting(k, v)` | issues `PUT /api/admin/settings/{k}` with body `{ 
value: v }` and `withCredentials: true` |
   | `resetSetting(k)` | issues `POST /api/admin/settings/reset/{k}` with an 
empty `{}` body |
   
   Set up `TestBed` with `HttpClientTestingModule` (or the equivalent 
`provideHttpClientTesting`) and `flush()` each expected request; `afterEach` 
calls `httpMock.verify()`. Any existing `*.service.spec.ts` under 
`frontend/src/app` that uses `HttpTestingController` is a good template.
   
   ## Scope
   
   - New spec: 
`frontend/src/app/dashboard/service/admin/settings/admin-settings.service.spec.ts`.
   - No production-code changes.
   
   ### Task Type
   
   - [ ] Refactor / Cleanup
   - [ ] DevOps / Deployment / CI
   - [x] Testing / QA
   - [ ] Documentation
   - [ ] Performance
   - [ ] Other
   


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