Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions packages/bruno-app/src/components/AIAssist/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@ import { Provider } from 'react-redux';
import { configureStore } from '@reduxjs/toolkit';
import { ThemeProvider } from 'styled-components';
import { aiGenerateScript, stopAiGeneration } from 'utils/ai';
import { getPlatformModifierKey } from 'utils/common/platform';
import AIAssist from './index';

jest.mock('utils/ai', () => ({
aiGenerateScript: jest.fn(),
stopAiGeneration: jest.fn()
}));

jest.mock('utils/common/platform', () => ({
...jest.requireActual('utils/common/platform'),
getPlatformModifierKey: jest.fn()
}));

const theme = {
bg: '#1e1e1e',
text: '#ffffff',
Expand Down Expand Up @@ -69,7 +63,6 @@ describe('AIAssist', () => {
beforeEach(() => {
jest.clearAllMocks();
aiGenerateScript.mockResolvedValue({ content: 'test("generated", () => {});' });
getPlatformModifierKey.mockReturnValue('Ctrl');
});

describe('visibility', () => {
Expand Down Expand Up @@ -166,15 +159,11 @@ describe('AIAssist', () => {
expect(screen.queryByRole('button', { name: 'Status 200' })).not.toBeInTheDocument();
});

it.each([
['macOS', '⌘'],
['non-macOS', 'Ctrl']
])('shows the %s modifier in the generate shortcut hint', (_platform, modifier) => {
getPlatformModifierKey.mockReturnValue(modifier);
it('shows the generate shortcut hint', () => {
renderAIAssist();
openPopup();

expect(screen.getByText(`${modifier} + Enter to generate`)).toBeInTheDocument();
expect(screen.getByText('Enter to generate · Shift+Enter for newline')).toBeInTheDocument();
});

it('keeps Generate disabled until the prompt has text', () => {
Expand Down
Loading