{
  "_meta": {
    "plan_id": "reactnative-rc-smoke",
    "plugin": "reactnative",
    "version": "1.0.0",
    "description": "Post-publish smoke plan for the AppsFlyer React Native plugin. Exercises SMOKE-001/002/003 against example_rc_smoke/, which pins react-native-appsflyer@<X.Y.Z-rcN> from npm. This plan never depends on plugin source.",
    "platforms": ["android", "ios"],
    "schema_version": "1.0.0",
    "tooling_contract_ref": "SMOKE-001, SMOKE-002, SMOKE-003"
  },

  "config": {
    "android": {
      "package_name": "com.appsflyer.engagement",
      "activity": "com.appsflyer.qa.reactnative.MainActivity",
      "apk_path": "example_rc_smoke/android/app/build/outputs/apk/debug/app-debug.apk",
      "build_cmd": "cd example_rc_smoke/android && ./gradlew assembleDebug"
    },
    "ios": {
      "bundle_id": "com.appsflyer.qa.reactnative",
      "app_path": "example_rc_smoke/ios/build/Build/Products/Debug-iphonesimulator/example.app",
      "build_cmd": "cd example_rc_smoke/ios && xcodebuild build -workspace example.xcworkspace -scheme example -configuration Debug -destination 'platform=iOS Simulator,id=$IOS_SIMULATOR_UDID' -derivedDataPath build"
    }
  },

  "phases": [
    {
      "id": "phase_1",
      "name": "Cold launch smoke (RC artifact)",
      "scenario_ref": "SMOKE-001",
      "description": "Fresh install using the npm-pinned RC build. Validates SDK startup, install conversion data, pre/post-start API markers, and standard events.",
      "requires_fresh_install": true,
      "wait_after_launch_sec": 60,
      "checks": [
        {
          "id": "sdk_started",
          "description": "startSDK returns a result",
          "type": "log_contains",
          "pattern": "[AF_QA][startSDK] result:",
          "fail_action": "abort"
        },
        {
          "id": "conversion_data",
          "description": "onInstallConversionData callback fires",
          "type": "log_contains",
          "pattern": "[AF_QA][CALLBACK][onInstallConversionData]",
          "fail_action": "fail"
        },
        {
          "id": "pre_start_complete",
          "description": "Pre-start auto APIs ran",
          "type": "log_contains",
          "pattern": "[AF_QA][AUTO_APIS] --- Pre-start auto APIs complete ---",
          "fail_action": "fail"
        },
        {
          "id": "post_start_complete",
          "description": "Post-start auto APIs ran",
          "type": "log_contains",
          "pattern": "[AF_QA][AUTO_APIS] --- Post-start auto APIs complete ---",
          "fail_action": "fail"
        },
        {
          "id": "events_fired",
          "description": "At least 3 logEvent calls recorded",
          "type": "count_matches",
          "pattern": "\\[AF_QA\\]\\[logEvent",
          "minimum": 3,
          "fail_action": "fail"
        },
        {
          "id": "no_fatal",
          "description": "No fatal exceptions or process crashes",
          "type": "absent",
          "patterns": ["FATAL EXCEPTION", "Process crashed"],
          "fail_action": "fail"
        }
      ]
    },

    {
      "id": "phase_2",
      "name": "Background deep link (RC artifact)",
      "scenario_ref": "SMOKE-002",
      "description": "Backgrounds the RC build after Phase 1. Deep link returns app to foreground. onDeepLinking fires with expected deep link value.",
      "requires_fresh_install": false,
      "wait_after_trigger_sec": 15,
      "deep_link_url": "afqa-reactnative://deeplink?deep_link_value=qa_deeplink_bg&af_sub1=background_test&pid=testmedia&c=deeplink_test",
      "pre_actions": {
        "android": ["adb shell input keyevent KEYCODE_HOME", "sleep 2"],
        "ios": ["xcrun simctl terminate {{UDID}} {{BUNDLE_ID}}", "sleep 1"]
      },
      "trigger": {
        "android": "adb shell am start -W -a android.intent.action.VIEW -d \"{{DEEP_LINK_URL}}\"",
        "ios": "xcrun simctl launch {{UDID}} {{BUNDLE_ID}} -deepLinkURL \"{{DEEP_LINK_URL}}\""
      },
      "checks": [
        {
          "id": "deep_link_received",
          "description": "onDeepLinking callback fires",
          "type": "log_contains",
          "pattern": "[AF_QA][CALLBACK][onDeepLinking]",
          "fail_action": "fail"
        },
        {
          "id": "deep_link_value",
          "description": "Deep link value matches qa_deeplink_bg",
          "type": "log_contains",
          "pattern": "qa_deeplink_bg",
          "fail_action": "fail"
        },
        {
          "id": "no_fatal",
          "description": "No fatal exceptions after deep link",
          "type": "absent",
          "patterns": ["FATAL EXCEPTION", "Process crashed"],
          "fail_action": "fail"
        }
      ]
    },

    {
      "id": "phase_3",
      "name": "Foreground deep link (RC artifact)",
      "scenario_ref": "SMOKE-003",
      "description": "Fresh install of the RC build, then deep link while app is in foreground. Verifies SDK start and deep link callback.",
      "requires_fresh_install": true,
      "wait_after_launch_sec": 60,
      "wait_after_trigger_sec": 15,
      "deep_link_url": "afqa-reactnative://deeplink?deep_link_value=qa_deeplink_fg&af_sub1=foreground_test&pid=testmedia&c=deeplink_test",
      "pre_actions": {
        "android": ["adb shell am start -a android.intent.action.MAIN -c android.intent.category.HOME", "sleep 1"],
        "ios": ["xcrun simctl terminate {{UDID}} {{BUNDLE_ID}}", "sleep 1"]
      },
      "trigger": {
        "android": "adb shell am start -W -a android.intent.action.VIEW -d \"{{DEEP_LINK_URL}}\"",
        "ios": "xcrun simctl launch {{UDID}} {{BUNDLE_ID}} -deepLinkURL \"{{DEEP_LINK_URL}}\""
      },
      "checks": [
        {
          "id": "sdk_started",
          "description": "startSDK returns a result on fresh install",
          "type": "log_contains",
          "pattern": "[AF_QA][startSDK] result:",
          "fail_action": "abort"
        },
        {
          "id": "deep_link_received",
          "description": "onDeepLinking callback fires after foreground deep link",
          "type": "log_contains",
          "pattern": "[AF_QA][CALLBACK][onDeepLinking]",
          "fail_action": "fail"
        },
        {
          "id": "deep_link_value",
          "description": "Deep link value matches qa_deeplink_fg",
          "type": "log_contains",
          "pattern": "qa_deeplink_fg",
          "fail_action": "fail"
        },
        {
          "id": "no_fatal",
          "description": "No fatal exceptions",
          "type": "absent",
          "patterns": ["FATAL EXCEPTION", "Process crashed"],
          "fail_action": "fail"
        }
      ]
    }
  ],

  "report": {
    "output_dir": ".af-smoke/reports"
  }
}
