Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 0 additions & 8 deletions eslint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1182,14 +1182,6 @@
"count": 2
}
},
"web/app/components/base/features/new-feature-panel/conversation-opener/modal.tsx": {
"no-restricted-imports": {
"count": 1
},
"react/set-state-in-effect": {
"count": 1
}
},
"web/app/components/base/features/new-feature-panel/feature-bar.tsx": {
"no-restricted-imports": {
"count": 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe('OpeningSettingModal', () => {
expect(onCancel).toHaveBeenCalledTimes(1)
})

it('should not call onCancel when close icon receives non-action key', async () => {
it('should call onCancel when Escape is pressed on the dialog close control', async () => {
const onCancel = vi.fn()
await render(
<OpeningSettingModal
Expand All @@ -200,7 +200,7 @@ describe('OpeningSettingModal', () => {
closeButton.focus()
fireEvent.keyDown(closeButton, { key: 'Escape' })

expect(onCancel).not.toHaveBeenCalled()
expect(onCancel).toHaveBeenCalledTimes(1)
})

it('should call onSave with updated data when save is clicked', async () => {
Expand Down Expand Up @@ -257,6 +257,26 @@ describe('OpeningSettingModal', () => {
expect(allInputs.length).toBeGreaterThanOrEqual(1)
})

it('should focus a new suggested question without destructive styling', async () => {
await render(
<OpeningSettingModal
data={defaultData}
onSave={vi.fn()}
onCancel={vi.fn()}
/>,
)

await userEvent.click(screen.getByText(/variableConfig\.addOption/))

const newInput = screen.getAllByPlaceholderText('appDebug.openingStatement.openingQuestionPlaceholder')
.find(input => (input as HTMLInputElement).value === '') as HTMLInputElement
const questionRow = newInput.parentElement

expect(newInput).toHaveFocus()
expect(questionRow).not.toHaveClass('border-components-input-border-destructive')
expect(questionRow).toHaveClass('border-components-input-border-active')
})

it('should delete a suggested question via save verification', async () => {
const onSave = vi.fn()
await render(
Expand Down Expand Up @@ -334,7 +354,39 @@ describe('OpeningSettingModal', () => {
)

// Count is displayed as "2/10" across child elements
expect(screen.getByText(/openingStatement\.openingQuestion/)).toBeInTheDocument()
expect(screen.getByText('appDebug.openingStatement.openingQuestion')).toBeInTheDocument()
})

it('should render separate opener and question sections', async () => {
await render(
<OpeningSettingModal
data={defaultData}
onSave={vi.fn()}
onCancel={vi.fn()}
/>,
)

expect(screen.getByTestId('opener-input-section')).toBeInTheDocument()
expect(screen.getByTestId('opener-questions-section')).toBeInTheDocument()
expect(screen.getByText(/openingStatement\.editorTitle/)).toBeInTheDocument()
expect(screen.getByTestId('opening-questions-tooltip')).toBeInTheDocument()
expect(screen.queryByText(/openingStatement\.openingQuestionDescription/)).not.toBeInTheDocument()
})

it('should show the opening questions description in a tooltip', async () => {
await render(
<OpeningSettingModal
data={defaultData}
onSave={vi.fn()}
onCancel={vi.fn()}
/>,
)

act(() => {
fireEvent.mouseEnter(screen.getByTestId('opening-questions-tooltip'))
})

expect(screen.getByText(/openingStatement\.openingQuestionDescription/)).toBeInTheDocument()
})

it('should call onAutoAddPromptVariable when confirm add is clicked', async () => {
Expand Down Expand Up @@ -540,7 +592,9 @@ describe('OpeningSettingModal', () => {

const editor = getPromptEditor()
expect(editor.textContent?.trim()).toBe('')
expect(screen.getByText('appDebug.openingStatement.placeholder')).toBeInTheDocument()
const openerSection = screen.getByTestId('opener-input-section')
expect(openerSection.textContent).toContain('appDebug.openingStatement.placeholderLine1')
expect(openerSection.textContent).toContain('appDebug.openingStatement.placeholderLine2')
})

it('should render with empty suggested questions when field is missing', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const ConversationOpener = ({
<>
{!isHovering && (
<div className="line-clamp-2 min-h-8 system-xs-regular text-text-tertiary">
{opening.opening_statement || t('openingStatement.placeholder', { ns: 'appDebug' })}
{opening.opening_statement || t('openingStatement.placeholderLine1', { ns: 'appDebug' })}
</div>
)}
{isHovering && (
Expand Down
Loading
Loading