Skip to content
quarry Artifact [9f63b90966]
Login

Artifact [9f63b90966]

Artifact 9f63b90966a7e6bc91f59ef1738a35854f96dc19ef8e95342e9032f60fa81db6:


package web

import (
	"html/template"
	"strings"
	"testing"
)

// A device name beside a full IPv6 address is wider than a phone, and
// the wrapper's sideways scroll is one nobody finds inside a card. The
// session table stops being a table below the fold: one block per
// device, each cell under the name it goes by.
func TestSessionTableStacksOnAPhone(t *testing.T) {
	for _, want := range []string{".dt-stack thead { display: none; }", `.dt-stack td[data-label]::before`} {
		if !strings.Contains(sheet, want) {
			t.Errorf("FAIL: the stacked layout is not in the served sheet: missing %q", want)
		}
	}
	// base is CLONED, never executed: executing it would freeze it and
	// every page built from it afterwards would fail to clone.
	tpl := template.Must(template.Must(base.Clone()).Parse(`{{define "content"}}{{end}}`))
	var b strings.Builder
	if err := tpl.ExecuteTemplate(&b, "session-table", map[string]any{
		"Sessions": []sessionRow{{ID: "a", Agent: "Safari on iPhone", IP: "2a09::1", Created: "2026-09-12T10:00:00Z"}},
		"This":     "a", "Action": "/me/sessions/end", "ShowAccount": false,
	}); err != nil {
		t.Fatal(err)
	}
	got := b.String()
	for _, want := range []string{`class="dt dt-stack"`, `data-label="Signed in"`, `data-label="Last seen"`} {
		if !strings.Contains(got, want) {
			t.Errorf("FAIL: the table cannot stack: missing %s", want)
		}
	}
	t.Log("ok: a phone reads the sessions as blocks, not as a table it must drag sideways")
}