Skip to content
quarry Artifact [ee9a659abc]
Login

Artifact [ee9a659abc]

Artifact ee9a659abcc7d2931d069824e268db2996475666692c28da7cc58781dec03383:


package web

import (
	"bytes"
	"strings"
	"testing"
)

// The front page opens on its repositories. What the forge is, is said
// on request: a closed disclosure after the tab strip, never a
// paragraph above the listing.
func TestTheFrontPageSaysWhatItIsOnlyWhenAsked(t *testing.T) {
	var b bytes.Buffer
	if err := explorePage.ExecuteTemplate(&b, "content", pageData{InviteOnly: true}); err != nil {
		t.Fatal(err)
	}
	got := b.String()
	intro := strings.Index(got, `data-hook="forge-intro"`)
	if intro < 0 {
		t.Fatal("FAIL: a visitor has no way to learn what this forge is")
	}
	open := strings.LastIndex(got[:intro], "<")
	if !strings.HasPrefix(got[open:], "<details") {
		t.Errorf("FAIL: the introduction is not a disclosure: %q", got[open:intro])
	}
	if strings.Contains(got[open:intro], " open") {
		t.Error("FAIL: the introduction opens by itself")
	}
	if tabs := strings.Index(got, `class="tl-controls fleet-bar"`); tabs < 0 || tabs > intro {
		t.Error("FAIL: the introduction sits above the listing's controls")
	}
	t.Log("ok: the introduction is a closed disclosure in the filter bar")
}