diff --git a/web/app/components/evaluation/components/section-header.tsx b/web/app/components/evaluation/components/section-header.tsx
index 37073265cd..b2bb630ebe 100644
--- a/web/app/components/evaluation/components/section-header.tsx
+++ b/web/app/components/evaluation/components/section-header.tsx
@@ -31,7 +31,7 @@ const SectionHeader = ({
return (
-
{title}
+
{title}
{description &&
{description}
}
{action}
@@ -58,7 +58,7 @@ export const InlineSectionHeader = ({
className="flex h-4 w-4 items-center justify-center text-text-quaternary transition-colors hover:text-text-tertiary"
aria-label={title}
>
-
+
)}
/>
diff --git a/web/app/components/evaluation/index.tsx b/web/app/components/evaluation/index.tsx
index 6c69ff9f5f..c7ebca62f0 100644
--- a/web/app/components/evaluation/index.tsx
+++ b/web/app/components/evaluation/index.tsx
@@ -27,7 +27,7 @@ const Evaluation = ({
return (
-
+
{
@@ -33,6 +34,10 @@ vi.mock('@/next/navigation', () => ({
}),
}))
+vi.mock('@/service/use-snippets.mock', () => ({
+ getSnippetDetailMock: (snippetId: string) => mockGetSnippetDetailMock(snippetId),
+}))
+
vi.mock('@/hooks/use-breakpoints', () => ({
default: () => 'desktop',
MediaType: { mobile: 'mobile', desktop: 'desktop' },
@@ -69,38 +74,49 @@ vi.mock('@/app/components/evaluation', () => ({
default: ({ resourceId }: { resourceId: string }) => {resourceId}
,
}))
-const mockSnippetApiDetail: Snippet = {
- id: 'snippet-1',
- name: 'Tone Rewriter',
- description: 'A static snippet mock.',
- type: 'node',
- is_published: false,
- version: 'draft',
- use_count: 19,
- icon_info: {
- icon_type: 'emoji',
+const mockSnippetDetail: SnippetDetailPayload = {
+ snippet: {
+ id: 'snippet-1',
+ name: 'Tone Rewriter',
+ description: 'A static snippet mock.',
+ author: 'Evan',
+ updatedAt: '2024-03-24',
+ usage: '19',
icon: '🪄',
- icon_background: '#E0EAFF',
+ iconBackground: '#E0EAFF',
+ },
+ graph: {
+ nodes: [],
+ edges: [],
+ viewport: {
+ x: 0,
+ y: 0,
+ zoom: 1,
+ },
+ },
+ inputFields: [],
+ uiMeta: {
+ inputFieldCount: 0,
+ checklistCount: 0,
+ autoSavedAt: '2024-03-24 12:00',
},
- input_fields: [],
- created_at: 1_711_609_600,
- updated_at: 1_711_616_800,
- author: 'Evan',
}
describe('SnippetEvaluationPage', () => {
beforeEach(() => {
vi.clearAllMocks()
mockUseSnippetApiDetail.mockReturnValue({
- data: mockSnippetApiDetail,
+ data: undefined,
isLoading: false,
})
+ mockGetSnippetDetailMock.mockReturnValue(mockSnippetDetail)
})
- it('should fetch evaluation route data independently from snippet init', () => {
+ it('should render evaluation with mock snippet detail data', () => {
render()
- expect(mockUseSnippetApiDetail).toHaveBeenCalledWith('snippet-1')
+ expect(mockGetSnippetDetailMock).toHaveBeenCalledWith('snippet-1')
+ expect(mockUseSnippetApiDetail).not.toHaveBeenCalled()
expect(screen.getByTestId('app-sidebar')).toBeInTheDocument()
expect(screen.getByTestId('evaluation')).toHaveTextContent('snippet-1')
})
diff --git a/web/app/components/snippets/snippet-evaluation-page.tsx b/web/app/components/snippets/snippet-evaluation-page.tsx
index e52c857b3d..736f36fc1e 100644
--- a/web/app/components/snippets/snippet-evaluation-page.tsx
+++ b/web/app/components/snippets/snippet-evaluation-page.tsx
@@ -1,9 +1,7 @@
'use client'
import { useMemo } from 'react'
-import Loading from '@/app/components/base/loading'
import Evaluation from '@/app/components/evaluation'
-import { buildSnippetDetailPayload, useSnippetApiDetail } from '@/service/use-snippets'
import { getSnippetDetailMock } from '@/service/use-snippets.mock'
import SnippetLayout from './components/snippet-layout'
@@ -12,25 +10,11 @@ type SnippetEvaluationPageProps = {
}
const SnippetEvaluationPage = ({ snippetId }: SnippetEvaluationPageProps) => {
- const snippetApiDetail = useSnippetApiDetail(snippetId)
const mockSnippet = useMemo(() => getSnippetDetailMock(snippetId)?.snippet, [snippetId])
- const snippet = useMemo(() => {
- if (snippetApiDetail.data)
- return buildSnippetDetailPayload(snippetApiDetail.data).snippet
+ const snippet = mockSnippet
- if (!snippetApiDetail.isLoading)
- return mockSnippet
-
- return undefined
- }, [mockSnippet, snippetApiDetail.data, snippetApiDetail.isLoading])
-
- if (!snippet || snippetApiDetail.isLoading) {
- return (
-
-
-
- )
- }
+ if (!snippet)
+ return null
return (