Skip to content
quarry Artifact [fcffc18234]
Login

Artifact [fcffc18234]

Artifact fcffc18234aadff918263ce478583dbbbdadda9cf377556f3316e76629393478:


package web

import (
	"strings"
	"testing"
)

// The composer offers two views of one draft: Rich, reading its blocks
// from this repository's markup-blocks and its pickers' lists from
// ref.suggest, and Markdown, the textarea the form posts. There is no third Preview: Rich renders through the same
// pipeline. Without script the tab bar stays hidden and the textarea is
// the composer.
func TestTheComposerOffersRichAndMarkdown(t *testing.T) {
	var b strings.Builder
	if err := noHooks.template(forumAnnouncePage).ExecuteTemplate(&b, "content", pageData{Repo: "alpha", Composer: true}); err != nil {
		t.Fatal(err)
	}
	s := b.String()
	if !strings.Contains(s, `data-hook="composer-rich"`) || !strings.Contains(s, `data-blocks="/r/alpha/markup-blocks"`) {
		t.Error("FAIL: the composer has no Rich view reading this repository's blocks")
	}
	if !strings.Contains(s, `data-suggest="/r/alpha/ref.suggest"`) {
		t.Error("FAIL: the Rich view's pickers do not ask this repository")
	}
	if !strings.Contains(s, `data-hook="composer-write"`) || strings.Contains(s, `data-tab="preview"`) {
		t.Error("FAIL: the composer's tabs are not Rich and Markdown")
	}
	if !strings.Contains(s, `<div class="f-tabs" hidden>`) || !strings.Contains(s, `name="body"`) {
		t.Error("FAIL: without script the composer is not the plain textarea")
	}
}