Skip to content

test(frontend): pin the admin settings form's wiring - #7426

Open
aglinxinyuan wants to merge 1 commit into
apache:mainfrom
aglinxinyuan:test-admin-settings-template
Open

test(frontend): pin the admin settings form's wiring#7426
aglinxinyuan wants to merge 1 commit into
apache:mainfrom
aglinxinyuan:test-admin-settings-template

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

The settings form is four near-identical Save/Reset cards, three near-identical upload blocks, and twelve sidebar switches. All 31 of its template listeners and all 34 of its branches were unhit, because the existing suite calls the component's methods directly and never renders an interaction.

The realistic defect in a template shaped like this is cross-wiring from copy-paste, and two switch keys are one character apart:

  • workflow_enabled vs workflows_enabled
  • dataset_enabled vs datasets_enabled

A swap between either pair is invisible on screen and silently toggles the wrong sidebar entry.

Adds 12 tests. The central one walks the twelve switches in template order and asserts each flips exactly one setting and no other — that is what catches a swap between the confusable pairs. Alongside it:

  • the Hub children locked until Hub is on, and the Your Work children until Your Work is on
  • the three section switches never locked, since locking one behind itself would make it impossible to switch back on
  • each of the five number inputs owning its own field
  • each card's Save and Reset reaching that card's own handler
  • each "Choose a …" button opening its own hidden input, and each file input tagging its change with its own setting key
  • the previews rendering only for images that have been chosen

Verified by mutation, all reverted (template diff empty):

Mutation Result
make the workflows switch write workflow_enabled red
make the datasets switch write dataset_enabled red
gate a Hub child on Your Work instead red
gate About on Hub red
gate the Hub section on itself red
point the tabs Save at the dataset handler red
point the csv Reset at the branding handler red
make the logo picker open the favicon input red
tag the mini-logo change as logo red
make the chunk-size input write maxFileSizeMiB red
render the logo preview unconditionally red
make the mini-logo preview show the logo red

The preview mutation survived its first run: the test set logoData, so removing that image's *ngIf changed nothing. A no-data case now covers it — without the guard a card renders a broken image on first load.

No production file is touched.

Any related issues, documentation, discussions?

Closes #7423

How was this PR tested?

npx ng test --watch=false --include="**/admin-settings.component.spec.ts"
 Test Files  1 passed (1)
      Tests  36 passed (36)

12 new on top of the existing 24. yarn format:ci passes.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 5)

The settings form is four near-identical Save/Reset cards, three near-identical
upload blocks, and twelve switches whose keys include two confusable
singular/plural pairs: workflow_enabled vs workflows_enabled, and
dataset_enabled vs datasets_enabled. Cross-wiring from copy-paste is the
realistic defect, and the existing suite calls the component's methods directly
without ever rendering an interaction.

Adds 12 tests. The central one walks the twelve switches in template order and
asserts each flips exactly one setting and no other, which is what catches a
swap between the confusable pairs. Alongside it: the Hub and Your Work children
being locked until their section is on, the three section switches never being
locked, each number input owning its own field, each card's Save and Reset
reaching that card's handler, each picker opening its own hidden input, each
file input tagging its change with its own setting key, and the previews
appearing only for images that have been chosen.

No production file is touched.
@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Aug 8, 2026
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @mengw15
    You can notify them by mentioning @mengw15 in a comment.

@aglinxinyuan
aglinxinyuan requested a review from mengw15 August 8, 2026 07:53
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.15%. Comparing base (fe89db4) to head (6e4c1cd).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7426      +/-   ##
============================================
+ Coverage     85.00%   85.15%   +0.15%     
  Complexity     4148     4148              
============================================
  Files          1169     1169              
  Lines         46740    46740              
  Branches       5202     5202              
============================================
+ Hits          39731    39803      +72     
+ Misses         5289     5216      -73     
- Partials       1720     1721       +1     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from fe89db4
agent-service 85.50% <ø> (ø) Carriedforward from fe89db4
amber 80.85% <ø> (ø) Carriedforward from fe89db4
computing-unit-managing-service 50.72% <ø> (ø) Carriedforward from fe89db4
config-service 65.97% <ø> (ø) Carriedforward from fe89db4
file-service 69.05% <ø> (ø) Carriedforward from fe89db4
frontend 87.49% <ø> (+0.34%) ⬆️
notebook-migration-service 78.89% <ø> (ø) Carriedforward from fe89db4
pyamber 97.55% <ø> (ø) Carriedforward from fe89db4
workflow-compiling-service 26.31% <ø> (ø) Carriedforward from fe89db4

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mengw15 mengw15 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds interaction-level unit tests that render AdminSettingsComponent and validate the template wiring for the sidebar switches, numeric inputs, card Save/Reset buttons, branding upload pickers, and preview rendering—specifically targeting copy/paste cross-wiring risks in the admin settings template.

Changes:

  • Introduces a new “wiring” test suite that drives the template via DOM events (switch toggles, input changes, button clicks, file input changes).
  • Adds assertions that each sidebar switch flips exactly its intended config key (including the singular/plural near-collisions).
  • Adds coverage for enable/disable gating of child switches, per-field numeric bindings, upload picker/input routing, and conditional preview rendering.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +468 to +472
fixture.detectChanges();
// ngOnInit loads the settings; answer it so the form starts from a known state.
http.expectOne("/api/config/settings").flush({});
fixture.detectChanges();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pin the admin settings form's wiring

4 participants