Phase 3: Testing & Verification Guide
๐ฏ Overviewโ
This guide covers comprehensive testing of the unified publishing workflow to ensure:
- โ All platforms work correctly (Facebook, Instagram, Twitter)
- โ Smart retry logic functions as expected
- โ Content validation works properly
- โ Security is maintained (encrypted tokens)
- โ No regressions from refactoring
๐ Test Planโ
Phase 3.1: Integration Tests โ โ
File: /integration-tests/http/socials/unified-publish-workflow.spec.ts
Test Coverage:
-
Facebook Publishing
- โ Successful publish
- โ Missing page_id validation
- โ Override page_id support
-
Instagram Publishing
- โ Successful publish
- โ Text-only post rejection
- โ Override ig_user_id support
-
Twitter Publishing
- โ Successful publish
- โ 280 character limit
- โ 4 image maximum
- โ No mixing images + video
-
FBINSTA (Both Platforms)
- โ Publish to both successfully
- โ Results for both platforms
-
Smart Retry Logic
- โ Retry only Instagram when Facebook succeeded
- โ Retry only Facebook when Instagram succeeded
- โ Preserve successful publishes
-
Security & Encryption
- โ Tokens encrypted in database
- โ Tokens decrypted in workflow
- โ No plaintext in logs
๐งช Running Testsโ
Run All Integration Testsโ
yarn test:integration:http
Run Specific Test Fileโ
yarn test:integration:http ./integration-tests/http/socials/unified-publish-workflow.spec.ts
Run Specific Test Suiteโ
yarn test:integration:http -t "Unified Publishing Workflow"
Run Specific Test Caseโ
yarn test:integration:http -t "should publish to Facebook successfully"
๐ Test Scenariosโ
Scenario 1: Facebook-Only Postโ
Setup:
- Platform: Facebook
- Content: Single image + caption
- Metadata:
page_id,publish_target: "facebook"
Expected:
- โ Post published to Facebook
- โ
results.facebookcontains post ID - โ Post status = "posted"
- โ Post URL set to Facebook permalink
Scenario 2: Instagram-Only Postโ
Setup:
- Platform: Instagram
- Content: Single image + caption
- Metadata:
ig_user_id,publish_target: "instagram"
Expected:
- โ Post published to Instagram
- โ
results.instagramcontains media ID - โ Post status = "posted"
- โ Instagram permalink in insights
Scenario 3: Twitter Postโ
Setup:
- Platform: Twitter
- Content: Text (< 280 chars)
- Credentials: OAuth1 credentials
Expected:
- โ Tweet published
- โ
results.twittercontains tweet data - โ Post status = "posted"
Scenario 4: FBINSTA (Both Platforms)โ
Setup:
- Platform: Facebook & Instagram
- Content: Single image + caption
- Metadata:
page_id,ig_user_id,publish_target: "both"
Expected:
- โ Published to both platforms
- โ
results.facebookandresults.instagramboth present - โ Post status = "posted" (if both succeed)
- โ Both permalinks in insights
Scenario 5: Smart Retry - Instagram Failedโ
Setup:
- Platform: FBINSTA
- Previous attempt: Facebook โ , Instagram โ
- Metadata:
publish_target: "both"
Expected:
- โ Only publishes to Instagram (smart retry)
- โ Preserves Facebook success from previous attempt
- โ
retry_info.is_retry = true - โ
retry_info.retried_platform = "instagram"
Scenario 6: Smart Retry - Facebook Failedโ
Setup:
- Platform: FBINSTA
- Previous attempt: Facebook โ, Instagram โ
- Metadata:
publish_target: "both"
Expected:
- โ Only publishes to Facebook (smart retry)
- โ Preserves Instagram success from previous attempt
- โ
retry_info.is_retry = true - โ
retry_info.retried_platform = "facebook"
Scenario 7: Content Validation - Text-Only Instagramโ
Setup:
- Platform: Instagram
- Content: Caption only, no media
- Metadata:
ig_user_id,publish_target: "instagram"
Expected:
- โ Validation error
- โ Error message: "Text-only posts are not supported on Instagram"
- โ Post status remains "draft"
Scenario 8: Content Validation - Twitter Character Limitโ
Setup:
- Platform: Twitter
- Content: 281 characters
- Credentials: OAuth1
Expected:
- โ Validation error
- โ Error message: "Tweet text exceeds 280 characters"
- โ Post status remains "draft"
Scenario 9: Content Validation - Twitter Image Limitโ
Setup:
- Platform: Twitter
- Content: 5 images
- Credentials: OAuth1
Expected:
- โ Validation error
- โ Error message: "Twitter supports maximum 4 images"
- โ Post status remains "draft"
Scenario 10: Missing Credentialsโ
Setup:
- Platform: Facebook (no access_token)
- Content: Single image + caption
Expected:
- โ Validation error
- โ Error message: "No access token found"
- โ Post status remains "draft"
๐ Security Verificationโ
Test 1: Token Encryption in Databaseโ
Steps:
- Create platform with plaintext token
- Fetch platform from database
- Verify
api_config.access_token_encryptedexists - Verify encrypted object has:
encrypted,iv,authTag - Verify plaintext token is NOT in database
Expected:
{
"api_config": {
"access_token_encrypted": {
"encrypted": "...",
"iv": "...",
"authTag": "...",
"keyVersion": 1
}
}
}
Test 2: Token Decryption in Workflowโ
Steps:
- Create platform with encrypted token
- Publish post
- Verify workflow decrypts token successfully
- Verify publish succeeds
Expected:
- โ Workflow decrypts token
- โ Publish succeeds
- โ No errors related to encryption
Test 3: No Plaintext in Logsโ
Steps:
- Enable debug logging
- Publish post
- Check logs for plaintext tokens
Expected:
- โ No plaintext tokens in logs
- โ Only encrypted data or "[REDACTED]" in logs
๐ Performance Testingโ
Test 1: Single Platform Publish Timeโ
Metric: Time to publish to one platform Target: < 2 seconds Steps:
- Create post
- Measure time to publish
- Verify under 2 seconds
Test 2: Both Platforms Publish Timeโ
Metric: Time to publish to both platforms Target: < 4 seconds Steps:
- Create FBINSTA post
- Measure time to publish to both
- Verify under 4 seconds
Test 3: Retry Performanceโ
Metric: Time to retry failed platform Target: < 2 seconds Steps:
- Create post with previous failed attempt
- Measure retry time
- Verify under 2 seconds
โ Success Criteriaโ
Must Pass:โ
- โ All integration tests pass
- โ All platforms publish successfully
- โ Smart retry works correctly
- โ Content validation works
- โ Tokens are encrypted in DB
- โ No plaintext tokens in logs
- โ Performance targets met
Nice to Have:โ
- โ Test coverage > 80%
- โ No console errors
- โ Clean logs
๐ Debugging Failed Testsโ
Test Fails: "Post not found"โ
Cause: Post not created properly in beforeEach Fix: Check post creation response, verify ID
Test Fails: "Platform not found"โ
Cause: Platform not created properly Fix: Check platform creation response, verify ID
Test Fails: "No access token"โ
Cause: Token not encrypted properly Fix: Check encryption service, verify token helpers
Test Fails: "Validation error"โ
Cause: Content doesn't meet platform requirements Fix: Check content type, media attachments, caption length
Test Fails: "Workflow error"โ
Cause: Step failing in workflow Fix: Check workflow logs, identify failing step
๐ Test Execution Checklistโ
- Run all integration tests
- Verify all tests pass
- Check test coverage report
- Review console logs for errors
- Verify no plaintext tokens in logs
- Test each platform individually
- Test FBINSTA (both platforms)
- Test smart retry scenarios
- Test content validation
- Test security (encryption)
- Measure performance
- Document any issues found
- Fix any failing tests
- Re-run tests after fixes
- Get final approval
๐ Next Steps After Testingโ
-
All Tests Pass:
- โ Mark Phase 3 complete
- โ Move to Phase 4: Documentation & Deployment
-
Some Tests Fail:
- โ Debug and fix issues
- โ Re-run tests
- โ Repeat until all pass
-
Performance Issues:
- โ ๏ธ Optimize slow steps
- โ ๏ธ Add caching if needed
- โ ๏ธ Re-test performance
๐ Test Results Templateโ
# Test Results - Phase 3
**Date:** [Date]
**Tester:** [Name]
**Environment:** [Dev/Staging/Prod]
## Summary
- Total Tests: X
- Passed: X
- Failed: X
- Skipped: X
- Coverage: X%
## Platform Tests
- [ ] Facebook: PASS/FAIL
- [ ] Instagram: PASS/FAIL
- [ ] Twitter: PASS/FAIL
- [ ] FBINSTA: PASS/FAIL
## Smart Retry Tests
- [ ] Retry Instagram: PASS/FAIL
- [ ] Retry Facebook: PASS/FAIL
- [ ] Preserve Success: PASS/FAIL
## Validation Tests
- [ ] Text-only Instagram: PASS/FAIL
- [ ] Twitter Char Limit: PASS/FAIL
- [ ] Twitter Image Limit: PASS/FAIL
## Security Tests
- [ ] Token Encryption: PASS/FAIL
- [ ] Token Decryption: PASS/FAIL
- [ ] No Plaintext Logs: PASS/FAIL
## Performance Tests
- [ ] Single Platform: X seconds (Target: < 2s)
- [ ] Both Platforms: X seconds (Target: < 4s)
- [ ] Retry: X seconds (Target: < 2s)
## Issues Found
1. [Issue description]
2. [Issue description]
## Conclusion
[PASS/FAIL] - [Summary]
๐ฏ Ready to Test!โ
Run the tests and verify everything works! ๐