Files
cleveragents-core/robot/output_rendering.robot
T
freemo 4e5e0624fd feat(cli): implement RendererRegistry and ElementRenderer architecture per spec
Implement the three missing architectural components of the Output Rendering
Framework as specified in issue #917:

1. RendererRegistry (spec §27249-27350): Central registry for format
   (MaterializationStrategy, ElementRenderer) pairs with register(),
   resolve(), available_formats(), is_registered() methods and a
   FormatRegistration model. Built-in formats pre-registered in
   default_registry. Replaces hardcoded if/elif chains for format
   resolution.

2. ElementRenderer Protocol (spec §26557-26654): Per-element render
   methods (render_panel, render_table, render_tree, etc.) plus
   serialize() and can_render(). Six concrete implementations:
   PlainElementRenderer, ColorElementRenderer, TableElementRenderer,
   RichElementRenderer, JsonElementRenderer, YamlElementRenderer.
   Each format now has a paired (Strategy, Renderer).

3. TerminalCapabilities (spec §27264-27301): Extended from 4 fields to
   all 11 spec-defined fields: width, height, supports_256_color,
   supports_truecolor, supports_unicode, supports_alternate_screen,
   no_color, plus renames supports_cursor → supports_cursor_movement,
   term → term_program. Backward-compatible properties preserved.

Additional fixes:
- ColumnDef serialises column type as 'type' (not 'col_type') per spec
  §26199, with alias for backward compatibility
- YAML output uses sort_keys=True per spec §27168
- Progress elements omitted from JSON/YAML per spec §26936
- MaterializationStrategy.bind(renderer, terminal_caps) method added
  to protocol and all strategy implementations (SD-19 resolved)
- Updated SD documentation in __init__.py

ISSUES CLOSED: #917
2026-06-02 16:48:22 -04:00

122 lines
6.1 KiB
Plaintext

*** Settings ***
Documentation End-to-end output rendering framework verification
Resource ${CURDIR}/common.resource
Suite Setup Setup Test Environment
Suite Teardown Cleanup Test Environment
*** Variables ***
${HELPER} ${CURDIR}/helper_output_rendering.py
*** Test Cases ***
Plain Format Renders Panel Without ANSI Codes
[Documentation] Verify plain format produces ASCII-only panel output
${result}= Run Process ${PYTHON} ${HELPER} plain-panel cwd=${WORKSPACE} timeout=120s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} output-rendering-plain-panel-ok
JSON Format Produces Valid JSON With Elements
[Documentation] Verify JSON format serialises elements as valid JSON
${result}= Run Process ${PYTHON} ${HELPER} json-output cwd=${WORKSPACE} timeout=120s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} output-rendering-json-output-ok
YAML Format Produces Valid YAML With Elements
[Documentation] Verify YAML format serialises elements as valid YAML
${result}= Run Process ${PYTHON} ${HELPER} yaml-output cwd=${WORKSPACE} timeout=120s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} output-rendering-yaml-output-ok
Table Format Renders Box Drawing Characters
[Documentation] Verify table format uses Unicode box-drawing for tables (P2-5)
${result}= Run Process ${PYTHON} ${HELPER} table-boxdraw cwd=${WORKSPACE} timeout=120s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} output-rendering-table-boxdraw-ok
Color Format Includes ANSI Codes
[Documentation] Verify color format includes ANSI escape codes
${result}= Run Process ${PYTHON} ${HELPER} color-ansi cwd=${WORKSPACE} timeout=120s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} output-rendering-color-ansi-ok
Error Envelope In JSON Mode
[Documentation] Verify error envelope structure in JSON mode
${result}= Run Process ${PYTHON} ${HELPER} json-error cwd=${WORKSPACE} timeout=120s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} output-rendering-json-error-ok
Format Output Backward Compatibility
[Documentation] Verify format_output still works for all formats
${result}= Run Process ${PYTHON} ${HELPER} backward-compat cwd=${WORKSPACE} timeout=120s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} output-rendering-backward-compat-ok
Materializer Selection Fallback
[Documentation] Verify materializer selection with fallback logic
${result}= Run Process ${PYTHON} ${HELPER} selection-fallback cwd=${WORKSPACE} timeout=120s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} output-rendering-selection-fallback-ok
Tree Element Renders Across Formats
[Documentation] Verify tree element renders in plain and JSON formats
${result}= Run Process ${PYTHON} ${HELPER} tree cwd=${WORKSPACE} timeout=120s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} output-rendering-tree-ok
Code Element Renders With Line Numbers
[Documentation] Verify code block renders with line numbers in plain format
${result}= Run Process ${PYTHON} ${HELPER} code cwd=${WORKSPACE} timeout=120s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} output-rendering-code-ok
Diff Element Renders Unified Diff
[Documentation] Verify diff block renders unified diff format
${result}= Run Process ${PYTHON} ${HELPER} diff cwd=${WORKSPACE} timeout=120s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} output-rendering-diff-ok
Text Separator And Action Hint Render
[Documentation] Verify text, separator, and action hint elements render
${result}= Run Process ${PYTHON} ${HELPER} text-sep-hint cwd=${WORKSPACE} timeout=120s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} output-rendering-text-sep-hint-ok
JSON Serializes All Element Types
[Documentation] Verify JSON format serializes all element types (progress omitted per spec §26936)
${result}= Run Process ${PYTHON} ${HELPER} json-all cwd=${WORKSPACE} timeout=120s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} output-rendering-json-all-ok
YAML Serializes All Element Types
[Documentation] Verify YAML format serializes all element types (progress omitted per spec §26936)
${result}= Run Process ${PYTHON} ${HELPER} yaml-all cwd=${WORKSPACE} timeout=120s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} output-rendering-yaml-all-ok