|
172 | 172 |
|
173 | 173 | log_info "✅ Root endpoint is accessible" |
174 | 174 |
|
| 175 | +# Test oRPC functionality - this exercises MockBrowserWindow methods like isDestroyed() |
| 176 | +log_info "Testing oRPC project creation..." |
| 177 | + |
| 178 | +# Create a temporary git repo for the test project |
| 179 | +PROJECT_DIR=$(mktemp -d) |
| 180 | +git init -b main "$PROJECT_DIR" >/dev/null 2>&1 |
| 181 | +git -C "$PROJECT_DIR" config user.email "test@example.com" |
| 182 | +git -C "$PROJECT_DIR" config user.name "Test User" |
| 183 | +touch "$PROJECT_DIR/README.md" |
| 184 | +git -C "$PROJECT_DIR" add . |
| 185 | +git -C "$PROJECT_DIR" commit -m "Initial commit" >/dev/null 2>&1 |
| 186 | + |
| 187 | +# Create project via oRPC |
| 188 | +PROJECT_RESPONSE=$(curl -sf -X POST "http://${SERVER_HOST}:${SERVER_PORT}/orpc/projects.create" \ |
| 189 | + -H "Content-Type: application/json" \ |
| 190 | + -d "{\"projectPath\": \"$PROJECT_DIR\"}" || true) |
| 191 | + |
| 192 | +if [[ -z "$PROJECT_RESPONSE" ]]; then |
| 193 | + log_error "Project creation returned empty response" |
| 194 | + rm -rf "$PROJECT_DIR" |
| 195 | + exit 1 |
| 196 | +fi |
| 197 | + |
| 198 | +if ! echo "$PROJECT_RESPONSE" | jq -e '.success == true' >/dev/null 2>&1; then |
| 199 | + log_error "Project creation failed: $PROJECT_RESPONSE" |
| 200 | + rm -rf "$PROJECT_DIR" |
| 201 | + exit 1 |
| 202 | +fi |
| 203 | + |
| 204 | +log_info "✅ Project created via oRPC" |
| 205 | + |
| 206 | +# Create workspace via oRPC - this exercises more of the backend layer |
| 207 | +log_info "Testing oRPC workspace creation..." |
| 208 | +WORKSPACE_RESPONSE=$(curl -sf -X POST "http://${SERVER_HOST}:${SERVER_PORT}/orpc/workspace.create" \ |
| 209 | + -H "Content-Type: application/json" \ |
| 210 | + -d "{\"projectPath\": \"$PROJECT_DIR\", \"branchName\": \"smoke-test-branch\", \"trunkBranch\": \"main\"}" || true) |
| 211 | + |
| 212 | +if [[ -z "$WORKSPACE_RESPONSE" ]]; then |
| 213 | + log_error "Workspace creation returned empty response" |
| 214 | + rm -rf "$PROJECT_DIR" |
| 215 | + exit 1 |
| 216 | +fi |
| 217 | + |
| 218 | +if ! echo "$WORKSPACE_RESPONSE" | jq -e '.success == true' >/dev/null 2>&1; then |
| 219 | + log_error "Workspace creation failed: $WORKSPACE_RESPONSE" |
| 220 | + rm -rf "$PROJECT_DIR" |
| 221 | + exit 1 |
| 222 | +fi |
| 223 | + |
| 224 | +WORKSPACE_ID=$(echo "$WORKSPACE_RESPONSE" | jq -r '.metadata.id // empty') |
| 225 | +if [[ -z "$WORKSPACE_ID" ]]; then |
| 226 | + log_error "Workspace ID not returned from creation" |
| 227 | + rm -rf "$PROJECT_DIR" |
| 228 | + exit 1 |
| 229 | +fi |
| 230 | + |
| 231 | +log_info "✅ Workspace created via oRPC (id: $WORKSPACE_ID)" |
| 232 | + |
| 233 | +# Test WebSocket connection - verifies the oRPC WebSocket endpoint is accessible |
| 234 | +log_info "Testing WebSocket connection..." |
| 235 | + |
| 236 | +# Use Node.js to test WebSocket since it's guaranteed to be available |
| 237 | +node -e " |
| 238 | +const WebSocket = require('ws'); |
| 239 | +const ws = new WebSocket('ws://${SERVER_HOST}:${SERVER_PORT}/orpc/ws'); |
| 240 | +
|
| 241 | +const timeout = setTimeout(() => { |
| 242 | + console.error('WebSocket connection timed out'); |
| 243 | + ws.close(); |
| 244 | + process.exit(1); |
| 245 | +}, 5000); |
| 246 | +
|
| 247 | +ws.on('open', () => { |
| 248 | + console.log('WebSocket connected successfully'); |
| 249 | + clearTimeout(timeout); |
| 250 | + ws.close(); |
| 251 | + process.exit(0); |
| 252 | +}); |
| 253 | +
|
| 254 | +ws.on('error', (err) => { |
| 255 | + console.error('WebSocket error:', err.message); |
| 256 | + clearTimeout(timeout); |
| 257 | + process.exit(1); |
| 258 | +}); |
| 259 | +" 2>&1 |
| 260 | + |
| 261 | +WS_EXIT_CODE=$? |
| 262 | +if [[ $WS_EXIT_CODE -ne 0 ]]; then |
| 263 | + log_error "WebSocket connection test failed" |
| 264 | + rm -rf "$PROJECT_DIR" |
| 265 | + exit 1 |
| 266 | +fi |
| 267 | + |
| 268 | +log_info "✅ WebSocket connection successful" |
| 269 | + |
| 270 | +# Cleanup test project |
| 271 | +rm -rf "$PROJECT_DIR" |
| 272 | + |
175 | 273 | # All tests passed |
176 | 274 | log_info "🎉 All smoke tests passed!" |
0 commit comments