Skip to content

fix(tests): update GlobalError test to handle multiple text matches#804

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

fix(tests): update GlobalError test to handle multiple text matches#804
vdimarco wants to merge 4 commits into
masterfrom
fix/global-error-test-matching

Conversation

@vdimarco

@vdimarco vdimarco commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes failing test GlobalError/should display error message in development mode

Changes

  • Updated test to use getAllByText with a regex matcher instead of getByText with exact string
  • The component renders error message in format Error: <name>: <message> and the message also appears in the stack trace

Test plan

  • Test passes locally: pnpm exec jest src/app/__tests__/global-error.test.tsx

Related

🤖 Generated with Claude Code

Greptile Summary

Fixed failing test for GlobalError component by updating the test to handle multiple occurrences of the error message using getAllByText with a regex matcher. The component now displays error details in the format Error: <name>: <message> and includes the stack trace, causing the message to appear multiple times in the DOM.

Additionally enhanced the desktop app with:

  • Console logging for error debugging (error.name, error.message, error.stack)
  • "Show error details" button for desktop users to view error details in production
  • Added required environment variables to desktop build workflow (NEXT_PUBLIC_PRIVY_APP_ID, API URLs)
  • Removed duplicate tray icon configuration from Tauri config

Confidence Score: 5/5

  • This PR is safe to merge with no issues
  • All changes are well-scoped improvements. The test fix correctly addresses the failing test by accounting for multiple DOM occurrences of the error message. The desktop enhancements add useful debugging capabilities without affecting existing functionality. Environment variables are properly configured for the build workflow. No security concerns, breaking changes, or logical errors detected.
  • No files require special attention

Important Files Changed

Filename Overview
src/app/tests/global-error.test.tsx Updated test to use getAllByText with regex matcher to handle multiple occurrences of error message (in both error display and stack trace), fixing test failure
src/app/global-error.tsx Enhanced error display to show error name, message, and stack trace; added desktop-specific "Show error details" button with console logging for debugging
.github/workflows/desktop-build.yml Added required environment variables (NEXT_PUBLIC_PRIVY_APP_ID, NEXT_PUBLIC_API_BASE_URL, NEXT_PUBLIC_CHAT_HISTORY_API_URL) for desktop app build
src-tauri/tauri.conf.json Removed duplicate tray icon configuration (likely consolidated elsewhere or removed intentionally)

Sequence Diagram

sequenceDiagram
    participant Test as Test Suite
    participant Component as GlobalError Component
    participant Sentry as Sentry SDK
    participant Console as Console (Desktop)
    participant DOM as DOM
    
    Test->>Component: render(<GlobalError error={mockError} reset={mockReset} />)
    Component->>Sentry: captureException(error, context)
    Sentry-->>Component: Error logged
    
    alt Desktop App
        Component->>Console: console.error('[GlobalError] Error caught:', error)
        Component->>Console: console.error('[GlobalError] Error name:', error.name)
        Component->>Console: console.error('[GlobalError] Error message:', error.message)
        Component->>Console: console.error('[GlobalError] Error stack:', error.stack)
    end
    
    Component->>DOM: Render error UI
    Note over Component,DOM: Format: "Error: {error.name}: {error.message}"
    
    alt Development Mode OR showDetails=true
        Component->>DOM: Render error details section
        DOM->>DOM: Display error name, message
        DOM->>DOM: Display stack trace (contains message again)
    end
    
    alt Desktop App && !showDetails && Production
        Component->>DOM: Render "Show error details" button
    end
    
    Test->>DOM: getAllByText(/Test error message/i)
    DOM-->>Test: Returns array of matching elements
    Test->>Test: expect(errorMessages.length).toBeGreaterThan(0)
    Test-->>Test: ✓ Test passes
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 test was looking for exact text 'Test error message' but the component
renders it in a format that includes the error name: 'Error: Test error message'.
Additionally, the error message appears in both the error display and stack trace.

Updated test to use getAllByText with a regex matcher to properly handle this.

🤖 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:17pm

@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