first commit
This commit is contained in:
commit
8c4dcae475
89 changed files with 24623 additions and 0 deletions
58
tests/sidtoday_scope_test.go
Normal file
58
tests/sidtoday_scope_test.go
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// The home figures describe the Reported collection; /?sidtoday=1 adds the
|
||||
// SIDtoday archive, and the note above them links between the two. In the
|
||||
// consistency corpus only s1 (SIDtoday archive) is dated 2011-05.
|
||||
func TestHomeStatsWithSIDtoday(t *testing.T) {
|
||||
withCorpus(t, writeConsistencyCorpus(t))
|
||||
plain := get(t, "/").Body.String()
|
||||
if !strings.Contains(plain, "exclude SIDtoday archive documents") || !strings.Contains(plain, `href="/?sidtoday=1"`) {
|
||||
t.Error("/: no note linking to the figures with the SIDtoday archive")
|
||||
}
|
||||
if strings.Contains(plain, "coll=sidtoday-archive") {
|
||||
t.Error("/: a figure links into the SIDtoday archive")
|
||||
}
|
||||
with := get(t, "/?sidtoday=1").Body.String()
|
||||
if !strings.Contains(with, "include SIDtoday archive documents") {
|
||||
t.Error("/?sidtoday=1: the note does not say the figures include the SIDtoday archive")
|
||||
}
|
||||
if !strings.Contains(with, `href="/browse/docdate/2011?coll=news&coll=sidtoday-archive"`) {
|
||||
t.Error("/?sidtoday=1: the document-date bars do not link with both collections")
|
||||
}
|
||||
}
|
||||
|
||||
// The "reported" badge tells an individually reported SIDtoday issue apart
|
||||
// from the bulk release, so only the SIDtoday tab shows it: every view of
|
||||
// that tab, and no other page.
|
||||
func TestReportedBadgeOnlyOnSIDtodayTab(t *testing.T) {
|
||||
root := writeConsistencyCorpus(t)
|
||||
d := filepath.Join(root, "r1")
|
||||
writeFixtureFile(t, filepath.Join(d, "r1.pdf"), "%PDF-1.4\n")
|
||||
writeFixtureFile(t, filepath.Join(d, "metadata.json"), `{"title": "Reported issue", "type": "SIDTODAY",
|
||||
"document": {"date_created": "2011-06-01"},
|
||||
"publication": [{"publisher": "The Intercept", "date_published": "2014-03-01", "link": "https://example.org/r"}]}`)
|
||||
withCorpus(t, root)
|
||||
|
||||
const badge = `class="issue-reported" title=`
|
||||
for _, p := range []string{"/browse?collection=sidtoday-archive", "/browse?collection=sidtoday-archive&view=card",
|
||||
"/browse?collection=sidtoday-archive&view=table"} {
|
||||
if !strings.Contains(get(t, p).Body.String(), badge) {
|
||||
t.Errorf("%s: no reported badge", p)
|
||||
}
|
||||
}
|
||||
for _, p := range []string{"/browse", "/browse?view=table", "/search?q=reported&do_search=1", "/browse/publisher/The%20Intercept"} {
|
||||
body := get(t, p).Body.String()
|
||||
if !strings.Contains(body, `href="/doc/r1"`) {
|
||||
t.Errorf("%s does not list r1", p)
|
||||
}
|
||||
if strings.Contains(body, badge) {
|
||||
t.Errorf("%s shows the reported badge", p)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue