feat: scaffold starter template with TypeScript, CRD list view, CI, ArtifactHub
Adds full plugin starter template including: - package.json with @kinvolk/headlamp-plugin devDependency and standard scripts - tsconfig.json extending headlamp plugin config - vitest.config.mts + vitest.setup.ts (jsdom, NODE_ENV=test, localStorage shim) - src/index.tsx: registers sidebar entry and route for ResourceListPage - src/components/ResourceListPage.tsx: placeholder CRD list view with TODO guide - src/components/ResourceListPage.test.tsx: example tests using vi.mock pattern - .github/workflows/ci.yaml: delegates to shared plugin-ci.yaml - .github/workflows/release.yaml: delegates to shared plugin-release.yaml - artifacthub-pkg.yml + artifacthub-repo.yml: ArtifactHub metadata with TODO markers - renovate.json: Mend Renovate config for weekly dependency updates - README.md: complete getting-started guide - CONTRIBUTING.md: local dev, code style, testing, PR process - LICENSE: Apache-2.0 Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import ResourceListPage from './ResourceListPage';
|
||||
|
||||
vi.mock('@kinvolk/headlamp-plugin/lib/CommonComponents', () => ({
|
||||
Loader: ({ title }: { title: string }) => <div data-testid="loader">{title}</div>,
|
||||
SectionBox: ({ title, children }: { title: React.ReactNode; children?: React.ReactNode }) => (
|
||||
<section>
|
||||
{title}
|
||||
{children}
|
||||
</section>
|
||||
),
|
||||
SectionHeader: ({ title }: { title: string }) => <h1>{title}</h1>,
|
||||
NameValueTable: ({
|
||||
rows,
|
||||
}: {
|
||||
rows: Array<{ name: React.ReactNode; value: React.ReactNode }>;
|
||||
}) => (
|
||||
<dl>
|
||||
{rows.map((r, i) => (
|
||||
<div key={i}>
|
||||
<dt>{r.name}</dt>
|
||||
<dd>{r.value}</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
),
|
||||
StatusLabel: ({ status, children }: { status: string; children?: React.ReactNode }) => (
|
||||
<span data-status={status}>{children}</span>
|
||||
),
|
||||
}));
|
||||
|
||||
describe('ResourceListPage', () => {
|
||||
it('renders the "My Plugin" heading', () => {
|
||||
render(<ResourceListPage />);
|
||||
expect(screen.getByText('My Plugin')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows the example resource group row', () => {
|
||||
render(<ResourceListPage />);
|
||||
expect(screen.getByText('Resource Group')).toBeInTheDocument();
|
||||
expect(screen.getByText('your.group.io/v1')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows the example Kind row', () => {
|
||||
render(<ResourceListPage />);
|
||||
expect(screen.getByText('Kind')).toBeInTheDocument();
|
||||
expect(screen.getByText('YourCustomResource')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user