Skip to content

Commit dd942e5

Browse files
Add test-integration-wss.sh to GitHub Actions (#68)
* Add test-integration-wss.sh to GitHub Actions * Refactor test-integration-wss.sh to use Stripe API directly for test object creation, removing dependency on Stripe CLI. Update prerequisite checks and improve event triggering process.
1 parent bdce30d commit dd942e5

File tree

2 files changed

+56
-17
lines changed

2 files changed

+56
-17
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ jobs:
141141
chmod +x ./scripts/test-integration-webhook-reuse.sh
142142
./scripts/test-integration-webhook-reuse.sh
143143
144+
- name: Run Managed WebSocket for Webhooks Integration Test
145+
run: |
146+
cd packages/sync-engine
147+
chmod +x ./scripts/test-integration-wss.sh
148+
./scripts/test-integration-wss.sh
149+
144150
- name: Run Deploy Integration Test
145151
run: |
146152
cd packages/sync-engine

packages/sync-engine/scripts/test-integration-wss.sh

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# End-to-end integration test for Stripe Sync Engine using WebSocket mode
44
# Tests WebSocket connection, event processing, webhook_response messages, and database writes
5-
# This test does NOT require ngrok - uses Stripe's WebSocket API directly
5+
# This test does NOT require ngrok or Stripe CLI - uses Stripe's WebSocket API directly
66

77
set -e # Exit on error
88

@@ -16,12 +16,11 @@ echo ""
1616

1717
# Check for required tools
1818
echo "🔧 Checking prerequisites..."
19-
if ! command -v stripe &> /dev/null; then
20-
echo "❌ Stripe CLI not found - required for triggering test events"
21-
echo " Install: brew install stripe/stripe-cli/stripe"
19+
if ! command -v curl &> /dev/null; then
20+
echo "❌ curl not found - required for API calls"
2221
exit 1
2322
fi
24-
echo "Stripe CLI found"
23+
echo "curl found"
2524

2625
if ! command -v jq &> /dev/null; then
2726
echo "❌ jq not found - required for JSON parsing"
@@ -107,27 +106,61 @@ else
107106
fi
108107
echo ""
109108

110-
# Step 3: Trigger test events using Stripe CLI
111-
echo "🎯 Step 3: Triggering Stripe test events..."
109+
# Step 3: Trigger test events using Stripe API directly (no Stripe CLI needed)
110+
echo "🎯 Step 3: Creating Stripe test objects via API..."
112111
echo " Events will be delivered via WebSocket and webhook_response sent back"
113112
echo ""
114113

115-
# Trigger customer.created event
116-
echo " Triggering customer.created..."
117-
stripe trigger customer.created > /dev/null 2>&1 || echo " (stripe trigger may have failed)"
114+
# Create a customer via API (triggers customer.created event)
115+
echo " Creating customer..."
116+
CUSTOMER_RESPONSE=$(curl -s -X POST https://api.stripe.com/v1/customers \
117+
-u "$STRIPE_API_KEY:" \
118+
-d "name=Test Customer $(date +%s)" \
119+
-d "email=test-$(date +%s)@example.com" \
120+
-d "metadata[test]=wss-integration")
121+
CUSTOMER_ID=$(echo "$CUSTOMER_RESPONSE" | jq -r '.id // empty')
122+
if [ -n "$CUSTOMER_ID" ]; then
123+
echo " ✓ Customer created: $CUSTOMER_ID"
124+
else
125+
echo " ⚠️ Customer creation may have failed"
126+
fi
118127
sleep 2
119128

120-
# Trigger product.created event
121-
echo " Triggering product.created..."
122-
stripe trigger product.created > /dev/null 2>&1 || echo " (stripe trigger may have failed)"
129+
# Create a product via API (triggers product.created event)
130+
echo " Creating product..."
131+
PRODUCT_RESPONSE=$(curl -s -X POST https://api.stripe.com/v1/products \
132+
-u "$STRIPE_API_KEY:" \
133+
-d "name=Test Product $(date +%s)" \
134+
-d "metadata[test]=wss-integration")
135+
PRODUCT_ID=$(echo "$PRODUCT_RESPONSE" | jq -r '.id // empty')
136+
if [ -n "$PRODUCT_ID" ]; then
137+
echo " ✓ Product created: $PRODUCT_ID"
138+
else
139+
echo " ⚠️ Product creation may have failed"
140+
fi
123141
sleep 2
124142

125-
# Trigger price.created event
126-
echo " Triggering price.created..."
127-
stripe trigger price.created > /dev/null 2>&1 || echo " (stripe trigger may have failed)"
143+
# Create a price via API (triggers price.created event)
144+
echo " Creating price..."
145+
if [ -n "$PRODUCT_ID" ]; then
146+
PRICE_RESPONSE=$(curl -s -X POST https://api.stripe.com/v1/prices \
147+
-u "$STRIPE_API_KEY:" \
148+
-d "product=$PRODUCT_ID" \
149+
-d "unit_amount=1000" \
150+
-d "currency=usd" \
151+
-d "metadata[test]=wss-integration")
152+
PRICE_ID=$(echo "$PRICE_RESPONSE" | jq -r '.id // empty')
153+
if [ -n "$PRICE_ID" ]; then
154+
echo " ✓ Price created: $PRICE_ID"
155+
else
156+
echo " ⚠️ Price creation may have failed"
157+
fi
158+
else
159+
echo " ⚠️ Skipping price creation (no product)"
160+
fi
128161
sleep 5 # Wait for events to be processed
129162

130-
echo "✓ Test events triggered"
163+
echo "✓ Test objects created"
131164
echo ""
132165

133166
# Step 4: Verify events in logs (look for "← event.type" pattern from websocket-client)

0 commit comments

Comments
 (0)