fix: webserver test skips when frontend assets not built#204
Merged
Conversation
The TestIndexHTMLReferencesExistingAssets test only checked whether the assets/ directory existed, but not whether it contained actual JS/CSS bundles. On Windows CI (and any env where npm run build hasn't run), the directory could exist empty or with non-bundle files, causing the test to proceed and fail when the SPA fallback served index.html instead of the expected asset content types. Now the test also verifies that assets/ contains at least one .js or .css file before proceeding, and skips with a clear message otherwise. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Windows CI flakiness in internal/webserver by making the TestIndexHTMLReferencesExistingAssets skip guard verify that frontend bundles are actually present, not just that the assets/ directory exists.
Changes:
- Read
dist/assetsdirectory entries and fail fast on unexpected FS errors. - Skip
TestIndexHTMLReferencesExistingAssetswhendist/assetsexists but contains no.js/.cssbundles, with a message pointing tonpm run build.
Show a summary per file
| File | Description |
|---|---|
| internal/webserver/server_test.go | Strengthens the test precondition for embedded frontend assets to avoid false failures when assets aren’t built. |
Copilot's findings
Comments suppressed due to low confidence (1)
internal/webserver/server_test.go:186
- The skip check only requires either a .js or .css file. If a partial/cached build leaves just one of those (or only non-bundle files), this test will still run and then fail later when a referenced asset is missing and served by the SPA fallback. Since
index.htmlreferences both JS and CSS bundles, consider trackinghasJSandhasCSS(similar toTestEmbeddedAssetsDirectoryContainsBundles) and skipping unless both are present.
var hasBundles bool
for _, e := range entries {
if !e.IsDir() {
ext := filepath.Ext(e.Name())
if ext == ".js" || ext == ".css" {
hasBundles = true
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Fix 'artefact' → 'artifact' misspelling in webserver test - Use runtime.GOOS to pick platform-correct absolute path in suggest test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
TestIndexHTMLReferencesExistingAssetsfails on Windows CI becausenpm run buildonly runs on the ubuntu-latest matrix. The test's skip guard only checked whether theassets/directory existed — not whether it contained actual JS/CSS bundles. If the directory exists but is empty (cache artefact, partial build), the test proceeds and fails when the SPA fallback servesindex.htmlinstead of the expected asset content types.Fix
After confirming
assets/exists, the test now also verifies it contains at least one.jsor.cssfile. If not, it skips with a descriptive message pointing atnpm run build.Verification
go test -count=1 -v ./internal/webserver/...— all passgo test ./...— full suite greengo vet ./...— cleanCo-authored-by: Copilot 223556219+Copilot@users.noreply.github.com