Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .tmp/proof/issue-151-component-lifecycles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .tmp/proof/issue-151-home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions .tmp/proof/issue-151-verification.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
Verification for issue #151

MISE_TRUSTED_CONFIG_PATHS="$PWD" mise run install
Passed. Dependency installation completed with existing peer-dependency warnings.
No dependency manifest or lockfile changes.

MISE_TRUSTED_CONFIG_PATHS="$PWD" mise run lint
[lint] $ ./scripts/lint
Checked 2 files in packages/backend 1.15s
(node:19149) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
(Use `node --trace-warnings ...` to show where the warning was created)
Checked 3 files in plugins/permission-backend-module-default 0.05s
Checked 1 files in packages/backstage-theme-github 1.48s
(node:19149) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
(Use `node --trace-warnings ...` to show where the warning was created)
Checked 8 files in plugins/plausible 1.52s
(node:19149) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
(Use `node --trace-warnings ...` to show where the warning was created)
Checked 55 files in packages/app 2.30s
(node:19149) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
(Use `node --trace-warnings ...` to show where the warning was created)

MISE_TRUSTED_CONFIG_PATHS="$PWD" mise run test -- --runInBand --verbose
PASS app packages/app/src/components/home/HomePage.test.tsx
HomePage component lifecycles
✓ counts component lifecycles, including custom and missing values, without claiming health (184 ms)
✓ explains the data source while loading and does not show zero counts (98 ms)
✓ distinguishes an empty component catalog from unavailable data (93 ms)
✓ reports unavailable data after a catalog failure without showing empty or zero counts (111 ms)
✓ keeps loaded lifecycle counts when a later template request fails (91 ms)

Test Suites: 1 skipped, 11 passed, 11 of 12 total
Tests: 1 skipped, 76 passed, 77 total
Snapshots: 0 total
Time: 25.398 s
Ran all test suites in 4 projects.

Existing test warnings included jsdom stylesheet parsing and React/MUI warnings.

BROWSER=none MISE_TRUSTED_CONFIG_PATHS="$PWD" mise run dev
Rspack compiled successfully. Frontend / returned HTTP 200.
Backend /.backstage/health/v1/readiness returned HTTP 200.
The dev stack was stopped after verification.

Paseo browser capture was blocked: No browser automation host is connected.
The local Playwright CLI fallback succeeded using Chrome and Guest > Enter.
It was invoked through a temporary mise task named proof-browser, which wrapped
/Users/johnny/.agents/skills/playwright/scripts/playwright_cli.sh with the session
backstage-issue-151. The temporary task was removed after capture.

MISE_TRUSTED_CONFIG_PATHS="$PWD" mise run proof-browser open http://localhost:3000 --browser chrome
MISE_TRUSTED_CONFIG_PATHS="$PWD" mise run proof-browser click e18
MISE_TRUSTED_CONFIG_PATHS="$PWD" mise run proof-browser resize 1440 1200
MISE_TRUSTED_CONFIG_PATHS="$PWD" mise run proof-browser snapshot
MISE_TRUSTED_CONFIG_PATHS="$PWD" mise run proof-browser screenshot e401 --filename=.tmp/proof/issue-151-component-lifecycles.png
MISE_TRUSTED_CONFIG_PATHS="$PWD" mise run proof-browser screenshot --full-page --filename=.tmp/proof/issue-151-home.png
MISE_TRUSTED_CONFIG_PATHS="$PWD" mise run proof-browser click e425

The section capture includes its heading, explanation, all four lifecycle counts
and Browse components. The home capture shows the surrounding page at 1440x1200;
the page uses an internal scroll area, so it is a viewport rather than the entire
home-page content. The local catalog had 13 production components and zero in
the other three groups. Browse components opened the catalog with kind=component
and All Components (13). No responses were mocked for the browser captures.

Browser warnings included the existing signals WebSocket 404, React Router future
flags and React deprecations. The backend also reported missing TechDocs search
indexes. These are outside this slice.

mise run build was not run locally because this slice changes frontend UI and
component tests only. The PR Build workflow runs install, lint, test and the Docker
build without publishing an image.

git diff --check
Passed.
150 changes: 150 additions & 0 deletions packages/app/src/components/home/HomePage.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import { fireEvent, screen, within } from '@testing-library/react';
import { renderInTestApp, TestApiProvider } from '@backstage/test-utils';
import { catalogApiRef } from '@backstage/plugin-catalog-react';
import { Entity } from '@backstage/catalog-model';
import { useLocation } from 'react-router-dom';
import { HomePage } from './HomePage';

const component = (name: string, lifecycle?: string): Entity => ({
apiVersion: 'backstage.io/v1alpha1',
kind: 'Component',
metadata: { name },
spec: { type: 'service', owner: 'guest', ...(lifecycle && { lifecycle }) },
});

const LocationDisplay = () => {
const location = useLocation();
return (
<div data-testid="location">{location.pathname + location.search}</div>
);
};

describe('HomePage component lifecycles', () => {
const getEntities = jest.fn();
const renderPage = () =>
renderInTestApp(
<TestApiProvider apis={[[catalogApiRef, { getEntities }]]}>
<HomePage />
<LocationDisplay />
</TestApiProvider>,
);
const lifecycleCard = () =>
within(screen.getByRole('region', { name: 'Component lifecycles' }));
const expectExplanation = () => {
expect(
lifecycleCard().getByText(/Counts use component lifecycle metadata/),
).toHaveTextContent('They do not report live service health.');
expect(screen.queryByText('System Health')).not.toBeInTheDocument();
expect(screen.queryByText('Overall Health')).not.toBeInTheDocument();
expect(lifecycleCard().queryByText(/%/)).not.toBeInTheDocument();
};

beforeEach(() => {
getEntities.mockReset();
});

it('counts component lifecycles, including custom and missing values, without claiming health', async () => {
const components = [
component('production-one', 'production'),
component('production-two', 'production'),
component('experiment', 'experimental'),
component('old-service', 'deprecated'),
component('preview', 'preview'),
component('unspecified'),
{ ...component('no-spec'), spec: undefined },
];
getEntities.mockImplementation(({ filter }) =>
Promise.resolve({
items:
filter[0].kind === 'component' && Object.keys(filter[0]).length === 1
? components
: [],
}),
);

await renderPage();

expectExplanation();
const card = lifecycleCard();
for (const [label, count] of [
['Production', '2'],
['Experimental', '1'],
['Deprecated', '1'],
['Other or unspecified', '3'],
]) {
const term = card.getByText(label);
expect(term.tagName).toBe('DT');
expect(term.nextElementSibling).toHaveTextContent(
new RegExp(`^${count}$`),
);
}
expect(card.queryByRole('progressbar')).not.toBeInTheDocument();

fireEvent.click(card.getByRole('button', { name: 'Browse components' }));
expect(screen.getByTestId('location')).toHaveTextContent(
'/catalog?filters[kind]=component',
);
});

it('explains the data source while loading and does not show zero counts', async () => {
getEntities.mockReturnValue(new Promise(() => {}));

await renderPage();

expectExplanation();
expect(lifecycleCard().getByRole('status')).toHaveTextContent(
'Loading component lifecycles...',
);
expect(lifecycleCard().queryByRole('definition')).not.toBeInTheDocument();
});

it('distinguishes an empty component catalog from unavailable data', async () => {
getEntities.mockResolvedValue({ items: [] });

await renderPage();

expectExplanation();
expect(
lifecycleCard().getByText('No components found in the catalog.'),
).toBeInTheDocument();
expect(lifecycleCard().queryByRole('alert')).not.toBeInTheDocument();
expect(lifecycleCard().queryByRole('definition')).not.toBeInTheDocument();
});

it('reports unavailable data after a catalog failure without showing empty or zero counts', async () => {
getEntities.mockRejectedValue(new Error('Catalog unavailable'));

await renderPage();

expectExplanation();
expect(lifecycleCard().getByRole('alert')).toHaveTextContent(
'Component lifecycle data is unavailable. Try reloading the page.',
);
expect(
lifecycleCard().queryByText('No components found in the catalog.'),
).not.toBeInTheDocument();
expect(lifecycleCard().queryByRole('definition')).not.toBeInTheDocument();
});

it('keeps loaded lifecycle counts when a later template request fails', async () => {
getEntities.mockImplementation(({ filter }) => {
if (filter[0].kind === 'template') {
return Promise.reject(new Error('Templates unavailable'));
}
return Promise.resolve({
items:
filter[0].kind === 'component' && Object.keys(filter[0]).length === 1
? [component('production-service', 'production')]
: [],
});
});

await renderPage();

expectExplanation();
expect(
lifecycleCard().getByText('Production').nextElementSibling,
).toHaveTextContent(/^1$/);
expect(lifecycleCard().queryByRole('alert')).not.toBeInTheDocument();
});
});
Loading
Loading