Skip to content

refactor(webview): extract pure HTML template functions for testability#405

Merged
nullvariant merged 2 commits into
mainfrom
issue-00110/webview-a11y-architecture
Mar 30, 2026
Merged

refactor(webview): extract pure HTML template functions for testability#405
nullvariant merged 2 commits into
mainfrom
issue-00110/webview-a11y-architecture

Conversation

@nullvariant
Copy link
Copy Markdown
Owner

Summary

  • Extract VS Code-independent pure functions from webview.ts to htmlTemplates.ts for unit testability
  • Apply a11y improvements: lang attribute (WCAG 2.1 SC 3.1.1), ARIA attributes on spinner/status, semantic <nav> and <footer> elements
  • Reduce webview.ts from 376 to 107 lines (thin wrapper delegating to pure functions)
  • Add 12 unit tests with 100% coverage on all metrics

Test plan

  • npx tsc --noEmit — no compile errors
  • npm run lint — 0 errors (63 pre-existing warnings)
  • npm run test:unit — all tests pass including 12 new htmlTemplates tests
  • npm run test:coverage — statement coverage 100% maintained, htmlTemplates.ts 100/100/100/100
  • Quality review passed (architect, security, test, a11y, CSS/UI + sergeant)

🤖 Generated with Claude Code

## Background
Quality review detected a11y issues and architecture improvements
in webview.ts.
## Changes
- Extract VS Code-independent pure functions to htmlTemplates.ts
  - buildCspString, buildDocumentHtml, buildLoadingHtml, buildErrorHtml
  - getBaseStyles for shared CSS across templates
- Reduce webview.ts from 376 to 107 lines (thin VS Code wrapper)
- Add lang="en" to loading/error HTML (WCAG 2.1 SC 3.1.1)
- Add aria-hidden="true" to spinner, role="status" to loading text
- Change nav-bar div to <nav> with aria-label
- Change div.footer to <footer> element
- Add 12 unit tests for htmlTemplates.ts (100% coverage)
- Use ErrorType alias instead of inline literal (SSOT)

🖥️ IDE: [Cursor](https://cursor.sh)
🔌 Extension: [Claude Code](https://claude.ai/download)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Model-Raw: claude-opus-4-6
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 30, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA a46a659.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@nullvariant-mimi
Copy link
Copy Markdown
Contributor

nullvariant-mimi Bot commented Mar 30, 2026

🐰 Mimi's Validation Report ✅

All checks are looking good! Great job! 🎉

⏳ Some checks are still running. I will keep watching!


バリデーターを通してくださいね

This report was carefully prepared by nullvariant-mimi[bot]

@nullvariant-slow
Copy link
Copy Markdown
Contributor

nullvariant-slow Bot commented Mar 30, 2026

🦥 Slow's Code Review 😩

...yawn... Do I really have to review this?

⚠️ TOO LONG... I can barely keep my eyes open reading these:

File Lines

| extensions/git-id-switcher/src/test/htmlTemplates.test.ts | 532 |
| extensions/git-id-switcher/src/ui/htmlTemplates.ts | 366 |

Split it up... reading long files is exhausting.


働きたくないでござる

This review was reluctantly filed by nullvariant-slow[bot]

@nullvariant-ciel
Copy link
Copy Markdown
Contributor

nullvariant-ciel Bot commented Mar 30, 2026

🕊️ Ciel's Mediation 🌤️

*~~ floating down from the clouds ~~ The zoo seems a bit noisy today...*

2 zoo members have reviewed this PR.

Zoo Member Status
🦥 Slow Commented
🐰 Mimi Commented

⚖️ The zoo has mixed opinions. Some are concerned, some are fine with it. Please review each comment carefully and make the final call.


まあまあ、ほどほどに。

This mediation was peacefully delivered by nullvariant-ciel[bot]

Combine separate `import type` and `import` statements from the same
module into a single import to fix no-duplicate-imports lint error.

🖥️ IDE: [Cursor](https://cursor.sh)
🔌 Extension: [Claude Code](https://claude.ai/download)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Model-Raw: claude-opus-4-6
@sonarqubecloud
Copy link
Copy Markdown

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@nullvariant nullvariant merged commit 05e06a3 into main Mar 30, 2026
29 checks passed
@nullvariant nullvariant deleted the issue-00110/webview-a11y-architecture branch March 30, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant