Skip to content

🧪 Add tests for StructuredAnswer.citationIndex extraction#29

Open
Gunnarguy wants to merge 1 commit into
mainfrom
test-citation-index-14510794647580699205
Open

🧪 Add tests for StructuredAnswer.citationIndex extraction#29
Gunnarguy wants to merge 1 commit into
mainfrom
test-citation-index-14510794647580699205

Conversation

@Gunnarguy

@Gunnarguy Gunnarguy commented Jun 24, 2026

Copy link
Copy Markdown
Owner

🎯 What: Added tests for the citationIndex(from:) parsing logic inside StructuredAnswer.swift. This covers the previous testing gap for this utility function.
📊 Coverage: Covered valid scenarios (like "S1", "s2", "[S3]"), invalid scenarios (empty strings, "S", "S0"), and handling text containing multiple elements. Modified visibility of citationIndex from private to internal so it can be accessed via @testable import.
Result: Enhanced test coverage ensures the stability and reliability of inline citation extraction when formatting StructuredAnswers.


PR created automatically by Jules for task 14510794647580699205 started by @Gunnarguy

Summary by Sourcery

Add unit test coverage for StructuredAnswer inline citation index parsing and expose the helper for testing.

Enhancements:

  • Relax the visibility of StructuredAnswer.citationIndex(from:) from private to internal to allow direct testing.

Tests:

  • Add StructuredAnswerTests covering valid, invalid, and mixed-text inputs for citationIndex(from:).

Co-authored-by: Gunnarguy <110250624+Gunnarguy@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 24, 2026 23:08
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@sourcery-ai

sourcery-ai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds focused unit tests for StructuredAnswer.citationIndex(from:) and relaxes its visibility from private to internal to enable testing, improving coverage of inline citation parsing behavior.

File-Level Changes

Change Details Files
Expose citationIndex(from:) for testing and validate its parsing behavior via new unit tests.
  • Changed StructuredAnswer.citationIndex(from:) visibility from private to internal so it is accessible from the test target via @testable import.
  • Verified the regex-based parsing behavior for valid citation strings, ensuring 1-based indices are converted to 0-based (e.g., S1 → 0, S10 → 9).
  • Asserted that malformed or out-of-range citation strings (empty, missing number, zero/negative, non-numeric) return nil.
  • Confirmed behavior when citations appear within surrounding or extra text, relying on the first regex match in the string.
OpenIntelligence/Core/Models/StructuredAnswer.swift
OpenIntelligenceTests/Core/Models/StructuredAnswerTests.swift

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3fc29b18e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -0,0 +1,32 @@
import XCTest
@testable import OpenIntelligence

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Import the package module in the new test

In the SwiftPM test target, OpenIntelligenceTests depends on the OpenIntelligenceEngine product defined in Package.swift, and the existing tests all use @testable import OpenIntelligenceEngine. This new file imports OpenIntelligence, which is the app target name rather than a package dependency, so running the package tests will fail with no such module 'OpenIntelligence' before these assertions execute. Use @testable import OpenIntelligenceEngine here.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds unit tests for StructuredAnswer.citationIndex(from:) (the inline citation index parser) and relaxes the helper’s visibility from private to internal so it can be exercised via @testable import.

Changes:

  • Add StructuredAnswerTests covering valid, invalid, and mixed-text citation inputs.
  • Change StructuredAnswer.citationIndex(from:) visibility from private to internal for test access.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
OpenIntelligenceTests/Core/Models/StructuredAnswerTests.swift New unit tests validating citationIndex(from:) parsing behavior across multiple input shapes.
OpenIntelligence/Core/Models/StructuredAnswer.swift Exposes citationIndex(from:) as internal so tests can call it.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +2
import XCTest
@testable import OpenIntelligence
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants