oficina / docs Public

Clone
git clone https://amadan.net/oficina/docs

Plain git — no account needed to clone.

Download

Download this file

1package docs
2
3import (
4 "context"
5 "net/http"
6 "strings"
7 "testing"
8)
9
10// The read view must render its content server-side whether or not the
11// editor loads. Spec §6.2: reading works with no script. A page that
12// renders only after the bundle executes is a regression against that,
13// and it is invisible in a browser that runs the script.
14func TestShowRendersContentWithoutScript(t *testing.T) {
15 app, err := NewForTest(t)
16 if err != nil {
17 t.Fatalf("NewForTest: %v", err)
18 }
19 ctx := context.Background()
20 owner := app.TestPerson(t, "reader@example.com")
21 doc, _ := app.Store().Create(ctx, owner, "Readable")
22 update := readFixture(t, "../../fixtures/vectors/fragment/simple.bin")
23 if _, err := app.Store().ApplyUpdate(ctx, doc, app.TestActorFor(t, doc), update); err != nil {
24 t.Fatalf("ApplyUpdate: %v", err)
25 }
26
27 req := app.TestRequest(t, "reader@example.com", http.MethodGet, "/d/"+doc.Sqid, nil)
28 rec := serve(app, req)
29 body := rec.Body.String()
30 if !strings.Contains(body, "First paragraph.") {
31 t.Error("the document's text is not in the server-rendered HTML")
32 }
33 if !strings.Contains(body, "docs-editor") {
34 t.Error("no editor mount point")
35 }
36 if !strings.Contains(body, editorScriptPath()) {
37 t.Error("the editor bundle is not referenced")
38 }
39}
40