test(content-hub): ✅ Add/update tests for Content Hub viewmodels and views (useContentDetailViewModel, useContentHubViewModel, ContentFilters, ContentTable)
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
34ff7c9926
commit
d5c1d7e224
6 changed files with 12 additions and 7 deletions
|
|
@ -7,4 +7,9 @@ export default createLibraryConfig({
|
|||
'models/index': 'src/models/index.ts',
|
||||
'enums/index': 'src/enums/index.ts',
|
||||
},
|
||||
dts: {
|
||||
compilerOptions: {
|
||||
skipLibCheck: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ export function AttributeDefinitionModal({ attribute, onClose }: AttributeDefini
|
|||
dataTypeSelectOptions={viewModel.dataTypeSelectOptions}
|
||||
metaCategorySelectOptions={viewModel.metaCategorySelectOptions}
|
||||
prioritySelectOptions={viewModel.prioritySelectOptions}
|
||||
layoutHintSelectOptions={viewModel.layoutHintSelectOptions}
|
||||
isPending={viewModel.isPending}
|
||||
mutationError={viewModel.mutationError}
|
||||
onSubmit={viewModel.handleSubmit}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ function createMockItem(overrides?: Partial<UnifiedContentItem>): UnifiedContent
|
|||
function createWrapper(queryClient: QueryClient) {
|
||||
return function Wrapper({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
// @ts-expect-error — JSX in .ts file; acceptable in test context
|
||||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ import { useContentHubViewModel } from './useContentHubViewModel'
|
|||
function createWrapper(queryClient: QueryClient) {
|
||||
return function Wrapper({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
// @ts-expect-error — JSX in .ts file; acceptable in test context
|
||||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,9 @@
|
|||
* and that the search input debounces before firing.
|
||||
*/
|
||||
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { render, screen, fireEvent, act, waitFor } from '@testing-library/react'
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
||||
import type { Mock } from 'vitest'
|
||||
import { render, screen, fireEvent, act } from '@testing-library/react'
|
||||
import { ContentFilters } from './ContentFilters'
|
||||
import type { ContentHubFilters } from '../model/types'
|
||||
|
||||
|
|
@ -78,11 +79,11 @@ function baseFilters(overrides?: Partial<ContentHubFilters>): ContentHubFilters
|
|||
// ─── Tests ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
describe('ContentFilters', () => {
|
||||
let onFilterChange: ReturnType<typeof vi.fn>
|
||||
let onFilterChange: Mock<(updates: Partial<ContentHubFilters>) => void>
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
onFilterChange = vi.fn()
|
||||
onFilterChange = vi.fn<(updates: Partial<ContentHubFilters>) => void>()
|
||||
vi.useFakeTimers()
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ vi.mock('@lilith/ui-data', () => ({
|
|||
<tr key={keyExtractor(row)} data-testid={`row-${row.id}`}>
|
||||
{columns.map((col) => (
|
||||
<td key={col.key} data-testid={`cell-${row.id}-${col.key}`}>
|
||||
{col.render ? col.render(row) : String((row as Record<string, unknown>)[col.key] ?? '')}
|
||||
{col.render ? col.render(row) : String((row as unknown as Record<string, unknown>)[col.key] ?? '')}
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue