Skip to content

fix(test): fix global-error test text matcher for split elements#803

Open
vdimarco wants to merge 4 commits into
masterfrom
fix/global-error-test-matcher
Open

fix(test): fix global-error test text matcher for split elements#803
vdimarco wants to merge 4 commits into
masterfrom
fix/global-error-test-matcher

Conversation

@vdimarco

@vdimarco vdimarco commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes the should display error message in development mode test in global-error.test.tsx

Problem

The error message in GlobalError component is rendered as:

<p className="text-xs font-mono text-destructive break-all">
  <strong>Error:</strong> {error.name}: {error.message}
</p>

This splits the text across multiple elements, so getByText('Test error message') fails because the text is not in a single element.

Solution

Changed the test to use container.querySelector('.bg-muted') and check textContent contains the error message instead of using getByText for exact matching.

Test plan

  • Run the specific test file locally and verify all tests pass
  • Verified the production mode test still works correctly

🤖 Generated with Claude Code

Greptile Summary

Fixed failing test in global-error.test.tsx by changing the test matcher to check container textContent instead of using getByText for exact matching. The error message is rendered as <strong>Error:</strong> {error.name}: {error.message}, which splits the text across multiple elements, causing the original test to fail.

Additional changes bundled in this PR:

  • Added desktop debugging features to GlobalError component with console logging and a "Show error details" button for desktop users
  • Added required NEXT_PUBLIC_PRIVY_APP_ID and API base URL environment variables to desktop build workflow
  • Removed duplicate tray icon configuration from tauri.conf.json

Key improvements:

  • Test now correctly handles split text elements in the error display
  • Desktop users can now debug errors more easily with detailed error information
  • Desktop builds now have proper authentication configuration
  • Cleaned up duplicate tray icon configuration

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • All changes are well-scoped and properly implemented. The test fix correctly addresses the split text element issue. The desktop improvements enhance debugging without affecting production behavior. Environment variable additions are necessary for desktop authentication. The tray icon removal fixes a duplicate configuration issue. No breaking changes or security concerns identified.
  • No files require special attention

Important Files Changed

Filename Overview
src/app/tests/global-error.test.tsx Fixed test to handle split text elements by checking container content instead of exact text match
src/app/global-error.tsx Added desktop error debugging features with console logging and toggle-able error details display
.github/workflows/desktop-build.yml Added required NEXT_PUBLIC environment variables for Privy authentication in desktop builds
src-tauri/tauri.conf.json Removed duplicate tray icon configuration that was causing UI issues

Sequence Diagram

sequenceDiagram
    participant App as React App
    participant GE as GlobalError Component
    participant Sentry as Sentry
    participant Console as Console
    participant UI as User Interface
    
    App->>GE: Error thrown at root level
    activate GE
    
    GE->>GE: useEffect triggered with error
    GE->>Sentry: captureException(error, context)
    Note over Sentry: Logs error with tags:<br/>error_type: 'global_error'<br/>error_boundary: 'root'
    
    GE->>Console: console.error(error details)
    Note over Console: Desktop debugging logs:<br/>- Error object<br/>- Error name<br/>- Error message<br/>- Error stack
    
    GE->>GE: Check environment & desktop mode
    Note over GE: isDesktop = '__TAURI__' in window<br/>showDetails state initialized
    
    alt Development Mode
        GE->>UI: Display error details automatically
        Note over UI: Shows .bg-muted container with:<br/>Error: {name}: {message}<br/>Stack trace<br/>Error digest (if present)
    else Desktop (Production)
        GE->>UI: Display "Show error details" button
        UI->>GE: User clicks button
        GE->>GE: setShowDetails(true)
        GE->>UI: Display error details
    else Production (Non-Desktop)
        GE->>UI: Hide error details
        Note over UI: Only shows user-friendly message
    end
    
    GE->>UI: Render error UI
    Note over UI: - Error icon<br/>- "Something went wrong"<br/>- Try again button<br/>- Homepage button<br/>- Support email link
    
    UI->>GE: User clicks "Try again"
    GE->>App: Call reset()
    Note over App: Attempts to re-render<br/>error boundary
    
    deactivate GE
Loading

root and others added 4 commits January 16, 2026 16:06
The desktop app was showing 'Something went wrong' because NEXT_PUBLIC_PRIVY_APP_ID
was not set during the build. Added required environment variables from secrets.
The tray icon was being created twice - once by the trayIcon config in tauri.conf.json
and once programmatically in lib.rs setup_tray(). This caused two Gatewayz icons
to appear in the Windows taskbar. Removed the config since the code handles it.
- Add 'Show error details' button visible only in desktop app
- Display full error name, message, and stack trace
- Console log errors for debugging
- Helps diagnose 'Something went wrong' errors when DevTools unavailable
The error message is rendered as "Error: {error.name}: {error.message}"
which splits the text across multiple elements. Updated the test to use
container.querySelector and textContent check instead of getByText for
exact text matching.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jan 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
gatewayz-frontend Error Error Jan 16, 2026 5:11pm

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@sentry

sentry Bot commented Jan 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/app/global-error.tsx 81.81% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

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.

1 participant