---
setup:
  - do:
      cluster.health:
        wait_for_status: yellow

---
teardown:
  - do:
      xpack.watcher.delete_watch:
        id: "my_watch1"
        ignore: 404

---
"Test put watch api with action level condition":
  - do:
      xpack.watcher.put_watch:
        id: "my_watch1"
        master_timeout: "40s"
        body:  >
          {
            "trigger": {
              "schedule": {
                "hourly": {
                  "minute": [ 0, 5 ]
                  }
                }
            },
            "input": {
              "simple": {
                "payload": {
                  "value": 15
                }
              }
            },
            "condition": {
              "always": {}
            },
            "actions": {
              "test_index": {
                "condition": {
                  "ctx.payload.value": {
                    "gt": 10
                  }
                },
                "index": {
                  "index": "test",
                  "doc_type": "test2"
                }
              }
            }
          }
  - match: { _id: "my_watch1" }

  - do:
      xpack.watcher.get_watch:
        id: "my_watch1"
  - match: { found : true}
  - match: { _id: "my_watch1" }
  - match: { watch.actions.test_index.condition.ctx.payload.value.gt: 10 }

---
setup:
  - do:
      cluster.health:
        wait_for_status: yellow

---
teardown:
  - do:
      xpack.watcher.delete_watch:
        id: "my_watch1"
        ignore: 404

---
"Test put watch api with action level condition":
  -skip:
      version: "all"
      reason: awaits fix bug URL https://github.com/elastic/x-plugins/issues/3137
  - do:
      xpack.watcher.put_watch:
        id: "my_watch1"
        master_timeout: "40s"
        body:  >
          {
            "trigger": {
              "schedule": {
                "hourly": {
                  "minute": [ 0, 5 ]
                  }
                }
            },
            "input": {
              "simple": {
                "payload": {
                  "value": 15
                }
              }
            },
            "condition": {
              "always": {}
            },
            "actions": {
              "test_index": {
                "condition": {
                  "ctx.payload.value": {
                    "gt": 10
                  }
                },
                "index": {
                  "index": "test",
                  "doc_type": "test2"
                }
              }
            }
          }
  - match: { _id: "my_watch1" }

  - do:
      xpack.watcher.get_watch:
        id: "my_watch1"
  - match: { found : true}
  - match: { _id: "my_watch1" }
  - match: { watch.actions.test_index.condition.ctx.payload.value.gt: 10 }

Mark failing Watcher REST test as awaits fix
Mark failing Watcher REST test as awaits fix

This commit marks a failing Watcher REST test with seed 97AAFD9CA37864EE
as awaits fix.

Original commit: elastic/x-pack-elasticsearch@5e19f0169cd2f96a396702c642f043c367bfd2e4
