Some checks failed
CI / goreleaser-lint (pull_request) Successful in 11s
CI / format (pull_request) Successful in 2m38s
CI / test (pull_request) Successful in 5m0s
CI / lint (pull_request) Successful in 3m5s
CI / build (pull_request) Successful in 3m16s
CI / e2e (pull_request) Failing after 28m15s
The test web server and Hako container previously ran on isolated Docker networks, so Hako could not fetch URLs like http://localhost:32865 (the host-mapped port) from inside its container. Most tests passed vacuously because they only checked DOM containers; the Archive tests failed because they tried to click an actual link item that was never created. Changes: - Add a shared Docker network so both containers can communicate by alias - Test web server registers as hako-testserver and returns that as its URL - Hako container joins the same network and can resolve the alias - CreateLink now navigates to /home before each call so it can be invoked multiple times in a row (the form redirects to /links after submission) - IsVisible uses .First() to avoid Playwright strict-mode errors when a selector matches multiple elements - Archive tests use .link-item instead of the never-matching a[href*='/links/'] selector - Bump Dockerfile.e2e Alpine to 3.23 to match the production Containerfile
34 lines
1 KiB
Go
34 lines
1 KiB
Go
package e2eutil
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"sync"
|
|
|
|
"github.com/testcontainers/testcontainers-go"
|
|
"github.com/testcontainers/testcontainers-go/network"
|
|
)
|
|
|
|
// Shared network used by the test web server and Hako container so that
|
|
// Hako can fetch URLs from the test web server via Docker DNS.
|
|
var (
|
|
sharedNetwork *testcontainers.DockerNetwork
|
|
sharedNetworkErr error
|
|
sharedNetworkOnce sync.Once
|
|
)
|
|
|
|
// Network alias used by the test web server inside the shared network.
|
|
const testServerAlias = "hako-testserver"
|
|
|
|
// getSharedNetwork lazily creates a shared Docker network for the test process.
|
|
// Both StartTestWebServer and StartHakoContainer attach to it so containers
|
|
// can communicate by alias.
|
|
func getSharedNetwork(ctx context.Context) (*testcontainers.DockerNetwork, error) {
|
|
sharedNetworkOnce.Do(func() {
|
|
sharedNetwork, sharedNetworkErr = network.New(ctx)
|
|
})
|
|
if sharedNetworkErr != nil {
|
|
return nil, fmt.Errorf("failed to create shared network: %w", sharedNetworkErr)
|
|
}
|
|
return sharedNetwork, nil
|
|
}
|