Skip to main content

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:

  1. Facebook Publishing

    • โœ… Successful publish
    • โœ… Missing page_id validation
    • โœ… Override page_id support
  2. Instagram Publishing

    • โœ… Successful publish
    • โœ… Text-only post rejection
    • โœ… Override ig_user_id support
  3. Twitter Publishing

    • โœ… Successful publish
    • โœ… 280 character limit
    • โœ… 4 image maximum
    • โœ… No mixing images + video
  4. FBINSTA (Both Platforms)

    • โœ… Publish to both successfully
    • โœ… Results for both platforms
  5. Smart Retry Logic

    • โœ… Retry only Instagram when Facebook succeeded
    • โœ… Retry only Facebook when Instagram succeeded
    • โœ… Preserve successful publishes
  6. 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.facebook contains 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.instagram contains 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.twitter contains 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.facebook and results.instagram both 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:

  1. Create platform with plaintext token
  2. Fetch platform from database
  3. Verify api_config.access_token_encrypted exists
  4. Verify encrypted object has: encrypted, iv, authTag
  5. 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:

  1. Create platform with encrypted token
  2. Publish post
  3. Verify workflow decrypts token successfully
  4. Verify publish succeeds

Expected:

  • โœ… Workflow decrypts token
  • โœ… Publish succeeds
  • โœ… No errors related to encryption

Test 3: No Plaintext in Logsโ€‹

Steps:

  1. Enable debug logging
  2. Publish post
  3. 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:

  1. Create post
  2. Measure time to publish
  3. Verify under 2 seconds

Test 2: Both Platforms Publish Timeโ€‹

Metric: Time to publish to both platforms Target: < 4 seconds Steps:

  1. Create FBINSTA post
  2. Measure time to publish to both
  3. Verify under 4 seconds

Test 3: Retry Performanceโ€‹

Metric: Time to retry failed platform Target: < 2 seconds Steps:

  1. Create post with previous failed attempt
  2. Measure retry time
  3. 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โ€‹

  1. All Tests Pass:

    • โœ… Mark Phase 3 complete
    • โœ… Move to Phase 4: Documentation & Deployment
  2. Some Tests Fail:

    • โŒ Debug and fix issues
    • โŒ Re-run tests
    • โŒ Repeat until all pass
  3. 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! ๐Ÿš€