Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
305 changes: 0 additions & 305 deletions tests/compiler_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,311 +824,6 @@ fn test_1es_compiled_output_no_unreplaced_markers() {
let _ = fs::remove_dir_all(&temp_dir);
}

/// Test that update-wiki-page requires a write service connection
#[test]
fn test_update_wiki_page_requires_write_sc() {
let temp_dir =
std::env::temp_dir().join(format!("agentic-pipeline-wiki-fail-{}", std::process::id()));
fs::create_dir_all(&temp_dir).expect("Failed to create temp directory");

let test_input = temp_dir.join("wiki-agent.md");
let test_content = r#"---
name: "Wiki Agent"
description: "Agent that edits wiki pages but has no write SC"
safe-outputs:
update-wiki-page:
wiki-name: "MyProject.wiki"
path-prefix: "/agent-output"
---

## Wiki Agent

Update the wiki.
"#;
fs::write(&test_input, test_content).expect("Failed to write test input");

let output_path = temp_dir.join("wiki-agent.yml");
let binary_path = PathBuf::from(env!("CARGO_BIN_EXE_ado-aw"));
let output = std::process::Command::new(&binary_path)
.args([
"compile",
test_input.to_str().unwrap(),
"-o",
output_path.to_str().unwrap(),
])
.output()
.expect("Failed to run compiler");

assert!(
!output.status.success(),
"Compiler should fail when update-wiki-page lacks a write SC"
);

let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("permissions.write"),
"Error message should mention permissions.write: {stderr}"
);

let _ = fs::remove_dir_all(&temp_dir);
}

/// Test that update-wiki-page compiles successfully when a write SC is present
#[test]
fn test_update_wiki_page_compiles_with_write_sc() {
let temp_dir =
std::env::temp_dir().join(format!("agentic-pipeline-wiki-pass-{}", std::process::id()));
fs::create_dir_all(&temp_dir).expect("Failed to create temp directory");

let test_input = temp_dir.join("wiki-agent.md");
let test_content = r#"---
name: "Wiki Agent"
description: "Agent that edits wiki pages with write SC"
permissions:
write: my-write-sc
safe-outputs:
update-wiki-page:
wiki-name: "MyProject.wiki"
path-prefix: "/agent-output"
title-prefix: "[Agent] "
comment: "Updated by agent"
create-if-missing: true
---

## Wiki Agent

Update the wiki.
"#;
fs::write(&test_input, test_content).expect("Failed to write test input");

let output_path = temp_dir.join("wiki-agent.yml");
let binary_path = PathBuf::from(env!("CARGO_BIN_EXE_ado-aw"));
let output = std::process::Command::new(&binary_path)
.args([
"compile",
test_input.to_str().unwrap(),
"-o",
output_path.to_str().unwrap(),
])
.output()
.expect("Failed to run compiler");

assert!(
output.status.success(),
"Compiler should succeed when write SC is provided: {}",
String::from_utf8_lossy(&output.stderr)
);

let _ = fs::remove_dir_all(&temp_dir);
}

/// Test that create-wiki-page requires a write service connection
#[test]
fn test_create_wiki_page_requires_write_sc() {
let temp_dir = std::env::temp_dir().join(format!(
"agentic-pipeline-create-wiki-fail-{}",
std::process::id()
));
fs::create_dir_all(&temp_dir).expect("Failed to create temp directory");

let test_input = temp_dir.join("create-wiki-agent.md");
let test_content = r#"---
name: "Create Wiki Agent"
description: "Agent that creates wiki pages but has no write SC"
safe-outputs:
create-wiki-page:
wiki-name: "MyProject.wiki"
path-prefix: "/agent-output"
---

## Create Wiki Agent

Create new wiki pages.
"#;
fs::write(&test_input, test_content).expect("Failed to write test input");

let output_path = temp_dir.join("create-wiki-agent.yml");
let binary_path = PathBuf::from(env!("CARGO_BIN_EXE_ado-aw"));
let output = std::process::Command::new(&binary_path)
.args([
"compile",
test_input.to_str().unwrap(),
"-o",
output_path.to_str().unwrap(),
])
.output()
.expect("Failed to run compiler");

assert!(
!output.status.success(),
"Compiler should fail when create-wiki-page lacks a write SC"
);

let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("permissions.write"),
"Error message should mention permissions.write: {stderr}"
);

let _ = fs::remove_dir_all(&temp_dir);
}

/// Test that create-wiki-page compiles successfully when a write SC is present
#[test]
fn test_create_wiki_page_compiles_with_write_sc() {
let temp_dir = std::env::temp_dir().join(format!(
"agentic-pipeline-create-wiki-pass-{}",
std::process::id()
));
fs::create_dir_all(&temp_dir).expect("Failed to create temp directory");

let test_input = temp_dir.join("create-wiki-agent.md");
let test_content = r#"---
name: "Create Wiki Agent"
description: "Agent that creates wiki pages with write SC"
permissions:
write: my-write-sc
safe-outputs:
create-wiki-page:
wiki-name: "MyProject.wiki"
path-prefix: "/agent-output"
title-prefix: "[Agent] "
comment: "Created by agent"
---

## Create Wiki Agent

Create new wiki pages.
"#;
fs::write(&test_input, test_content).expect("Failed to write test input");

let output_path = temp_dir.join("create-wiki-agent.yml");
let binary_path = PathBuf::from(env!("CARGO_BIN_EXE_ado-aw"));
let output = std::process::Command::new(&binary_path)
.args([
"compile",
test_input.to_str().unwrap(),
"-o",
output_path.to_str().unwrap(),
])
.output()
.expect("Failed to run compiler");

assert!(
output.status.success(),
"Compiler should succeed when write SC is provided: {}",
String::from_utf8_lossy(&output.stderr)
);

let _ = fs::remove_dir_all(&temp_dir);
}

/// Test that update-work-item requires a write service connection
#[test]
fn test_update_work_item_requires_write_sc() {
let temp_dir =
std::env::temp_dir().join(format!("agentic-pipeline-uwi-fail-{}", std::process::id()));
fs::create_dir_all(&temp_dir).expect("Failed to create temp directory");

let test_input = temp_dir.join("uwi-agent.md");
let test_content = r#"---
name: "Update Work Item Agent"
description: "Agent that updates work items but has no write SC"
safe-outputs:
update-work-item:
title: true
status: true
target: "*"
---

## Update Work Item Agent

Update existing work items.
"#;
fs::write(&test_input, test_content).expect("Failed to write test input");

let output_path = temp_dir.join("uwi-agent.yml");
let binary_path = PathBuf::from(env!("CARGO_BIN_EXE_ado-aw"));
let output = std::process::Command::new(&binary_path)
.args([
"compile",
test_input.to_str().unwrap(),
"-o",
output_path.to_str().unwrap(),
])
.output()
.expect("Failed to run compiler");

assert!(
!output.status.success(),
"Compiler should fail when update-work-item lacks a write SC"
);

let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("permissions.write"),
"Error message should mention permissions.write: {stderr}"
);

let _ = fs::remove_dir_all(&temp_dir);
}

/// Test that update-work-item compiles successfully when a write SC is present
#[test]
fn test_update_work_item_compiles_with_write_sc() {
let temp_dir =
std::env::temp_dir().join(format!("agentic-pipeline-uwi-pass-{}", std::process::id()));
fs::create_dir_all(&temp_dir).expect("Failed to create temp directory");

let test_input = temp_dir.join("uwi-agent.md");
let test_content = r#"---
name: "Update Work Item Agent"
description: "Agent that updates work items with write SC"
permissions:
write: my-write-sc
safe-outputs:
update-work-item:
title: true
status: true
body: true
markdown-body: true
title-prefix: "[bot] "
tag-prefix: "agent-"
max: 2
target: "*"
area-path: true
iteration-path: true
assignee: true
tags: true
---

## Update Work Item Agent

Update existing work items.
"#;
fs::write(&test_input, test_content).expect("Failed to write test input");

let output_path = temp_dir.join("uwi-agent.yml");
let binary_path = PathBuf::from(env!("CARGO_BIN_EXE_ado-aw"));
let output = std::process::Command::new(&binary_path)
.args([
"compile",
test_input.to_str().unwrap(),
"-o",
output_path.to_str().unwrap(),
])
.output()
.expect("Failed to run compiler");

assert!(
output.status.success(),
"Compiler should succeed when write SC is provided: {}",
String::from_utf8_lossy(&output.stderr)
);

let _ = fs::remove_dir_all(&temp_dir);
}

/// Test that comment-on-work-item requires a target field
#[test]
fn test_comment_on_work_item_requires_target_field() {
Expand Down