Skip to content
This repository was archived by the owner on Jun 26, 2026. It is now read-only.

Commit 197fd4a

Browse files
twoGiantsclaude
andcommitted
feat: FunctionsListPage renders empty state
Replace template boilerplate with the actual view that renders FunctionsEmptyState when no functions exist. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent cfecfcb commit 197fd4a

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { render, screen } from '@testing-library/react';
2+
import { MemoryRouter } from 'react-router-dom';
3+
import FunctionsListPage from './FunctionsListPage';
4+
5+
jest.mock('react-i18next', () => ({
6+
useTranslation: () => ({ t: (key: string) => key }),
7+
}));
8+
9+
jest.mock('@openshift-console/dynamic-plugin-sdk', () => ({
10+
DocumentTitle: ({ children }: { children: string }) => children,
11+
ListPageHeader: ({ title }: { title: string }) => title,
12+
}));
13+
14+
afterEach(() => {
15+
jest.restoreAllMocks();
16+
});
17+
18+
describe('FunctionsListPage', () => {
19+
it('renders the empty state when no functions exist', () => {
20+
render(
21+
<MemoryRouter>
22+
<FunctionsListPage />
23+
</MemoryRouter>,
24+
);
25+
26+
expect(
27+
screen.getByRole('heading', { name: 'No functions found' }),
28+
).toBeInTheDocument();
29+
});
30+
31+
it('renders a "Create function" link to /functions/create', () => {
32+
render(
33+
<MemoryRouter>
34+
<FunctionsListPage />
35+
</MemoryRouter>,
36+
);
37+
38+
expect(
39+
screen.getByRole('link', { name: 'Create function' }),
40+
).toHaveAttribute('href', '/functions/create');
41+
});
42+
});

src/views/FunctionsListPage.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { DocumentTitle, ListPageHeader } from '@openshift-console/dynamic-plugin-sdk';
2+
import { PageSection } from '@patternfly/react-core';
3+
import { useTranslation } from 'react-i18next';
4+
import { FunctionsEmptyState } from '../components/EmptyState';
5+
6+
export default function FunctionsListPage() {
7+
const { t } = useTranslation('plugin__console-functions-plugin');
8+
9+
return (
10+
<>
11+
<DocumentTitle>{t('Functions')}</DocumentTitle>
12+
<ListPageHeader title={t('Functions')} />
13+
<PageSection>
14+
<FunctionsEmptyState />
15+
</PageSection>
16+
</>
17+
);
18+
}

0 commit comments

Comments
 (0)