1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//! End-to-End Test Framework for DCG
//!
//! This module provides comprehensive E2E testing infrastructure that serves as
//! the foundation for testing across all DCG epics. It offers:
//!
//! - **Test Context Management**: Isolated test environments with temp directories,
//! config files, and environment variable control.
//! - **DCG Binary Interaction**: Helpers to run the DCG binary with various inputs
//! and validate outputs.
//! - **Detailed Logging**: Structured logging for debugging test failures.
//! - **Fixtures**: Pre-defined configs, commands, and mock git repos.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ E2E Test Suite │
//! ├─────────────────────────────────────────────────────────────────┤
//! │ test_pattern_testing.rs │ Epic 1: Pattern testing tool │
//! │ test_explanations.rs │ Epic 2: Natural language │
//! │ test_suggestions.rs │ Epic 3: Command rewriting │
//! │ test_auto_suggest.rs │ Epic 4: Automatic suggestions │
//! │ test_path_allowlist.rs │ Epic 5: Context-aware allowlist │
//! │ test_temp_allowlist.rs │ Epic 6: Temporary/expiring rules │
//! │ test_interactive.rs │ Epic 7: Interactive learning │
//! │ test_git_awareness.rs │ Epic 8: Git branch awareness │
//! │ test_agent_profiles.rs │ Epic 9: Agent-specific profiles │
//! │ test_graduated_response.rs│ Epic 10: Graduated response │
//! └─────────────────────────────────────────────────────────────────┘
//! │
//! ▼
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ Framework (framework.rs) │
//! ├─────────────────────────────────────────────────────────────────┤
//! │ E2ETestContext │ Isolated test environment │
//! │ DcgOutput │ Captured stdout/stderr/exit code │
//! │ TestAssertion │ Fluent assertions for test outcomes │
//! └─────────────────────────────────────────────────────────────────┘
//! │
//! ▼
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ Logging (logging.rs) │
//! ├─────────────────────────────────────────────────────────────────┤
//! │ TestLogger │ Detailed, parseable test logs │
//! │ TestReport │ Summary report generation │
//! └─────────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Usage
//!
//! ```ignore
//! use tests::e2e::{E2ETestContext, DcgOutput};
//!
//! #[test]
//! fn test_git_reset_hard_is_blocked() {
//! let ctx = E2ETestContext::new("git_reset_hard_blocked")
//! .with_config("minimal")
//! .build();
//!
//! let output = ctx.run_dcg_hook("git reset --hard");
//!
//! ctx.assert_blocked(&output);
//! assert!(output.contains_rule_id("core.git:reset-hard"));
//! }
//! ```
//!
//! # Fixtures
//!
//! The framework includes pre-defined fixtures in `tests/e2e/fixtures/`:
//!
//! - **configs/**: TOML configuration files for various scenarios
//! - `minimal.toml`: Bare minimum config
//! - `full_featured.toml`: All features enabled
//! - `path_specific.toml`: Path-aware allowlists
//! - `temporary_rules.toml`: TTL and session rules
//! - `agent_profiles.toml`: Per-agent settings
//! - `git_awareness.toml`: Branch-specific settings
//! - `graduated_response.toml`: Response graduation config
//!
//! - **commands/**: Test command sets
//! - `dangerous.txt`: Commands that should be blocked
//! - `safe.txt`: Commands that should be allowed
//! - `edge_cases.txt`: Boundary conditions
// Re-export commonly used types for convenience
pub use ;
pub use ;
/// Module-level test initialization.
///
/// Call this at the start of each test file to ensure proper logging setup.