feat(test): add end-to-end live API test suite (DIS-73)#40
feat(test): add end-to-end live API test suite (DIS-73)#40
Conversation
Adds comprehensive e2e tests gated behind LIVE_TEST=true that: - Test all 8 command domains via SDK and CLI shell execution - Validate all 3 output formats (json, table, toon) - Verify parity between SDK responses and direct REST API calls - Test error handling (invalid API key, non-existent slugs, missing key) - Generate JSON report with pass/fail per command x format Co-Authored-By: Chris K <ckorhonen@gmail.com>
Original prompt from Chris K |
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…l injection Addresses Devin Review findings: - SDK instantiation moved from eager describe-body scope into beforeAll hook so it only runs when LIVE_TEST=true - Replaced execSync with execFileSync in cli() helper to avoid shell metacharacter injection via OPENSEA_API_KEY env var - API key now passed via OPENSEA_API_KEY env var instead of CLI argument Co-Authored-By: Chris K <ckorhonen@gmail.com>
Add parseArgs() that respects double-quoted groups so values like "New Punk Blue" are passed as a single argument to execFileSync. Both cli() and cliFormatted() now accept string | string[]. Co-Authored-By: Chris K <ckorhonen@gmail.com>
Co-Authored-By: Chris K <ckorhonen@gmail.com>
|
@devin Several issues to address:
if (err instanceof OpenSeaAPIError && [400, 404, 422].includes(err.statusCode)) {
// acceptable for swap quote
}
|
…rowing, build step - Parity tests now use tolerance (±1) instead of exact count matching - Swap error handling narrowed to expected codes [400, 404, 422] - beforeAll runs npm run build to ensure dist/cli.js is fresh Co-Authored-By: Chris K <ckorhonen@gmail.com>
|
All 4 items addressed:
|
feat(test): add end-to-end live API test suite (DIS-73)
Summary
Adds
test/e2e.test.ts— a comprehensive live API test suite gated behindLIVE_TEST=true. The suite tests all 8 command domains (collections, nfts, listings, offers, events, tokens, swaps, accounts) across three layers:OpenSeaCLIclass methods programmaticallynode dist/cli.jsviaexecFileSync(no shell) and captures stdout/stderr/exit codesfetchcalls to the REST APIOutput format validation covers all 3 formats (json, table, toon). Error handling tests cover invalid API key (401), non-existent slugs (4xx), and missing API key (exit code 2). An
afterAllhook writes a JSON report totest/e2e-report.json.When
LIVE_TESTis unset, the entire suite is skipped viadescribe.runIf— existing CI is unaffected (confirmed: 151 tests pass, 75 e2e tests skipped).Updates since last revision
Round 1 (bot review):
beforeAll— was previously eagerly constructed at describe-body scopeexecSyncwithexecFileSync— avoids shell metacharacter injection; API key passed via env varexecSyncimportRound 2 (human review — @ckorhonen):
Math.abs(a - b) <= 1tolerance instead of exact.lengthequality, since data can change between sequential API calls[400, 404, 422]as acceptableOpenSeaAPIErrorstatus codes; 500s and other unexpected errors will correctly propagate as test failuresbeforeAllnow runsnpm run build(30s timeout) so CLI tests always execute against a freshdist/cli.jsinstead of potentially stale artifacts.gitignoreupdated — Addedtest/e2e-report.jsonto prevent accidental commits of the generated reportcli()helper usesparseArgs()regex to correctly handle double-quoted arguments (e.g.--value "New Punk Blue")Review & Testing Checklist for Human
LIVE_TEST=true OPENSEA_API_KEY=<key> npx vitest run test/e2e.test.ts.lengthcomparisons is an improvement over exact matching but is still somewhat arbitrary. On high-churn endpoints the counts could diverge by more than 1 between sequential calls. Consider whether structural/field-level comparison (e.g. comparing first item IDs) would be more robust.[400, 404, 422]. A 429 (rate limit) during the swap quote call will propagate as a hard failure. Verify this doesn't happen during a full test run.Notes
searchcommand is intentionally excluded — ticket specifies exactly 8 domains and does not list searchbeforeAlladds ~30s to test startup; ensures CLI tests run against current code but may affect CI timingLink to Devin Session: https://app.devin.ai/sessions/0a1a825e89dc41c5a3f3a68952aa262d
Requested by: @ckorhonen