Files
muninn/sidecars/reddit-post/run.sh
T
Doar MihaiandClaude Sonnet 5 0154c058af polish: trim unknown-arg echo, document trace artifacts and unverified selectors
Addresses whole-branch review's minor findings:
- Unknown CLI arguments now echo only the flag name, not its value, so a
  mistyped flag (e.g. --pasword=secret) can't leak a credential into the
  error output.
- README now notes that failed runs retain a screenshot/trace under
  test-results/ (gitignored, may contain the username but not the masked
  password), and points at the UNVERIFIED post-composer selectors as the
  first thing to check during real home-network verification.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-18 19:03:50 +03:00

65 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
USERNAME=""
PASSWORD=""
SUBREDDIT=""
TITLE=""
BODY=""
HEADLESS_FLAG="true"
for arg in "$@"; do
case "$arg" in
--username=*) USERNAME="${arg#*=}" ;;
--password=*) PASSWORD="${arg#*=}" ;;
--subreddit=*) SUBREDDIT="${arg#*=}" ;;
--title=*) TITLE="${arg#*=}" ;;
--body=*) BODY="${arg#*=}" ;;
--headed) HEADLESS_FLAG="false" ;;
*)
UNKNOWN_FLAG="${arg%%=*}"
echo "{\"success\": false, \"error\": \"Unknown argument: $UNKNOWN_FLAG\"}"
exit 1
;;
esac
done
MISSING=""
[ -z "$USERNAME" ] && MISSING="$MISSING --username"
[ -z "$PASSWORD" ] && MISSING="$MISSING --password"
[ -z "$SUBREDDIT" ] && MISSING="$MISSING --subreddit"
[ -z "$TITLE" ] && MISSING="$MISSING --title"
[ -z "$BODY" ] && MISSING="$MISSING --body"
if [ -n "$MISSING" ]; then
echo "{\"success\": false, \"error\": \"Missing required argument(s):$MISSING\"}"
exit 1
fi
export REDDIT_USERNAME="$USERNAME"
export REDDIT_PASSWORD="$PASSWORD"
export SUBREDDIT="$SUBREDDIT"
export POST_TITLE="$TITLE"
export POST_BODY="$BODY"
export HEADLESS="$HEADLESS_FLAG"
set +e
npx playwright test tests/reddit-post.spec.js
PLAYWRIGHT_EXIT_CODE=$?
set -e
RESULT_FILE="test-results/result.json"
if [ -f "$RESULT_FILE" ]; then
cat "$RESULT_FILE"
echo
else
echo "{\"success\": false, \"error\": \"Test did not produce a result file\"}"
exit 1
fi
exit "$PLAYWRIGHT_EXIT_CODE"