Skip to content

add unit test coverage for AdminSettingsService #6260

Description

@aglinxinyuan

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

  • Refactor / Cleanup
  • DevOps / Deployment / CI
  • Testing / QA
  • Documentation
  • Performance
  • Other

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions