Skip to content

Commit

Permalink
Revert "fix(opentrons-ai-client): Navigate to landing page when refre…
Browse files Browse the repository at this point in the history
…shing chat page" (#16817)

Reverts #16810
  • Loading branch information
connected-znaim authored Nov 14, 2024
1 parent e6524c9 commit e569ab4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
17 changes: 1 addition & 16 deletions opentrons-ai-client/src/pages/Chat/__tests__/Chat.test.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
import { screen } from '@testing-library/react'
import { describe, it, vi, beforeEach, expect } from 'vitest'
import { describe, it, vi, beforeEach } from 'vitest'
import { renderWithProviders } from '../../../__testing-utils__'
import { i18n } from '../../../i18n'
import { PromptGuide } from '../../../molecules/PromptGuide'
import { ChatFooter } from '../../../molecules/ChatFooter'
import { Chat } from '../index'
import type { NavigateFunction } from 'react-router-dom'

vi.mock('../../../molecules/PromptGuide')
vi.mock('../../../molecules/ChatFooter')
// Note (kk:05/20/2024) to avoid TypeError: scrollRef.current.scrollIntoView is not a function
window.HTMLElement.prototype.scrollIntoView = vi.fn()
const mockNavigate = vi.fn()

vi.mock('react-router-dom', async importOriginal => {
const reactRouterDom = await importOriginal<NavigateFunction>()
return {
...reactRouterDom,
useNavigate: () => mockNavigate,
}
})

const render = (): ReturnType<typeof renderWithProviders> => {
return renderWithProviders(<Chat />, {
Expand All @@ -38,11 +28,6 @@ describe('Chat', () => {
screen.getByText('mock ChatFooter')
})

it('should navigate to home if chatData is empty', () => {
render()
expect(mockNavigate).toHaveBeenCalledWith('/')
})

it.skip('should not show the feedback modal when loading the page', () => {
render()
screen.getByText('Send feedback to Opentrons')
Expand Down
8 changes: 0 additions & 8 deletions opentrons-ai-client/src/pages/Chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { ChatDisplay } from '../../molecules/ChatDisplay'
import { ChatFooter } from '../../molecules/ChatFooter'
import styled from 'styled-components'
import { FeedbackModal } from '../../molecules/FeedbackModal'
import { useNavigate } from 'react-router-dom'

export interface InputType {
userPrompt: string
Expand All @@ -29,13 +28,6 @@ export function Chat(): JSX.Element | null {
const scrollRef = useRef<HTMLSpanElement | null>(null)
const [showFeedbackModal] = useAtom(feedbackModalAtom)
const [scrollToBottom] = useAtom(scrollToBottomAtom)
const navigate = useNavigate()

useEffect(() => {
if (chatData.length === 0) {
navigate('/')
}
}, [])

useEffect(() => {
if (scrollRef.current != null)
Expand Down

0 comments on commit e569ab4

Please sign in to comment.