clone

a personal forge on plain git: static pages, stacked-diff reviews, signed local ci, repo sites and releases

main
forge / test / scenarios / web-comment-same.sh
web-comment-same.sh 2.3K
1# A comment posted from a review page, signed in with a passkey, is the2# comment forge comment makes over ssh: the same file, byte for byte, for3# the same text at the same time, on the whole review and on a line, and4# the same event for open pages. The answer says where it went.5. "$(dirname "$0")/../lib.sh"6user dami7user ana8repo dami/greet9clone dami dami/greet "$T/w/dami"10at "$T/w/dami" commit "first" greet.sh11ok push_as dami "$T/w/dami" origin main12at "$T/w/dami" git switch -q -c dami/feature13at "$T/w/dami" commit "feature" greet.sh14ok push_as dami "$T/w/dami" origin dami/feature15tip=$(git --git-dir="$FORGE_ROOT/dami/greet.git" rev-parse dami/feature)16export FORGE_BASE_URL=https://forge.test17private_server18ana=$(signin ana) || fail "ana can't sign in"19csrf=$(csrf_of "$ana")20post() { http -s -H "Cookie: __Host-forge=$ana" -H 'Origin: https://forge.test' -H 'Content-Type: application/json' -d "$1" "$PRIV/dami/greet/reviews/1/comment"; }21d=$FORGE_ROOT/dami/greet.git/forge/comments/12223printf 'Looks *good*\n\nOne thing.\n' | ssh_as ana comment dami/greet 1 >/dev/null24post '{"body":"Looks *good*\n\nOne thing.","at":"'"$tip"'","csrf":"'"$csrf"'"}' >"$T/res"25has "$T/res" '"ok":true'26has "$T/res" '"comment":2'27has "$T/res" '"message":"comment 2 on #1 r1: https://forge.test/dami/greet/reviews/1/#comment-2"'28cmp "$d/1" "$d/2" || fail "the web's comment differs from ssh's"29has "$d/2" '^user ana$'3031printf 'Why 2?\n' | ssh_as ana comment dami/greet 1 --line greet.sh:2 >/dev/null32post '{"body":"Why 2?","line":"greet.sh:2","at":"'"$tip"'","csrf":"'"$csrf"'"}' >"$T/res"33has "$T/res" '"comment":4'34cmp "$d/3" "$d/4" || fail "the web's line comment differs from ssh's"35has "$d/4" '^path greet.sh$'36has "$d/4" '^line 2$'3738# Open pages hear of each the same way.39eq "$(grep -c '"type":"comment","user":"ana","review":1' "$FORGE_ROOT/.forge/events.jsonl")" 440eq "$(grep '"type":"comment"' "$FORGE_ROOT/.forge/events.jsonl" | sort -u | wc -l | tr -d ' ')" 14142# What the forge refuses, it refuses in its own words.43post '{"body":"x","line":"nope.sh:1","at":"'"$tip"'","csrf":"'"$csrf"'"}' >"$T/res"44has "$T/res" '"error":"comment: no file nope.sh in #1 at '"$(printf %.7s "$tip")"'"'45post '{"body":" ","csrf":"'"$csrf"'"}' >"$T/res"46has "$T/res" '"error":"comment: empty message"'47missing "$d/5"