-
Notifications
You must be signed in to change notification settings - Fork 289
Symphony: Forced Parallel Execution: bypass message queue with modifier shortcut (#702) #711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
873d623
[Symphony] Start contribution for #702
chr1syy 2688bbf
MAESTRO: Add forced parallel execution settings, shortcut, and modal …
chr1syy cc168bd
MAESTRO: Add ForcedParallelWarningModal one-time acknowledgment dialog
chr1syy eb7d462
MAESTRO: Add Forced Parallel Execution settings UI card in GeneralTab
chr1syy d214636
MAESTRO: Add forced parallel keyboard handling and queue bypass logic
chr1syy 18adf21
MAESTRO: Add tests for forced parallel execution feature
chr1syy 6299d4a
fix: address CodeRabbit and Greptile review findings for forced paral…
chr1syy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
215 changes: 215 additions & 0 deletions
215
src/__tests__/renderer/components/ForcedParallelWarningModal.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,215 @@ | ||
| /** | ||
| * Tests for ForcedParallelWarningModal component | ||
| * | ||
| * Tests the one-time acknowledgment modal for forced parallel execution: | ||
| * - Rendering when open/closed | ||
| * - Confirm and Cancel button handlers | ||
| * - Layer stack integration | ||
| * - Warning content display | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; | ||
| import { render, screen, fireEvent, waitFor } from '@testing-library/react'; | ||
| import { ForcedParallelWarningModal } from '../../../renderer/components/ForcedParallelWarningModal'; | ||
| import { LayerStackProvider } from '../../../renderer/contexts/LayerStackContext'; | ||
| import type { Theme } from '../../../renderer/types'; | ||
|
|
||
| // Mock lucide-react | ||
| vi.mock('lucide-react', () => ({ | ||
| X: () => <svg data-testid="x-icon" />, | ||
| AlertTriangle: () => <svg data-testid="alert-triangle-icon" />, | ||
| })); | ||
|
|
||
| const testTheme: Theme = { | ||
| id: 'test-theme', | ||
| name: 'Test Theme', | ||
| mode: 'dark', | ||
| colors: { | ||
| bgMain: '#1e1e1e', | ||
| bgSidebar: '#252526', | ||
| bgActivity: '#333333', | ||
| textMain: '#d4d4d4', | ||
| textDim: '#808080', | ||
| accent: '#007acc', | ||
| border: '#404040', | ||
| error: '#f14c4c', | ||
| warning: '#cca700', | ||
| success: '#89d185', | ||
| info: '#3794ff', | ||
| textInverse: '#000000', | ||
| }, | ||
| }; | ||
|
|
||
| const renderWithLayerStack = (ui: React.ReactElement) => { | ||
| return render(<LayerStackProvider>{ui}</LayerStackProvider>); | ||
| }; | ||
|
|
||
| describe('ForcedParallelWarningModal', () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| vi.restoreAllMocks(); | ||
| }); | ||
|
|
||
| describe('rendering', () => { | ||
| it('renders when isOpen is true', () => { | ||
| renderWithLayerStack( | ||
| <ForcedParallelWarningModal | ||
| isOpen={true} | ||
| onConfirm={vi.fn()} | ||
| onCancel={vi.fn()} | ||
| theme={testTheme} | ||
| /> | ||
| ); | ||
|
|
||
| expect(screen.getByRole('dialog')).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByRole('heading', { name: 'Forced Parallel Execution' }) | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('does not render when isOpen is false', () => { | ||
| renderWithLayerStack( | ||
| <ForcedParallelWarningModal | ||
| isOpen={false} | ||
| onConfirm={vi.fn()} | ||
| onCancel={vi.fn()} | ||
| theme={testTheme} | ||
| /> | ||
| ); | ||
|
|
||
| expect(screen.queryByRole('dialog')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('displays warning content', () => { | ||
| renderWithLayerStack( | ||
| <ForcedParallelWarningModal | ||
| isOpen={true} | ||
| onConfirm={vi.fn()} | ||
| onCancel={vi.fn()} | ||
| theme={testTheme} | ||
| /> | ||
| ); | ||
|
|
||
| expect( | ||
| screen.getByText(/sends messages immediately, even when the agent is already working/i) | ||
| ).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByText(/intended for advanced users who understand the risks/i) | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('displays alert triangle icon', () => { | ||
| renderWithLayerStack( | ||
| <ForcedParallelWarningModal | ||
| isOpen={true} | ||
| onConfirm={vi.fn()} | ||
| onCancel={vi.fn()} | ||
| theme={testTheme} | ||
| /> | ||
| ); | ||
|
|
||
| expect(screen.getByTestId('alert-triangle-icon')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('displays confirm and cancel buttons', () => { | ||
| renderWithLayerStack( | ||
| <ForcedParallelWarningModal | ||
| isOpen={true} | ||
| onConfirm={vi.fn()} | ||
| onCancel={vi.fn()} | ||
| theme={testTheme} | ||
| /> | ||
| ); | ||
|
|
||
| expect(screen.getByRole('button', { name: 'I understand, enable it' })).toBeInTheDocument(); | ||
| expect(screen.getByRole('button', { name: 'Cancel' })).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('button handlers', () => { | ||
| it('calls onConfirm when confirm button is clicked', () => { | ||
| const onConfirm = vi.fn(); | ||
| renderWithLayerStack( | ||
| <ForcedParallelWarningModal | ||
| isOpen={true} | ||
| onConfirm={onConfirm} | ||
| onCancel={vi.fn()} | ||
| theme={testTheme} | ||
| /> | ||
| ); | ||
|
|
||
| fireEvent.click(screen.getByRole('button', { name: 'I understand, enable it' })); | ||
| expect(onConfirm).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| it('calls onCancel when cancel button is clicked', () => { | ||
| const onCancel = vi.fn(); | ||
| renderWithLayerStack( | ||
| <ForcedParallelWarningModal | ||
| isOpen={true} | ||
| onConfirm={vi.fn()} | ||
| onCancel={onCancel} | ||
| theme={testTheme} | ||
| /> | ||
| ); | ||
|
|
||
| fireEvent.click(screen.getByRole('button', { name: 'Cancel' })); | ||
| expect(onCancel).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| it('calls onCancel when X close button is clicked', () => { | ||
| const onCancel = vi.fn(); | ||
| renderWithLayerStack( | ||
| <ForcedParallelWarningModal | ||
| isOpen={true} | ||
| onConfirm={vi.fn()} | ||
| onCancel={onCancel} | ||
| theme={testTheme} | ||
| /> | ||
| ); | ||
|
|
||
| const closeButton = screen.getByTestId('x-icon').closest('button'); | ||
| fireEvent.click(closeButton!); | ||
| expect(onCancel).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); | ||
|
|
||
| describe('focus management', () => { | ||
| it('focuses confirm button on mount', async () => { | ||
| renderWithLayerStack( | ||
| <ForcedParallelWarningModal | ||
| isOpen={true} | ||
| onConfirm={vi.fn()} | ||
| onCancel={vi.fn()} | ||
| theme={testTheme} | ||
| /> | ||
| ); | ||
|
|
||
| await waitFor(() => { | ||
| expect(document.activeElement).toBe( | ||
| screen.getByRole('button', { name: 'I understand, enable it' }) | ||
| ); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('layer stack integration', () => { | ||
| it('registers and unregisters without errors', () => { | ||
| const { unmount } = renderWithLayerStack( | ||
| <ForcedParallelWarningModal | ||
| isOpen={true} | ||
| onConfirm={vi.fn()} | ||
| onCancel={vi.fn()} | ||
| theme={testTheme} | ||
| /> | ||
| ); | ||
|
|
||
| expect(screen.getByRole('dialog')).toBeInTheDocument(); | ||
| expect(() => unmount()).not.toThrow(); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.