Files
cleveractors-core/features/unit_json_sanitization.feature
2026-05-27 21:41:03 +00:00

74 lines
2.6 KiB
Gherkin

Feature: JSON Sanitization
Unit tests for JSON sanitization in CleverAgents Application.
Tests the _sanitize_json_string method that handles malformed JSON from LLMs.
Background:
Given I have an application with JSON sanitizer
Scenario: Valid JSON remains unchanged
Given a valid JSON string with file and content
When I sanitize the JSON string
Then the JSON should be unchanged
And the JSON should parse successfully
Scenario: Newline escaping
Given a JSON string with literal newlines in content
When I sanitize the JSON string
Then the JSON should parse successfully
And the content should contain all original lines
Scenario: Multiple consecutive newlines
Given a JSON string with multiple consecutive newlines
When I sanitize the JSON string
Then the JSON should parse successfully
Scenario: Complex content with newlines like blockchain example
Given a JSON string with complex multi-section blockchain content
When I sanitize the JSON string
Then the JSON should parse successfully
And the content should contain all blockchain sections
Scenario: Tab escaping
Given a JSON string with literal tabs
When I sanitize the JSON string
Then the JSON should parse successfully
Scenario: Carriage return escaping
Given a JSON string with carriage returns
When I sanitize the JSON string
Then the JSON should parse successfully
Scenario: Mixed control characters
Given a JSON string with mixed control characters
When I sanitize the JSON string
Then the JSON should parse successfully
Scenario: Empty content
Given a JSON string with empty content
When I sanitize the JSON string
Then the JSON should parse successfully
And the content should be empty
Scenario: Content with escaped quotes
Given a JSON string with escaped quotes in content
When I sanitize the JSON string
Then the JSON should parse successfully
Scenario: Long content
Given a JSON string with very long content
When I sanitize the JSON string
Then the JSON should parse successfully
And the content should be longer than 1000 characters
Scenario: Special characters preserved
Given a JSON string with special characters
When I sanitize the JSON string
Then the JSON should parse successfully
And special characters should be preserved
Scenario: Unicode characters preserved
Given a JSON string with unicode characters
When I sanitize the JSON string
Then the JSON should parse successfully
And unicode characters should be preserved