Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,19 @@ npm run dev
# Start the server
docker compose up --build
```

## Localhost API Test

After the API is running on port 8080, run this smoke test:

```bash
bash scripts/test_localhost.sh
```
Comment on lines +13 to +17

If your API is running on a different host or port:

```bash
bash scripts/test_localhost.sh http://localhost:9000
```

The script sends a valid request to `POST /api/submit/exec-form` and fails with a non-zero exit code if the endpoint does not return a successful response.
53 changes: 53 additions & 0 deletions scripts/test_localhost.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
set -euo pipefail

BASE_URL="${1:-http://localhost:8080}"
ENDPOINT="${BASE_URL%/}/api/submit/exec-form"

PAYLOAD='{
"fullName": "Local Test User",
"email": "local.test@example.com",
"studentId": "12345678",
"yearOfStudy": "3",
"faculty": "Engineering",
"major": "Software Engineering",
"coopTerm": "no",
"firstChoiceTeam": "TECHNOLOGY",
"questions": {
"tech_q1": "I enjoy building backend services.",
"tech_q2": "I want to grow in API design.",
"tech_q3": "Python and FastAPI.",
"tech_q4": "I collaborate through pull requests and code reviews."
}
}'

TMP_BODY="$(mktemp)"
trap 'rm -f "$TMP_BODY"' EXIT

HTTP_CODE="$(curl -sS -o "$TMP_BODY" -w "%{http_code}" \
-X POST "$ENDPOINT" \
-H "Content-Type: application/json" \
-d "$PAYLOAD")"
Comment on lines +25 to +30

BODY="$(cat "$TMP_BODY")"

if [[ "$HTTP_CODE" != "200" ]]; then
echo "Localhost test failed: expected HTTP 200, got HTTP $HTTP_CODE"
echo "Endpoint: $ENDPOINT"
echo "Response body:"
echo "$BODY"
exit 1
fi

if [[ "$BODY" != *'"message":"Submission received successfully"'* ]]; then
echo "Localhost test failed: success message not found in response"
echo "Endpoint: $ENDPOINT"
echo "Response body:"
echo "$BODY"
exit 1
fi

echo "Localhost test passed"
echo "Endpoint: $ENDPOINT"
echo "HTTP $HTTP_CODE"
echo "$BODY"
Loading