test: Smoke prüft Bereichs- und Schlüssel-Ablehnung auf Grund und Feld

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-10-19 18:17:41 +02:00
co-authored by Claude Sonnet 5.5
parent 4300205f17
commit cb41f9e877
+7 -2
View File
@@ -75,6 +75,11 @@ STALE=$(ability lit/divi-theme-options-update "$(echo "$UPDATE" | jq -c '.set.bo
[ "$(error_code "$STALE")" = "rev_mismatch" ] || fail "stale design_rev: $STALE" [ "$(error_code "$STALE")" = "rev_mismatch" ] || fail "stale design_rev: $STALE"
pass "theme options changed ($THEME_SNAPSHOT), stale design_rev refused" pass "theme options changed ($THEME_SNAPSHOT), stale design_rev refused"
# refused_for <answer> <field>: the call was refused (an error that is not the dry run's confirm_required) and the text names the field.
refused_for() {
[ "$(error_code "$1")" != "confirm_required" ] && echo "$1" | jq -e --arg f "$2" 'has("__error") and (.__error | contains($f))' >/dev/null
}
# 3. Validation. Range and unknown keys are already refused by the input schema (before the plugin runs); unknown font # 3. Validation. Range and unknown keys are already refused by the input schema (before the plugin runs); unknown font
# names and "none" reach the plugin, which collects them with suggestions. Nothing is written in any case. # names and "none" reach the plugin, which collects them with suggestions. Nothing is written in any case.
BAD=$(ability lit/divi-theme-options-update '{"set": {"heading_font": "Robotto", "body_font": "none"}}') BAD=$(ability lit/divi-theme-options-update '{"set": {"heading_font": "Robotto", "body_font": "none"}}')
@@ -82,9 +87,9 @@ BAD=$(ability lit/divi-theme-options-update '{"set": {"heading_font": "Robotto",
echo "$BAD" | grep -q 'Roboto' || fail "no font suggestion in: $BAD" echo "$BAD" | grep -q 'Roboto' || fail "no font suggestion in: $BAD"
echo "$BAD" | grep -q 'body_font' || fail "none not refused with its path: $BAD" echo "$BAD" | grep -q 'body_font' || fail "none not refused with its path: $BAD"
BAD=$(ability lit/divi-theme-options-update '{"set": {"body_font_size": 99}}') BAD=$(ability lit/divi-theme-options-update '{"set": {"body_font_size": 99}}')
echo "$BAD" | jq -e 'has("__error")' >/dev/null || fail "out-of-range size accepted: $BAD" refused_for "$BAD" body_font_size || fail "out-of-range size not refused for its field: $BAD"
BAD=$(ability lit/divi-theme-options-update '{"set": {"colour": 1}}') BAD=$(ability lit/divi-theme-options-update '{"set": {"colour": 1}}')
echo "$BAD" | jq -e 'has("__error")' >/dev/null || fail "unknown key accepted: $BAD" refused_for "$BAD" colour || fail "unknown key not refused for its field: $BAD"
[ "$(theme_option body_font_size)" = "18" ] || fail "invalid call changed body_font_size" [ "$(theme_option body_font_size)" = "18" ] || fail "invalid call changed body_font_size"
[ "$(theme_option heading_font)" = "<unset>" ] || fail "invalid call changed heading_font" [ "$(theme_option heading_font)" = "<unset>" ] || fail "invalid call changed heading_font"
pass "unknown font with suggestions, none, range and unknown key refused" pass "unknown font with suggestions, none, range and unknown key refused"