Repository navigation
Description
Task Summary
AdminSettingsComponent is at 85.84 % with 8 uncovered lines and 8 half-taken branches — the image-upload reader, the "settings not loaded yet" guards on each save action, and a couple of reset paths. All are ordinary conditionals reachable by feeding the component the right state; no infrastructure.
Pure EXTEND of admin-settings.component.spec.ts. Vitest/jsdom; see frontend/TESTING.md and frontend/AGENTS.md.
Behavior to add
AdminSettingsComponent (frontend/src/app/dashboard/component/admin/settings/admin-settings.component.ts, codecov 85.84 % — EXTEND)
onFileChange(147–153) — reads the uploaded file via aFileReaderand, on load, stores the data URL intologoDatawhentype === "logo"orfaviconDatawhentype === "mini_logo". Cover both types, and thetypeof e.target?.result === "string" ? … : nullguard by firing a load whose result is not a string. StubFileReaderdeterministically — a fake whosereadAsDataURLfiresonloadviaqueueMicrotask— rather than relying on jsdom's real async.saveLogos(170–171) — theif (this.faviconData)branch that pushes an extraupdateSetting("favicon", …)request. Cover with and without favicon data set, and assert the set of requests issued.resetTabs(227–232) —if (!this.maxFileSizeMiB || !this.chunkSizeMiB) return 0andif (!this.maxFileSizeMiB) return this.MIN_PART_SIZE_MiB. Cover each missing-value combination so both guards' true sides are taken.saveDatasetSettings(238–240) andsaveCsvSettings(294–296) — both begin withif (!this.settingsLoaded) { message.error("Settings have not loaded; refresh before saving."); return }. Assert the error is shown and no save request is made when settings have not loaded, and that a save proceeds when they have.resetCsvSettings(315) — the error handlernotificationService.error("Could not reset result panel settings…"). Flush an error from the settings service and assert it is surfaced.
Determinism notes:
- Stub
adminSettingsService,message, andnotificationService; useHttpClientTestingModuleorof(...)/throwError(...)and flush synchronously — never a real backend. - Stub
FileReaderas above so the upload test does not depend on real async timing. vi.restoreAllMocks()inafterEach;fixture.destroy()so subscriptions stop.- Assert on the request/args passed to the stubbed service and on the message shown, not on rendered DOM geometry.
Task Type
- Refactor / Cleanup
- DevOps / Deployment / CI
- Testing / QA
- Documentation
- Performance
- Other
Activity
test(frontend): cover the admin settings uploads and save guards (apa…