Added "feature", "background" and "scenario" keywords

This commit is contained in:
Steven Joseph 2025-01-28 14:43:01 +11:00
parent f847e414db
commit 5c8fd0fe91
No known key found for this signature in database
GPG Key ID: 982E27B3BDB107AA

36
800.md
View File

@ -20,6 +20,7 @@ The need for BDD payloads arises from the desire to integrate automated testing
##### 1. **Event Structure** ##### 1. **Event Structure**
A BDD payload is a specialized Nostr event (`kind` value: `800`). The payload must conform to the following structure: A BDD payload is a specialized Nostr event (`kind` value: `800`). The payload must conform to the following structure:
```json
```json ```json
{ {
"id": "<event_id>", "id": "<event_id>",
@ -28,14 +29,24 @@ A BDD payload is a specialized Nostr event (`kind` value: `800`). The payload mu
"kind": 800, "kind": 800,
"tags": [ "tags": [
["test-suite", "<suite_name>"], ["test-suite", "<suite_name>"],
["test-feature", "<feature_name>"],
["test-scenario", "<scenario_name>"], ["test-scenario", "<scenario_name>"],
["test-description", "<description>"], ["test-description", "<description>"],
["expected-result", "<expected_result>"] ["expected-result", "<expected_result>"]
], ],
"content": { "content": {
"given": "<given_clause>", "feature": "<feature_description>",
"when": "<when_clause>", "background": {
"then": "<then_clause>" "given": "<background_given_clause>"
},
"scenario": {
"name": "<scenario_name>",
"steps": [
{"given": "<given_clause>"},
{"when": "<when_clause>"},
{"then": "<then_clause>"}
]
}
}, },
"sig": "<signature>" "sig": "<signature>"
} }
@ -46,25 +57,28 @@ A BDD payload is a specialized Nostr event (`kind` value: `800`). The payload mu
##### 2. **Tags** ##### 2. **Tags**
- **`test-suite`**: The name of the test suite. - **`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. - **`test-description`**: A detailed description of the test case.
- **`expected-result`**: The expected outcome for validation. - **`expected-result`**: The expected outcome for validation.
--- ---
##### 3. **BDD Payload Content** ##### 3. **BDD Payload Content**
The `content` field must contain the BDD clauses: The `content` field must include the following keywords:
- **`given`**: The initial context or state. - **`feature`**: A high-level description of the feature under test.
- **`when`**: The action or trigger. - **`background`**: Contains shared setup steps or context that applies to multiple scenarios (uses the **`given`** keyword).
- **`then`**: The expected outcome or result. - **`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** ##### 4. **Relay Execution**
Relays supporting NIP-800 must: Relays supporting NIP-800 must:
1. Validate the event structure and signature. 1. Validate the event structure and signature.
2. Parse the `content` to extract the BDD clauses. 2. Parse the `content` to extract the BDD elements: **feature**, **background**, and **scenario**.
3. Execute the BDD test using a sandboxed runtime environment. 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`). 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, "kind": 801,
"tags": [ "tags": [
["test-suite", "<suite_name>"], ["test-suite", "<suite_name>"],
["test-feature", "<feature_name>"],
["test-scenario", "<scenario_name>"], ["test-scenario", "<scenario_name>"],
["status", "<pass|fail>"], ["status", "<pass|fail>"],
["error", "<error_message_if_any>"] ["error", "<error_message_if_any>"]
@ -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). - Support for additional test formats (e.g., unit tests).
- Integration with popular test frameworks. - Integration with popular test frameworks.
- Mechanisms for incentivizing relays to execute tests (e.g., Lightning payments). - Mechanisms for incentivizing relays to execute tests (e.g., Lightning payments).