Skip to content

test: Add attachment E2E integration tests#574

Merged
limbonaut merged 26 commits intomainfrom
feat/attachment-e2e-tests
Mar 9, 2026
Merged

test: Add attachment E2E integration tests#574
limbonaut merged 26 commits intomainfrom
feat/attachment-e2e-tests

Conversation

@limbonaut
Copy link
Copy Markdown
Collaborator

@limbonaut limbonaut commented Mar 6, 2026

Add end-to-end integration tests for custom attachments, covering all 4 combinations of attachment type (file path vs bytes) and timing (configuration callback vs after init).

This is needed to verify that attachments added both during SDK configuration and at runtime are correctly sent to Sentry. The new attachment-capture CLI command exercises each path, and the Pester tests assert on name, type, content type, and size.

_init_sentry() now accepts an optional Callable for extra configuration, keeping the existing callers unchanged.

Note: file path attachments currently fail due to a known bug being fixed separately. Bytes attachments pass.

limbonaut and others added 11 commits March 6, 2026 11:29
SentrySDK.add_attachment() called inside the init() configuration
callback was silently lost because the internal SDK wasn't initialized
yet. Now, during the callback window, attachments are redirected to
options storage and registered with the platform SDK during init.

Split attachment storage in SentryOptions into default_attachments
(built-in: log, screenshot, view hierarchy — survive clear) and
custom_attachments (user-added during callback — ephemeral, consumed
at init). On clear_attachments(), only default attachments are
restored.

Co-Authored-By: Claude <noreply@anthropic.com>
Reuse add_attachment() after platform SDK init for custom attachments,
same pattern as NativeSDK. This correctly handles both file-path and
bytes attachments instead of only file-path.

Co-Authored-By: Claude <noreply@anthropic.com>
…S SDK

Bytes attachments added inside the configuration callback were silently
dropped on the web platform. The init method appended them to the
file_attachments vector instead of routing through add_attachment(),
which dispatches file vs bytes attachments correctly.

Co-Authored-By: Claude <noreply@anthropic.com>
Default attachments are always file-based (log, screenshot, view
hierarchy). Reject bytes attachments with an error to catch misuse
early.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Move custom attachment drain to after js_bridge init call, fixing
bytes attachments being sent before the bridge is ready. Also
normalize comments across all backends and add changelog entry.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Route clear_attachments() through options.clear_custom_attachments()
when called inside the configuration callback, consistent with how
add_attachment() already handles the is_configuring state. Previously,
clear_attachments() would fall through to DisabledSDK (a no-op),
leaving previously added custom attachments intact.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move the custom-attachment draining logic (iterate, add_attachment,
clear) from all four backend init() methods into SentrySDK::init(),
right after internal_sdk->init() succeeds. This eliminates identical
copy-pasted blocks in NativeSDK, AndroidSDK, CocoaSDK, and
JavaScriptSDK, reducing the risk of future inconsistencies.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Previously, add_default_attachment would dereference the Ref to check
get_path() without first verifying it's non-null, risking a crash.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

  • (init) Register event processors after configuration callback by limbonaut in #580

Internal Changes 🔧

  • Add attachment E2E integration tests by limbonaut in #574

🤖 This preview updates automatically when you update the PR.

@limbonaut limbonaut changed the title feat(tests): Add attachment E2E integration tests test: Add attachment E2E integration tests Mar 6, 2026
@limbonaut limbonaut marked this pull request as ready for review March 6, 2026 12:29
Comment thread project/cli/cli_commands.gd
limbonaut and others added 7 commits March 6, 2026 13:51
Add `attachment-capture` CLI command that tests all 4 attachment
combinations: file and bytes attachments added both in configuration
callback and after SDK initialization.

Add corresponding Pester test context that verifies each attachment
arrives at Sentry with correct name, type, content type, and size.

Closes #571

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Verify that no attachment has a blank name, guarding against the
regression fixed in #567.

Co-Authored-By: Claude <noreply@anthropic.com>
Add comment explaining why attachments are added inside the init
config callback — to verify they are retained after SDK initialization.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Verify that file attachments have the expected byte size to catch
cases where files are sent empty.

Co-Authored-By: Claude <noreply@anthropic.com>
@limbonaut limbonaut changed the base branch from main to limbonaut/fix/attachments-in-config-callback March 6, 2026 12:52
@limbonaut limbonaut force-pushed the feat/attachment-e2e-tests branch from 37406cd to cc5ad32 Compare March 6, 2026 12:52
In exported builds, res:// files are packed into the PCK/APK and
don't exist on the filesystem. Use user:// paths and write the
files at runtime so file path attachments work on all platforms.

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread project/cli/cli_commands.gd
Base automatically changed from limbonaut/fix/attachments-in-config-callback to main March 6, 2026 14:08
Explicitly enable attach_log and attach_scene_tree in the test
config and assert that godot.log and view-hierarchy.json are
present. Screenshot is not tested as it's unavailable in headless
mode.

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread project/cli/cli_commands.gd
Comment thread project/cli/cli_commands.gd
View hierarchy is not yet implemented on Cocoa platforms, so skip the
assertion to avoid false failures.

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread integration_tests/Integration.Tests.ps1 Outdated
Comment thread integration_tests/Integration.Tests.ps1 Outdated
Cocoa platforms don't include view-hierarchy.json, so the expected
count and assertion need to account for 5 attachments instead of 6.

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread integration_tests/Integration.Tests.ps1 Outdated
Pester v5 evaluates -Skip during Discovery phase, before BeforeAll
runs. Since $script:TestSetup.IsCocoa is initialized in BeforeAll,
the -Skip parameter was always falsy and the test never skipped.
Use an if-return guard inside the It block instead, matching the
existing pattern used elsewhere in the file.

Co-Authored-By: Claude <noreply@anthropic.com>
@limbonaut limbonaut merged commit 35225bc into main Mar 9, 2026
61 checks passed
@limbonaut limbonaut deleted the feat/attachment-e2e-tests branch March 9, 2026 15:24
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.

Add end-to-end tests for attachments

3 participants