Make embedded maps cooperate with page gestures

This commit is contained in:
SimpleTest 2026-08-25 20:36:36 +03:00
parent 9cdd31c72e
commit 85039b76ef
3 changed files with 70 additions and 14 deletions

View File

@ -883,6 +883,7 @@ const createAidMap = element => {
attributionControl: true,
renderWorldCopies: false,
trackResize: false,
cooperativeGestures: true,
dragRotate: !demoMap,
pitchWithRotate: !demoMap,
scrollZoom: !demoMap
@ -2483,6 +2484,7 @@ export const Hooks = {
zoom: initialCoordinates ? 13 : 5,
locale: mapUiLocale(),
attributionControl: true,
cooperativeGestures: true,
dragRotate: false,
pitchWithRotate: false
})

View File

@ -0,0 +1,13 @@
import assert from "node:assert/strict"
import {readFile} from "node:fs/promises"
import test from "node:test"
const hooksSource = await readFile(new URL("./hooks.js", import.meta.url), "utf8")
test("every embedded MapLibre map uses cooperative gestures", () => {
const constructors = hooksSource.match(/new maplibregl\.Map\(\{/g) || []
const cooperativeOptions = hooksSource.match(/cooperativeGestures:\s*true/g) || []
assert.equal(constructors.length, 2)
assert.equal(cooperativeOptions.length, constructors.length)
})

View File

@ -140,6 +140,50 @@ pod_snapshot() {
] | sort_by(.component, .name)' >"$1"
}
web_readiness_snapshot() {
local output_file=$1
local jsonl_file="${output_file%.json}.jsonl"
local body
local pod
mapfile -t web_pods < <(
"${kube[@]}" get pods \
-l app.kubernetes.io/component=web \
--field-selector=status.phase=Running \
-o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}'
)
if [[ "${#web_pods[@]}" -ne 2 ]]; then
echo "Expected two running web pods; observed ${#web_pods[@]}." >&2
return 1
fi
: >"$jsonl_file"
for pod in "${web_pods[@]}"; do
if ! body=$(
"${kube[@]}" exec -c web "$pod" -- sh -c \
'curl --silent --show-error --fail --max-time 2 \
"http://127.0.0.1:${PORT:?}/healthz/ready"'
); then
echo "The readiness endpoint failed inside web pod $pod." >&2
return 1
fi
jq -cn \
--arg pod "$pod" \
--arg body "$body" \
'{
pod: $pod,
body: $body,
response: (try ($body | fromjson) catch null)
}' >>"$jsonl_file"
done
jq -s 'sort_by(.pod)' "$jsonl_file" >"$output_file"
unlink "$jsonl_file"
}
stop_probe() {
unlink "$probe_marker" 2>/dev/null || true
@ -406,24 +450,21 @@ jq -s '{
samples: length,
failures: (map(select(.status != "200")) | length),
retried_samples: (map(select(.retries > 0)) | length),
total_retries: (map(.retries) | add),
nodes: (map(.body | fromjson? | .node) | map(select(. != null)) | unique)
total_retries: (map(.retries) | add)
}' "$probe_log" >"$output_dir/readiness-summary.json"
"${kube[@]}" get pods \
-l app.kubernetes.io/component=web \
-o json |
jq '[.items[].status.podIP | "who_need_help@" + .] | sort' \
>"$output_dir/current-web-nodes.json"
web_readiness_snapshot "$output_dir/web-pod-readiness.json"
if ! jq -e '.samples > 0 and .failures == 0' \
"$output_dir/readiness-summary.json" >/dev/null; then
echo "Kind readiness was unavailable during the rollout." >&2
exit 1
fi
if ! jq -e \
--slurpfile current "$output_dir/current-web-nodes.json" '
.samples > 0 and
.failures == 0 and
($current[0] | length) == 2 and
(($current[0] - .nodes) | length) == 0
' "$output_dir/readiness-summary.json" >/dev/null; then
echo "Kind readiness was unavailable or did not reach both web replicas." >&2
'length == 2 and all(.response.status == "ready")' \
"$output_dir/web-pod-readiness.json" >/dev/null; then
echo "Both replacement web pods did not pass direct readiness checks." >&2
exit 1
fi