test: Smoke prüft conflict, sha256/Bytes, Schriftdatei und body_font; Lint-Zeilenlängen

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-10-19 18:30:13 +02:00
co-authored by Claude Sonnet 5.5
parent f2aeb59d02
commit 7678d228e7
3 changed files with 11 additions and 5 deletions
+8 -2
View File
@@ -118,7 +118,9 @@ pass "theme_options snapshot restored (body_font_size, content_width, heading_fo
UPLOAD=$(jq -cn --arg n "$FONT_NAME" --arg u "$FONT_URL" '{name: $n, files: {woff2: $u}, weights: "all"}')
DRY=$(ability lit/divi-fonts-upload "$UPLOAD")
[ "$(error_code "$DRY")" = "confirm_required" ] || fail "font dry run: $DRY"
echo "$DRY" | grep -q 'woff2' || fail "dry run does not name the format: $DRY"
echo "$DRY" | jq -e '.__error | fromjson | [.. | objects | select(has("sha256"))]
| length == 1 and (.[0].format == "woff2") and (.[0].sha256 | test("^[0-9a-f]{64}$")) and (.[0].bytes | type == "number" and . > 0)' >/dev/null \
|| fail "dry run does not report format, byte count and a 64-hex sha256: $DRY"
LIT_FONT="$FONT_NAME" wp eval 'exit(isset(get_option("et_uploaded_fonts", [])[getenv("LIT_FONT")]) ? 1 : 0);' \
|| fail "dry run installed the font"
pass "font dry run installs nothing"
@@ -128,13 +130,17 @@ DONE=$(ability lit/divi-fonts-upload "$(echo "$UPLOAD" | jq -c '. + {confirm: tr
[ "$(echo "$DONE" | jq -r '.ok')" = "true" ] || fail "font upload: $DONE"
LIT_FONT="$FONT_NAME" wp eval '$f = get_option("et_uploaded_fonts", [])[getenv("LIT_FONT")] ?? null; exit($f && isset($f["font_url"]["woff2"]) ? 0 : 1);' \
|| fail "font not stored in et_uploaded_fonts"
# The stored file is on disk: font_file is the path (or, if Divi stores URLs only, the URL mapped into the uploads dir).
LIT_FONT="$FONT_NAME" wp eval '$f = get_option("et_uploaded_fonts", [])[getenv("LIT_FONT")]; $p = $f["font_file"]["woff2"] ?? ""; if ($p !== "" && !file_exists($p)) { $u = wp_get_upload_dir(); $p = str_replace($u["baseurl"], $u["basedir"], $f["font_url"]["woff2"] ?? $p); } exit($p !== "" && file_exists($p) && filesize($p) > 0 ? 0 : 1);' \
|| fail "stored font file does not exist"
AGAIN=$(ability lit/divi-fonts-upload "$(echo "$UPLOAD" | jq -c '. + {confirm: true}')")
[ "$(error_code "$AGAIN")" != "" ] || fail "a second upload of the same name was accepted: $AGAIN"
[ "$(error_code "$AGAIN")" = "conflict" ] || fail "a second upload of the same name was accepted: $AGAIN"
pass "font installed through Divi, same name refused"
# 8. The uploaded font is a valid theme font now; Arial (web-safe) is refused as a new font name.
DONE=$(confirm lit/divi-theme-options-update "$(jq -cn --arg n "$FONT_NAME" '{set: {body_font: $n}}')")
[ "$(echo "$DONE" | jq -r '.ok')" = "true" ] || fail "uploaded font as body_font: $DONE"
[ "$(theme_option body_font)" = "'$FONT_NAME'" ] || fail "uploaded font not stored as body_font"
# A taken name (web-safe, Google, uploaded) is a conflict, see DiviFontsUploadAbility.
RESERVED=$(ability lit/divi-fonts-upload "$(jq -cn --arg u "$FONT_URL" '{name: "Arial", files: {woff2: $u}, weights: "all"}')")
[ "$(error_code "$RESERVED")" = "conflict" ] || fail "web-safe name accepted: $RESERVED"