Skip to content
quarry Artifact [1a9ca5ded8]
Login

Artifact [1a9ca5ded8]

Artifact 1a9ca5ded8d3ccd3051b723a4f7f0f291b6e634ff7ee858c9a173b90ec5c336f:


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)
		}
	}
}

// The live patch draws the side column with the page's posture: on a
// read-only mirror it must not bring the edit form back (2026-10-29).
func TestALivePatchOnAMirrorDrawsNoEditForm(t *testing.T) {
	tk := tktFixture()
	var p posture
	p.Mirror.Tracking, p.Mirror.URL = true, "https://fossil.craftdesign.group/zit"
	frag := ticketParts(&noHooks, pageData{Repo: "zit", Ticket: tk, CanWrite: true, Posture: p})
	if frag == "" || strings.Contains(frag, `class="tkt-fields"`) {
		t.Errorf("FAIL: the live side column on a read-only mirror draws the edit form:\n%s", frag)
	}
	frag = ticketParts(&noHooks, pageData{Repo: "zit", Ticket: tk, CanWrite: true})
	if !strings.Contains(frag, `class="tkt-fields"`) {
		t.Error("FAIL: a writable ticket's live side column lost its form")
	}
}