This document outlines the test scenarios covered by the EventStream E2E Validator framework.
File: tests/event-validation.spec.ts
- Objective: Verify that a valid order event is correctly published to Kafka and validates against the defined JSON schema.
- Steps:
- Subscribe to
order.eventstopic. - Publish a valid JSON event with
orderId,status,amount, andtimestamp. - Wait for the consumer to receive the event with the matching
orderId. - Validate the received event against
schema/order.schema.json.
- Subscribe to
- Expected Result:
- Event is received.
- Event data matches the published data.
- Schema validation passes (
isValid: true).
File: tests/advanced-scenarios.spec.ts
- Objective: Ensure that events violating the schema are correctly flagged as invalid.
- Steps:
- Subscribe to
order.eventstopic. - Publish an event missing a required field (e.g.,
amount). - Wait for the event.
- Validate against schema.
- Subscribe to
- Expected Result:
- Schema validation fails (
isValid: false). - Error details indicate the missing property.
- Schema validation fails (
- Objective: Verify that the test fails gracefully (times out) if the expected event does not arrive within the specified duration.
- Steps:
- Subscribe to
order.eventstopic. - Call
waitForEventfor anorderIdthat will NOT be published. - Set a short timeout (e.g., 2000ms).
- Subscribe to
- Expected Result:
- The
waitForEventpromise rejects with a "Timeout waiting for event" error.
- The
- Objective: Verify that the consumer can identify and capture a specific event from a stream containing multiple unrelated events.
- Steps:
- Subscribe to
order.eventstopic. - Publish "Noise Event 1".
- Publish "Target Event" (the one we are waiting for).
- Publish "Noise Event 2".
- Call
waitForEventfiltering for "Target Event" ID.
- Subscribe to
- Expected Result:
- The consumer correctly resolves with the "Target Event".
- Noise events do not trigger a false positive resolution.
File: tests/ui-integration.spec.ts
- Objective: Verify the end-to-end flow from a UI action to backend simulation and finally to Kafka event consumption.
- Steps:
- Subscribe to
order.eventstopic. - Load
src/mock/mock.htmlin the browser. - Intercept the API call to
http://localhost:5000/api/orders. - Click the "Place Order" button in the UI.
- In the interception handler, publish the event to Kafka.
- Wait for the consumer to receive the event.
- Subscribe to
- Expected Result:
- UI displays success message.
- Consumer receives the event with the correct
orderId. - Event data matches the UI action.