| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
set -uo pipefail |
| 25 |
|
| 26 |
BASE="${BASE:-https://testnot.work}" |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
MIN_PROJECTS=5 |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
MIN_VISIBLE_ITEMS=20 |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
PLACEHOLDER_COVERS_BASELINE=0 |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
REAL_COVER_MIN_BYTES=2048 |
| 61 |
|
| 62 |
|
| 63 |
MIN_PAGE_BYTES=3000 |
| 64 |
|
| 65 |
TMP="$(mktemp -d)" |
| 66 |
trap 'rm -rf "$TMP"' EXIT |
| 67 |
|
| 68 |
fails=0 |
| 69 |
warns=0 |
| 70 |
pass() { printf ' ok %s\n' "$*"; } |
| 71 |
fail() { printf ' FAIL %s\n' "$*"; fails=$((fails + 1)); } |
| 72 |
warn() { printf ' warn %s\n' "$*"; warns=$((warns + 1)); } |
| 73 |
section() { printf '\n== %s\n' "$*"; } |
| 74 |
|
| 75 |
|
| 76 |
get() { |
| 77 |
curl -sS --max-time 30 -o "$TMP/body" -w '%{http_code}' "$BASE$1" 2>/dev/null || echo 000 |
| 78 |
} |
| 79 |
|
| 80 |
section "reachable" |
| 81 |
code=$(get /) |
| 82 |
if [ "$code" != "200" ]; then |
| 83 |
fail "GET / returned $code; nothing else below is meaningful" |
| 84 |
printf '\n%s\n' "smoke: FAILED ($fails)" |
| 85 |
exit 1 |
| 86 |
fi |
| 87 |
pass "GET / -> 200" |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
section "catalog" |
| 96 |
code=$(get /discover) |
| 97 |
[ "$code" = "200" ] || fail "GET /discover returned $code" |
| 98 |
|
| 99 |
|
| 100 |
grep -oE '<a href="/p/[a-z0-9-]+" class="table-row project-row">|<span class="row-items">[0-9]+</span>' "$TMP/body" | |
| 101 |
sed -e 's/.*href="\/p\///' -e 's/" class.*//' -e 's/<span class="row-items">//' -e 's/<\/span>//' | |
| 102 |
paste - - >"$TMP/advertised" 2>/dev/null |
| 103 |
|
| 104 |
n_projects=$(wc -l <"$TMP/advertised") |
| 105 |
if [ "$n_projects" -lt "$MIN_PROJECTS" ]; then |
| 106 |
fail "discover lists $n_projects projects, floor is $MIN_PROJECTS" |
| 107 |
else |
| 108 |
pass "discover lists $n_projects projects" |
| 109 |
fi |
| 110 |
|
| 111 |
visible_total=0 |
| 112 |
: >"$TMP/covers" |
| 113 |
|
| 114 |
while read -r slug advertised; do |
| 115 |
[ -n "$slug" ] || continue |
| 116 |
code=$(get "/p/$slug") |
| 117 |
if [ "$code" != "200" ]; then |
| 118 |
fail "/p/$slug returned $code" |
| 119 |
continue |
| 120 |
fi |
| 121 |
|
| 122 |
rendered=$(grep -o 'class="item-card' "$TMP/body" | wc -l) |
| 123 |
grep -oE 'src="https://[^"]*/image/[^"]*"' "$TMP/body" | sed -e 's/src="//' -e 's/"$//' >>"$TMP/covers" |
| 124 |
|
| 125 |
if grep -q 'class="paywall-box"' "$TMP/body"; then |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
if [ "$rendered" -ne 0 ]; then |
| 131 |
fail "/p/$slug is paywalled but rendered $rendered item cards" |
| 132 |
elif grep -qE "(^|>)[^<]*\b$advertised items? included" "$TMP/body"; then |
| 133 |
pass "/p/$slug paywalled, states its $advertised items" |
| 134 |
else |
| 135 |
fail "/p/$slug is paywalled and does not state its $advertised items; discover advertises them" |
| 136 |
fi |
| 137 |
else |
| 138 |
visible_total=$((visible_total + rendered)) |
| 139 |
if [ "$rendered" -eq "$advertised" ]; then |
| 140 |
pass "/p/$slug renders $rendered items, matching discover" |
| 141 |
else |
| 142 |
fail "/p/$slug renders $rendered items, discover advertises $advertised" |
| 143 |
fi |
| 144 |
fi |
| 145 |
done <"$TMP/advertised" |
| 146 |
|
| 147 |
if [ "$visible_total" -lt "$MIN_VISIBLE_ITEMS" ]; then |
| 148 |
fail "$visible_total items visible across open storefronts, floor is $MIN_VISIBLE_ITEMS" |
| 149 |
else |
| 150 |
pass "$visible_total items visible across open storefronts" |
| 151 |
fi |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
section "covers" |
| 159 |
sort -u "$TMP/covers" >"$TMP/covers.uniq" |
| 160 |
n_covers=$(wc -l <"$TMP/covers.uniq") |
| 161 |
[ "$n_covers" -gt 0 ] || fail "no cover images referenced by any storefront" |
| 162 |
|
| 163 |
placeholders=0 |
| 164 |
while read -r url; do |
| 165 |
[ -n "$url" ] || continue |
| 166 |
read -r ccode csize ctype <<<"$(curl -sS --max-time 30 -o /dev/null \ |
| 167 |
-w '%{http_code} %{size_download} %{content_type}' "$url" 2>/dev/null || echo "000 0 -")" |
| 168 |
short="${url##*/projects/}" |
| 169 |
case "$ctype" in |
| 170 |
image/*) is_image=1 ;; |
| 171 |
*) is_image=0 ;; |
| 172 |
esac |
| 173 |
if [ "$ccode" != "200" ]; then |
| 174 |
fail "cover $short returned $ccode" |
| 175 |
elif [ "$is_image" -eq 0 ]; then |
| 176 |
fail "cover $short served as ${ctype:--}, not an image" |
| 177 |
elif [ "$csize" -lt "$REAL_COVER_MIN_BYTES" ]; then |
| 178 |
placeholders=$((placeholders + 1)) |
| 179 |
fi |
| 180 |
done <"$TMP/covers.uniq" |
| 181 |
|
| 182 |
if [ "$placeholders" -gt "$PLACEHOLDER_COVERS_BASELINE" ]; then |
| 183 |
fail "$placeholders placeholder covers, sealed baseline is $PLACEHOLDER_COVERS_BASELINE (a real cover reverted)" |
| 184 |
elif [ "$placeholders" -eq "$PLACEHOLDER_COVERS_BASELINE" ] && [ "$placeholders" -gt 0 ]; then |
| 185 |
warn "$placeholders of $n_covers covers are still the seed placeholder; at baseline, not a regression" |
| 186 |
else |
| 187 |
pass "$placeholders placeholder covers, down from a baseline of $PLACEHOLDER_COVERS_BASELINE. Lower PLACEHOLDER_COVERS_BASELINE to $placeholders" |
| 188 |
fi |
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
section "other surfaces" |
| 196 |
for path in /discover?mode=items /pricing /fan-plus /docs; do |
| 197 |
code=$(get "$path") |
| 198 |
size=$(wc -c <"$TMP/body") |
| 199 |
if [ "$code" != "200" ]; then |
| 200 |
fail "$path returned $code" |
| 201 |
elif [ "$size" -lt "$MIN_PAGE_BYTES" ]; then |
| 202 |
fail "$path returned 200 but only ${size}B, which is chrome and no content" |
| 203 |
else |
| 204 |
pass "$path -> 200, ${size}B" |
| 205 |
fi |
| 206 |
done |
| 207 |
|
| 208 |
section "blogs and feeds" |
| 209 |
while read -r slug _; do |
| 210 |
[ -n "$slug" ] || continue |
| 211 |
code=$(get "/p/$slug/blog") |
| 212 |
[ "$code" = "200" ] || fail "/p/$slug/blog returned $code" |
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
code=$(get "/p/$slug/blog/feed.xml") |
| 217 |
posts=$(grep -c '<item>' "$TMP/body" 2>/dev/null || echo 0) |
| 218 |
if [ "$code" != "200" ]; then |
| 219 |
fail "/p/$slug/blog/feed.xml returned $code" |
| 220 |
elif [ "$posts" -lt 1 ]; then |
| 221 |
fail "/p/$slug/blog/feed.xml is an empty feed" |
| 222 |
else |
| 223 |
pass "/p/$slug blog + feed ($posts posts)" |
| 224 |
fi |
| 225 |
done <"$TMP/advertised" |
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
section "deferred" |
| 230 |
code=$(get /library) |
| 231 |
if [ "$code" = "401" ] || [ "$code" = "302" ] || [ "$code" = "303" ]; then |
| 232 |
warn "/library is $code to anonymous, as expected. Checking its contents needs the demo buyer, which the seed creates when TESTNOT_BUYER_PASSWORD is set (GoingsOn 839a8e5a, option B). The carousel capture is what exercises it" |
| 233 |
else |
| 234 |
warn "/library returned $code to an anonymous visitor; expected an auth redirect. Worth a look" |
| 235 |
fi |
| 236 |
|
| 237 |
printf '\n' |
| 238 |
if [ "$fails" -gt 0 ]; then |
| 239 |
printf 'smoke: FAILED (%d failures, %d warnings)\n' "$fails" "$warns" |
| 240 |
exit 1 |
| 241 |
fi |
| 242 |
printf 'smoke: ok (%d warnings)\n' "$warns" |
| 243 |
|