| index 9a4912b..7380ce4 100644 |
| --- a/internal/slidestest/talk_readers_test.go |
| +++ b/internal/slidestest/talk_readers_test.go |
| @@ -2,6 +2,7 @@ package slidestest |
| |
| import ( |
| "net/http" |
| + "net/http/httptest" |
| "net/url" |
| "strings" |
| "testing" |
| @@ -131,6 +132,38 @@ func TestAParkedSlideReachesNoReader(t *testing.T) { |
| }) |
| } |
| |
| +// TestAConditionalThumbnailOfAParkedSlideIsStill404: a wildcard or a |
| +// matching tag must not turn "no such slide" into "not modified". |
| +func TestAConditionalThumbnailOfAParkedSlideIsStill404(t *testing.T) { |
| + a := newApp(t) |
| + cookies := signedIn(t, a, allowedAddress) |
| + path, _, _ := markedDeck(t, a, cookies, mixedTalk) |
| + share := "/s/" + mintShareLink(t, a, path, cookies) |
| + session, _ := startPresenting(t, a, path, cookies) |
| + seq := "" |
| + if row := a.db.G.Raw("SELECT seq FROM decks WHERE sqid = ?", strings.TrimPrefix(path, "/d/")).Row(); row != nil { |
| + row.Scan(&seq) |
| + } |
| + for _, base := range []string{share, "/p/" + session} { |
| + for _, tag := range []string{"*", `"` + seq + `-pone-` + `"`, `"` + seq + `-pone-480"`, `"` + seq + `-pone-1920"`} { |
| + req := httptest.NewRequest(http.MethodGet, base+"/slides/pone.svg", nil) |
| + req.Header.Set("If-None-Match", tag) |
| + rec := httptest.NewRecorder() |
| + a.ServeHTTP(rec, req) |
| + if rec.Code != http.StatusNotFound { |
| + t.Errorf("GET %s parked, If-None-Match %s: status %d, want 404", base, tag, rec.Code) |
| + } |
| + } |
| + req := httptest.NewRequest(http.MethodGet, base+"/slides/stwo.svg", nil) |
| + req.Header.Set("If-None-Match", "*") |
| + rec := httptest.NewRecorder() |
| + a.ServeHTTP(rec, req) |
| + if rec.Code != http.StatusNotModified { |
| + t.Errorf("GET %s shown slide, If-None-Match *: status %d, want 304", base, rec.Code) |
| + } |
| + } |
| +} |
| + |
| // TestAFullOnlySlideShowsToReaders: full only is a way of giving the |
| // talk, not a way of hiding a slide: readers get it. |
| func TestAFullOnlySlideShowsToReaders(t *testing.T) { |
| @@ -179,17 +212,30 @@ func TestEveryParkedDeckIsEmptyToReaders(t *testing.T) { |
| {"ptwo", "parked", "PARKEDTWO"}, |
| }) |
| share := "/s/" + mintShareLink(t, a, path, cookies) |
| + session, remote := startPresenting(t, a, path, cookies) |
| |
| - for _, target := range []string{share, path + "?slide=1", path + "/notes"} { |
| + for _, target := range []string{share, path + "?slide=1", path + "/notes", |
| + "/p/" + session, "/p/" + session + "/notes", "/p/" + session + "/remote?t=" + remote} { |
| rec := get(t, a, target, cookies...) |
| if target == share { |
| rec = get(t, a, target) |
| } |
| + if strings.Contains(target, "/remote") { |
| + rec = get(t, a, target) |
| + } |
| body := rec.Body.String() |
| if rec.Code != http.StatusOK || strings.Contains(body, "PARKED") || strings.Contains(body, "<section slides-slide") { |
| t.Errorf("GET %s: status %d, want an empty page with no slide:\n%s", target, rec.Code, body) |
| } |
| } |
| + if rec := get(t, a, share+"?follow=1"); rec.Code != http.StatusOK && rec.Code != http.StatusSeeOther || strings.Contains(rec.Body.String(), "PARKED") { |
| + t.Errorf("the follow view of an all-parked deck: status %d, want the empty page or a redirect", rec.Code) |
| + } |
| + // Nothing is left to export, as for an empty deck: the job says so. |
| + status := startExport(t, a, path, cookies, url.Values{}) |
| + if fragment := waitForExport(t, a, status, cookies); !strings.Contains(fragment, "rst-tone=\"negative\"") { |
| + t.Errorf("exporting an all-parked deck did not fail:\n%s", fragment) |
| + } |
| // An empty deck answers any slide with its empty page, and so does this. |
| if rec := get(t, a, share+"?slide=1"); rec.Code != http.StatusOK || strings.Contains(rec.Body.String(), "<section slides-slide") { |
| t.Errorf("slide 1 of an all-parked deck over a share link: status %d, want the empty page", rec.Code) |