package web
import (
"strings"
"testing"
)
// The composer offers two views of one draft: Rich, reading its blocks
// from this repository's markup-blocks, 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-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")
}
}