package web
import (
"strings"
"testing"
)
// The ticket page's option A: who opened it beside the state, the body
// headed by its author, Critical as a hot pill, a hash as a short link,
// and on a read-only mirror one banner at the top and no edit controls.
func TestTheTicketPageReadsAsAnIssue(t *testing.T) {
tk := tktFixture()
tk.Created = "2026-10-27T20:14:57"
tk.Changes = []ticketChange{{Date: "2026-10-27T20:14:57", User: "dmestas"}}
tk.Fields = append(tk.Fields, ticketField{Name: "severity", Value: "Critical"},
ticketField{Name: "foundin", Value: "77a57718ac750f420ce44bdbc04664e3a8947a67"})
var p posture
p.Mirror.Tracking, p.Mirror.URL = true, "https://fossil.craftdesign.group/zit"
html := renderTkt(t, "content", pageData{Repo: "zit", Ticket: tk, CanWrite: true, Posture: p,
DescriptionHTML: "<h2>Reproduction</h2>"})
for _, want := range []string{
`data-hook="ticket-mirror"`, `data-hook="ticket-opened"`, `data-hook="ticket-body"`,
`tkt-pill-hot" data-hook="ticket-severity"`, `>77a57718ac75</a>`,
} {
if !strings.Contains(html, want) {
t.Errorf("FAIL: the page lacks %s", want)
}
}
for _, gone := range []string{`class="tkt-fields"`, `t-pen-desc`, `id="t-edit-title"`} {
if strings.Contains(html, gone) {
t.Errorf("FAIL: a read-only mirror draws %s", gone)
}
}
}