Add comprehensive snapshot testing for all templ views#3
Conversation
…rap templates Co-authored-by: jveski <7576912+jveski@users.noreply.github.com>
…r templates Co-authored-by: jveski <7576912+jveski@users.noreply.github.com>
…ic branches Co-authored-by: jveski <7576912+jveski@users.noreply.github.com>
|
Incredible work honestly. 🔥 Now add a github action to run the tests in CI! |
Co-authored-by: jveski <7576912+jveski@users.noreply.github.com>
Added a comprehensive GitHub Actions CI workflow that runs all tests automatically on push and pull requests. The workflow includes dependency caching, race condition detection, and automatic templ generation. Commit: 9d3a76a Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
| - name: Run tests | ||
| run: go test ./... -v | ||
|
|
||
| - name: Run tests with race detector |
There was a problem hiding this comment.
Let's just run the tests with the race detector - no need to bother with the "Run tests" step without it
There was a problem hiding this comment.
Removed the redundant "Run tests" step. Now only running tests with the race detector. Commit: 89d7d69
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.24.0' |
There was a problem hiding this comment.
This action supports discovering the go version from the go.mod - let's use it!
There was a problem hiding this comment.
Updated to use go-version-file: 'go.mod' instead of hardcoding the version. The action will now automatically discover the Go version from go.mod. Commit: 89d7d69
…nt test step Co-authored-by: jveski <7576912+jveski@users.noreply.github.com>
| with: | ||
| go-version-file: 'go.mod' | ||
|
|
||
| - name: Cache Go modules |
There was a problem hiding this comment.
We can remove this - the github action handles caching!
There was a problem hiding this comment.
Same with "Download dependencies"
There was a problem hiding this comment.
Removed the redundant caching step since setup-go@v5 handles module caching automatically. Commit: 0586852
There was a problem hiding this comment.
Removed the redundant "Download dependencies" step since setup-go@v5 handles module downloading automatically. Commit: 537606d
Co-authored-by: jveski <7576912+jveski@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Implements snapshot-style unit tests for all templ views in the Conway repository with comprehensive coverage of logic branches and edge cases.
Overview
This PR adds a robust testing framework for templ components that:
Testing Framework
Created
internal/testing/templates.gowith utilities:RenderSnapshot()- Compare rendered output against HTML fixturesRenderSnapshotWithName()- Convenience function for test-based fixture namingRENDER_SNAPSHOTS=1is setCoverage Achieved
Modules Tested
engine/errors.templ- Error page rendering with different HTTP status codesmodules/bootstrap/bootstrap.templ- Base layout with light/dark themesmodules/kiosk/kiosk.templ- Kiosk interface with QR code generationmodules/members/member.templ- Member dashboard with status variationsmodules/auth/login.templ- Login forms with/without Turnstile CAPTCHAmodules/machines/machines.templ- Printer status displaysmodules/waiver/waiver.templ- Liability waiver forms (signed/unsigned)modules/admin/admin.templ- Admin navigation and data tablesmodules/admin/member.templ- Complex member management interfaceLogic Branches Covered
Example Test Cases
Usage
Benefits
This ensures robust protection against UI regressions while maintaining comprehensive test coverage of all templ view logic.
Fixes #2.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.