package main // prefs_matrix_test.go - every preference, asserted against the markup it // is supposed to change. The cookies are documented in prefs.go and their // effects are spread across four templates; before this, nothing checked // that setting one did anything at all. import ( "net/http" "strings" "testing" ) // prefCase is one preference: the cookie that turns it on, a page that // shows it, and a marker that must be present in exactly one of the two // states. present says which state the marker belongs to. type prefCase struct { name string cookie string value string path string marker string present bool // true: the marker appears when the cookie is SET } func TestPreferenceMatrix(t *testing.T) { buildFixture(t) cases := []prefCase{ // --- card display switches (browse lists, search results) ------- {"hide thumbnails", "pref_hide_thumbs", "1", "/browse", `class="thumb-container"`, false}, {"hide thumbnails (search)", "pref_hide_thumbs", "1", "/search?q=prism&do_search=1", `class="result-thumb"`, false}, {"hide summaries", "pref_hide_summary", "1", "/browse", `class="card-summary"`, false}, {"hide classification", "pref_hide_classification", "1", "/browse", `class="doc-classification"`, false}, {"hide programs", "pref_hide_programs", "1", "/browse", `class="doc-programs"`, false}, {"hide people", "pref_hide_people", "1", "/browse", `class="doc-people"`, false}, {"hide journalists", "pref_hide_journalists", "1", "/browse", `class="doc-journalist`, false}, {"page preview hook", "pref_page_preview", "1", "/browse", "data-pp-id=", true}, // --- category tables -------------------------------------------- {"collection columns", "pref_show_coll_cols", "1", "/browse/program", `id="coll-cols" class="coll-cols-checkbox" checked`, true}, // --- the document page ------------------------------------------ {"info sidebar", "pref_info_position", "beside", "/doc/prism-slides", `class="doc-layout info-sidebar"`, true}, {"scroll panes", "pref_scroll_doc", "1", "/doc/prism-slides", "scroll-panes", true}, {"expand more info", "pref_open_info", "1", "/doc/prism-slides", `id="meta-toggle" class="meta-checkbox" checked`, true}, {"programs one per line", "pref_programs_list", "1", "/doc/prism-slides", `