package console
import (
"context"
"fmt"
"html"
"html/template"
"net/http"
"net/url"
"os"
"regexp"
"slices"
"strings"
"testing"
"time"
"github.com/carlosframework/platform/internal/provision"
"github.com/carlosframework/platform/internal/release"
"github.com/carlosframework/platform/internal/status"
"github.com/carlosframework/platform/internal/updatewords"
)
// pageFx is zdd-6 Task 12's heldFixture (kass's web instance, on stable, with
// box1 reporting it held: installed v2, serving v1) plus the store helpers the
// instance page's Updates section tests use. Every helper writes the store
// directly, bypassing the settings doors.
type pageFx struct {
*consoleFixture
t *testing.T
// report is box1's update report for heldHost, written by boxesEnforce.
report *status.HostUpdates
}
func updatesPageFixture(t *testing.T) *pageFx {
t.Helper()
return &pageFx{consoleFixture: heldFixture(t), t: t}
}
// esc is a text as the instance page's html/template prints it.
func esc(s string) string { return template.HTMLEscapeString(s) }
// getPage GETs u, a full URL or a redirect's path.
func (fx *pageFx) getPage(c *http.Client, u string) (int, string) {
fx.t.Helper()
if strings.HasPrefix(u, "/") {
u = fx.ts.URL + u
}
code, _, body := get(fx.t, c, u)
return code, body
}
// updatesSection is the instance page's Updates section, "" when none.
func updatesSection(body string) string {
i := strings.Index(body, `