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.
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
Task Summary
Add
admin-settings.service.spec.tscoveringAdminSettingsService, the thin REST client for site-wide key/value settings. Use Angular'sHttpTestingControllerto assert the request each method makes.Background
frontend/src/app/dashboard/service/admin/settings/admin-settings.service.tswraps three endpoints under/api/admin/settings. ItsgetSettingresponse-mapping (resp?.value ?? null) is untested.Behavior to pin
HttpTestingController)getSetting(k)GET /api/admin/settings/{k}; a{ value }body maps to that value; an empty/absent body maps tonullupdateSetting(k, v)PUT /api/admin/settings/{k}with body{ value: v }andwithCredentials: trueresetSetting(k)POST /api/admin/settings/reset/{k}with an empty{}bodySet up
TestBedwithHttpClientTestingModule(or the equivalentprovideHttpClientTesting) andflush()each expected request;afterEachcallshttpMock.verify(). Any existing*.service.spec.tsunderfrontend/src/appthat usesHttpTestingControlleris a good template.Scope
frontend/src/app/dashboard/service/admin/settings/admin-settings.service.spec.ts.Task Type