diff --git a/800.md b/800.md index b77fbdbf..72718795 100644 --- a/800.md +++ b/800.md @@ -20,6 +20,7 @@ The need for BDD payloads arises from the desire to integrate automated testing ##### 1. **Event Structure** A BDD payload is a specialized Nostr event (`kind` value: `800`). The payload must conform to the following structure: +```json ```json { "id": "", @@ -28,14 +29,24 @@ A BDD payload is a specialized Nostr event (`kind` value: `800`). The payload mu "kind": 800, "tags": [ ["test-suite", ""], + ["test-feature", ""], ["test-scenario", ""], ["test-description", ""], ["expected-result", ""] ], "content": { - "given": "", - "when": "", - "then": "" + "feature": "", + "background": { + "given": "" + }, + "scenario": { + "name": "", + "steps": [ + {"given": ""}, + {"when": ""}, + {"then": ""} + ] + } }, "sig": "" } @@ -46,25 +57,28 @@ A BDD payload is a specialized Nostr event (`kind` value: `800`). The payload mu ##### 2. **Tags** - **`test-suite`**: The name of the test suite. -- **`test-scenario`**: A specific scenario name within the test suite. +- **`test-feature`**: The name of the feature being tested. +- **`test-scenario`**: A specific scenario name within the feature. - **`test-description`**: A detailed description of the test case. - **`expected-result`**: The expected outcome for validation. --- ##### 3. **BDD Payload Content** -The `content` field must contain the BDD clauses: -- **`given`**: The initial context or state. -- **`when`**: The action or trigger. -- **`then`**: The expected outcome or result. +The `content` field must include the following keywords: +- **`feature`**: A high-level description of the feature under test. +- **`background`**: Contains shared setup steps or context that applies to multiple scenarios (uses the **`given`** keyword). +- **`scenario`**: Describes a specific scenario to be tested. It includes: + - **`name`**: The name of the scenario. + - **`steps`**: A list of BDD steps using the **`given`**, **`when`**, and **`then`** keywords. --- ##### 4. **Relay Execution** Relays supporting NIP-800 must: 1. Validate the event structure and signature. -2. Parse the `content` to extract the BDD clauses. -3. Execute the BDD test using a sandboxed runtime environment. +2. Parse the `content` to extract the BDD elements: **feature**, **background**, and **scenario**. +3. Execute the BDD test using a sandboxed runtime environment, applying the `background` steps before running the `scenario` steps. 4. Return the results as a new Nostr event (`kind: 801`). --- @@ -80,6 +94,7 @@ The results of a BDD test are published as a new event (`kind: 801`) by the rela "kind": 801, "tags": [ ["test-suite", ""], + ["test-feature", ""], ["test-scenario", ""], ["status", ""], ["error", ""] @@ -118,4 +133,3 @@ The results of a BDD test are published as a new event (`kind: 801`) by the rela - Support for additional test formats (e.g., unit tests). - Integration with popular test frameworks. - Mechanisms for incentivizing relays to execute tests (e.g., Lightning payments). -