{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mobster.dev/schema/webhooks/suite.finished.json",
  "title": "A test suite finished",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "type",
    "suite",
    "project",
    "verdict",
    "exitCode",
    "counts",
    "startedAt",
    "finishedAt",
    "durationMs",
    "git",
    "failures",
    "report",
    "text"
  ],
  "properties": {
    "type": {
      "const": "suite.finished",
      "description": "The event, as the Mobster-Event header names it."
    },
    "suite": {
      "type": "string",
      "description": "The suite's id: its folder under .mobster/test-results."
    },
    "project": {
      "type": "string",
      "description": "The project folder's name; for a git worktree, such as each pull request mobster test pr --watch tests, its repository's."
    },
    "verdict": {
      "enum": [
        "passed",
        "failed",
        "needs_review",
        "couldnt_run",
        "stopped"
      ]
    },
    "exitCode": {
      "type": "integer",
      "description": "The exit code mobster test returns for it."
    },
    "counts": {
      "type": "object",
      "description": "The checks' results on every device, by verdict. Quarantined ones never decide the suite.",
      "additionalProperties": false,
      "required": [
        "passed",
        "failed",
        "needsReview",
        "couldntRun",
        "flaky",
        "quarantined",
        "total"
      ],
      "properties": {
        "passed": {
          "type": "integer",
          "minimum": 0
        },
        "failed": {
          "type": "integer",
          "minimum": 0
        },
        "needsReview": {
          "type": "integer",
          "minimum": 0
        },
        "couldntRun": {
          "type": "integer",
          "minimum": 0
        },
        "flaky": {
          "type": "integer",
          "minimum": 0
        },
        "quarantined": {
          "type": "integer",
          "minimum": 0
        },
        "total": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "startedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "UTC, ISO 8601. Null when unknown."
    },
    "finishedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "UTC, ISO 8601. Null when unknown."
    },
    "durationMs": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0
    },
    "git": {
      "anyOf": [
        {
          "type": "object",
          "description": "What the suite tested. Null outside a git checkout.",
          "additionalProperties": false,
          "required": [
            "branch",
            "head"
          ],
          "properties": {
            "branch": {
              "type": [
                "string",
                "null"
              ],
              "description": "The branch."
            },
            "head": {
              "type": [
                "string",
                "null"
              ],
              "description": "The commit."
            }
          }
        },
        {
          "type": "null"
        }
      ]
    },
    "failures": {
      "type": "array",
      "maxItems": 40,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "check",
          "file",
          "device",
          "status",
          "expected",
          "found",
          "replay",
          "report"
        ],
        "properties": {
          "check": {
            "type": "string",
            "description": "The check's name, or an XCTest case as Target: Class.test."
          },
          "file": {
            "type": [
              "string",
              "null"
            ],
            "description": "The check file, relative to the project. A file outside it has its full path, with the home folder as ~. Null for an XCTest case."
          },
          "device": {
            "type": [
              "string",
              "null"
            ],
            "description": "The simulator or iPhone it ran on."
          },
          "status": {
            "enum": [
              "failed",
              "needs_review",
              "couldnt_run"
            ]
          },
          "expected": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the check expected, in its own words. Null when it didn't get that far."
          },
          "found": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the screen showed instead, or why it couldn't decide or run."
          },
          "replay": {
            "type": [
              "string",
              "null"
            ],
            "description": "The command that runs this check again on that device. It replays the steps that Mac recorded and heals a step that changed with a model; a Mac without them records them again with a model. Null for an XCTest case."
          },
          "report": {
            "type": [
              "string",
              "null"
            ],
            "description": "With --share: this result's page in the hosted report, with the screen at its verdict. The key that opens it is after #. Null otherwise."
          }
        }
      },
      "description": "Each result that didn't pass, quarantined ones and drafts left out."
    },
    "report": {
      "type": [
        "string",
        "null"
      ],
      "description": "With --share: the hosted report. The key that opens it is after #. Null otherwise."
    },
    "text": {
      "type": "string",
      "description": "The suite in a few lines for chat tools: the verdict, the counts, each check that didn't pass, and the report when shared."
    }
  }
}
