diff --git a/grasp-audit/src/fixtures.rs b/grasp-audit/src/fixtures.rs index e34ee6d..71d64d3 100644 --- a/grasp-audit/src/fixtures.rs +++ b/grasp-audit/src/fixtures.rs @@ -199,18 +199,25 @@ impl<'a> TestContext<'a> { } FixtureKind::RepoWithIssue => { - // First create repo + use nostr_sdk::prelude::*; + + // First create and send repo let test_name = format!("fixture-{:?}-{}", FixtureKind::ValidRepo, &uuid::Uuid::new_v4().to_string()[..8]); let repo = self.client.create_repo_announcement(&test_name).await?; self.client.send_event(repo.clone()).await?; - // Then create issue referencing it - self.client.create_issue( + // Then create issue referencing it - this will have 'a' tag to repo + // Note: We build the issue but DON'T send it here - the caller will send it + let issue = self.client.create_issue( &repo, "Test Issue", "Issue content for testing", vec![], - ) + )?; + + // Return the issue - tests can extract repo reference from its 'a' tag + // The caller (create_fresh/get_or_create_shared) will send this event + Ok(issue) } FixtureKind::RepoWithComment => { diff --git a/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs b/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs index 353d2c3..176b19a 100644 --- a/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs +++ b/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs @@ -645,27 +645,10 @@ impl EventAcceptancePolicyTests { // Create TestContext let ctx = TestContext::new(client); - // Get repo with issue fixture (mode-aware) - let repo_a = ctx.get_fixture(FixtureKind::RepoWithIssue).await + // Get repo with issue fixture (mode-aware) - returns the issue event + let issue_a = ctx.get_fixture(FixtureKind::RepoWithIssue).await .map_err(|e| format!("Test setup failed: could not get repo with issue fixture: {}", e))?; - // Extract the issue from the repo_a event (it's stored as the first 'e' tag) - let issue_a_id = repo_a.tags.iter() - .find(|t| t.kind() == TagKind::e()) - .and_then(|t| t.content()) - .ok_or("Missing issue reference in RepoWithIssue fixture")?; - - // Query to get the actual issue event - let filter = Filter::new().id( - nostr_sdk::EventId::from_hex(issue_a_id) - .map_err(|e| format!("Invalid issue ID: {}", e))? - ); - let issues = client.query(filter).await - .map_err(|e| format!("Failed to query issue: {}", e))?; - let issue_a = issues.first() - .ok_or("Issue not found")? - .clone(); - // Create Repo B but DON'T send it (unaccepted) - just for creating Issue B let repo_b = Self::create_test_repo(client, "repo-b").await?; @@ -701,27 +684,10 @@ impl EventAcceptancePolicyTests { // Create TestContext let ctx = TestContext::new(client); - // Get repo with issue fixture (mode-aware) - let repo = ctx.get_fixture(FixtureKind::RepoWithIssue).await + // Get repo with issue fixture (mode-aware) - returns the issue event + let issue = ctx.get_fixture(FixtureKind::RepoWithIssue).await .map_err(|e| format!("Test setup failed: could not get repo with issue fixture: {}", e))?; - // Extract the issue from the repo event (it's stored as the first 'e' tag) - let issue_id = repo.tags.iter() - .find(|t| t.kind() == TagKind::e()) - .and_then(|t| t.content()) - .ok_or("Missing issue reference in RepoWithIssue fixture")?; - - // Query to get the actual issue event - let filter = Filter::new().id( - nostr_sdk::EventId::from_hex(issue_id) - .map_err(|e| format!("Invalid issue ID: {}", e))? - ); - let issues = client.query(filter).await - .map_err(|e| format!("Failed to query issue: {}", e))?; - let issue = issues.first() - .ok_or("Issue not found")? - .clone(); - // Create comment using the helper (which adds NIP-22 tags including 'E') let comment = Self::create_comment_for_event(client, &issue, "Comment content")?;