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
59 changes: 59 additions & 0 deletions .tmp/proof/issue-149-verification.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
$ MISE_TRUSTED_CONFIG_PATHS="$PWD" mise run install
➤ YN0000: · Done with warnings in 28m 41s
Finished in 325.23s
exit 0; no lockfile changes

$ MISE_TRUSTED_CONFIG_PATHS="$PWD" mise run lint
[lint] $ ./scripts/lint
Checked 2 files in packages/backend 3.98s
(node:70265) 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.16s
Checked 1 files in packages/backstage-theme-github 5.10s
(node:70265) 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 5.51s
(node:70265) 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 54 files in packages/app 7.88s
(node:70265) 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)
exit 0

$ MISE_TRUSTED_CONFIG_PATHS="$PWD" mise run test -- --runInBand --verbose
PASS app packages/app/src/components/pulse-check/PulseCheckPage.test.tsx (11.484 s)
PulseCheckPage
✓ identifies simulated health and fixture metrics on the populated dashboard (959 ms)
✓ keeps the sample-data notice visible while services load (211 ms)
✓ keeps the sample-data notice visible when the catalog fails (740 ms)
✓ retries a failed catalog load and restores the dashboard after a pending request (1073 ms)
✓ offers another retry after a second failure and handles an empty recovery (988 ms)
✓ offers retry when the catalog rejects without an Error object (329 ms)
✓ identifies example metrics even when the catalog has no services (425 ms)

Test Suites: 1 skipped, 10 passed, 10 of 11 total
Tests: 1 skipped, 71 passed, 72 total
Snapshots: 0 total
Time: 141.774 s
Ran all test suites in 4 projects.
exit 0

The test excerpt above contains the complete PulseCheckPage result block and overall totals. Existing jsdom stylesheet and React/MUI warnings are omitted.

$ BROWSER=none MISE_TRUSTED_CONFIG_PATHS="$PWD" mise run dev
[0] Rspack compiled successfully
[1] 2026-11-16T09:13:39.229Z backstage info Plugin initialization complete, newly initialized: 'notifications', 'scaffolder', 'catalog' type="initialization"
[1] 2026-11-16T09:13:40.323Z signals warn Event subscribe request failed with status 404, events backend not found. Will only receive events that were sent locally on this process.
[1] yarn start-backend exited with code 0
[0] yarn start exited with code 0
The stack was stopped with Ctrl+C after verification.

$ curl --silent --output /dev/null --write-out "GET /pulse-check -> HTTP %{http_code}\n" http://localhost:3000/pulse-check
GET /pulse-check -> HTTP 200

Screenshot method (a) was blocked. Attempting to open http://localhost:3000/pulse-check with the browser tool returned "The browser access host is unavailable". No screenshot was captured and browser rendering remains unverified. Method (b) succeeded with the regression-test output above.

$ git diff --check
exit 0

mise run build was not run locally. This slice changes frontend controls and component tests only; backend and packaging are unchanged. The PR Build workflow runs all four mise gates including the Docker image build.
121 changes: 107 additions & 14 deletions packages/app/src/components/pulse-check/PulseCheckPage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { screen } from '@testing-library/react';
import { act, fireEvent, screen, waitFor } from '@testing-library/react';
import { renderInTestApp, TestApiProvider } from '@backstage/test-utils';
import { catalogApiRef } from '@backstage/plugin-catalog-react';
import { PulseCheckPage } from './PulseCheckPage';

describe('PulseCheckPage', () => {
const getEntities = jest.fn();
const demoService = {
apiVersion: 'backstage.io/v1alpha1',
kind: 'Component',
metadata: { name: 'demo-service' },
spec: { type: 'service', lifecycle: 'experimental', owner: 'guest' },
};

const renderPage = () =>
renderInTestApp(
Expand All @@ -14,9 +20,11 @@ describe('PulseCheckPage', () => {
);

const expectSampleDataNotice = () => {
expect(screen.getByRole('alert')).toHaveTextContent(
'Sample data only. Service names come from the catalog. Health and uptime are simulated; incidents and deployment metrics are examples. This page does not report live service status.',
);
expect(
screen.getByText(
'Sample data only. Service names come from the catalog. Health and uptime are simulated; incidents and deployment metrics are examples. This page does not report live service status.',
),
).toBeVisible();
expect(
screen.getByText('Explore a service health dashboard with sample data'),
).toBeInTheDocument();
Expand All @@ -28,14 +36,7 @@ describe('PulseCheckPage', () => {

it('identifies simulated health and fixture metrics on the populated dashboard', async () => {
getEntities.mockResolvedValue({
items: [
{
apiVersion: 'backstage.io/v1alpha1',
kind: 'Component',
metadata: { name: 'demo-service' },
spec: { type: 'service', lifecycle: 'experimental', owner: 'guest' },
},
],
items: [demoService],
});

await renderPage();
Expand All @@ -53,7 +54,9 @@ describe('PulseCheckPage', () => {
await renderPage();

expectSampleDataNotice();
expect(screen.getByRole('progressbar')).toBeInTheDocument();
expect(
screen.getByRole('progressbar', { name: 'Loading services' }),
).toBeInTheDocument();
});

it('keeps the sample-data notice visible when the catalog fails', async () => {
Expand All @@ -63,8 +66,98 @@ describe('PulseCheckPage', () => {

expectSampleDataNotice();
expect(
screen.getByText('Error loading services: Catalog unavailable'),
screen.getByRole('alert', { name: 'Could not load services' }),
).toHaveTextContent('Catalog unavailable');
expect(screen.getByRole('button', { name: 'Retry' })).toBeInTheDocument();
expect(screen.queryByText('Total Deployments')).not.toBeInTheDocument();
});

it('retries a failed catalog load and restores the dashboard after a pending request', async () => {
let resolveRetry: () => void;
const retry = new Promise<{ items: (typeof demoService)[] }>(resolve => {
resolveRetry = () => resolve({ items: [demoService] });
});
getEntities
.mockRejectedValueOnce(new Error('Catalog unavailable'))
.mockReturnValueOnce(retry);

await renderPage();
fireEvent.click(screen.getByRole('button', { name: 'Retry' }));

expectSampleDataNotice();
expect(
screen.getByRole('progressbar', { name: 'Loading services' }),
).toBeInTheDocument();
expect(
screen.queryByRole('alert', { name: 'Could not load services' }),
).not.toBeInTheDocument();
expect(
screen.queryByRole('button', { name: 'Retry' }),
).not.toBeInTheDocument();
expect(screen.queryByText('Total Deployments')).not.toBeInTheDocument();
expect(getEntities).toHaveBeenCalledTimes(2);
expect(getEntities).toHaveBeenLastCalledWith({
filter: [{ kind: 'component', 'spec.type': 'service' }],
});

await act(async () => resolveRetry());

expectSampleDataNotice();
expect(screen.getByText('demo-service')).toBeInTheDocument();
expect(screen.getByText('Total Deployments')).toBeInTheDocument();
expect(
screen.queryByRole('alert', { name: 'Could not load services' }),
).not.toBeInTheDocument();
expect(screen.queryByRole('progressbar')).not.toBeInTheDocument();
expect(getEntities).toHaveBeenCalledTimes(2);
});

it('offers another retry after a second failure and handles an empty recovery', async () => {
getEntities
.mockRejectedValueOnce(new Error('Catalog unavailable'))
.mockRejectedValueOnce(new Error('Still unavailable'))
.mockResolvedValueOnce({ items: [] });

await renderPage();
fireEvent.click(screen.getByRole('button', { name: 'Retry' }));

await waitFor(() =>
expect(
screen.getByRole('alert', { name: 'Could not load services' }),
).toHaveTextContent('Still unavailable'),
);
expectSampleDataNotice();
expect(screen.queryByText('Catalog unavailable')).not.toBeInTheDocument();
expect(screen.queryByText('Total Deployments')).not.toBeInTheDocument();
expect(
screen.queryByText('No services found in the catalog.'),
).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: 'Retry' }));

expect(
await screen.findByText('No services found in the catalog.'),
).toBeInTheDocument();
expectSampleDataNotice();
expect(screen.getByText('Total Deployments')).toBeInTheDocument();
expect(
screen.queryByRole('alert', { name: 'Could not load services' }),
).not.toBeInTheDocument();
expect(
screen.queryByRole('button', { name: 'Retry' }),
).not.toBeInTheDocument();
expect(getEntities).toHaveBeenCalledTimes(3);
});

it('offers retry when the catalog rejects without an Error object', async () => {
getEntities.mockRejectedValue(null);

await renderPage();

expectSampleDataNotice();
expect(
screen.getByRole('alert', { name: 'Could not load services' }),
).toHaveTextContent('The catalog is unavailable.');
expect(screen.getByRole('button', { name: 'Retry' })).toBeInTheDocument();
expect(screen.queryByText('Total Deployments')).not.toBeInTheDocument();
});

Expand Down
48 changes: 37 additions & 11 deletions packages/app/src/components/pulse-check/PulseCheckPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import CircularProgress from '@mui/material/CircularProgress';
import Card from '@mui/material/Card';
import CardContent from '@mui/material/CardContent';
import Alert from '@mui/material/Alert';
import AlertTitle from '@mui/material/AlertTitle';
import Button from '@mui/material/Button';
import { useTheme } from '@mui/material/styles';
import { Page, Header, Content } from '@backstage/core-components';
import { useApi } from '@backstage/core-plugin-api';
Expand Down Expand Up @@ -116,23 +118,35 @@ export const PulseCheckPage = () => {
const [entities, setEntities] = useState<Entity[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<Error | null>(null);
const [loadAttempt, setLoadAttempt] = useState(0);

useEffect(() => {
let active = true;
const fetchEntities = async () => {
setLoading(true);
setError(null);
try {
setLoading(true);
const response = await catalogApi.getEntities({
filter: [{ kind: 'component', 'spec.type': 'service' }],
});
setEntities(response.items);
if (active) setEntities(response.items);
} catch (err) {
setError(err as Error);
if (active) {
setError(
err instanceof Error
? err
: new Error('The catalog is unavailable.'),
);
}
} finally {
setLoading(false);
if (active) setLoading(false);
}
};
fetchEntities();
}, [catalogApi]);
return () => {
active = false;
};
}, [catalogApi, loadAttempt]);

const healthData = entities.map(generateMockHealth);

Expand All @@ -159,7 +173,7 @@ export const PulseCheckPage = () => {
minHeight: 400,
}}
>
<CircularProgress />
<CircularProgress aria-label="Loading services" />
</Box>
</Content>
</Page>
Expand All @@ -175,11 +189,23 @@ export const PulseCheckPage = () => {
/>
<Content>
<SampleDataNotice />
<Box sx={{ textAlign: 'center', py: 4 }}>
<Typography color="error">
Error loading services: {error.message}
</Typography>
</Box>
<Alert
severity="error"
aria-labelledby="pulse-check-load-error"
action={
<Button
color="inherit"
onClick={() => setLoadAttempt(attempt => attempt + 1)}
>
Retry
</Button>
}
>
<AlertTitle id="pulse-check-load-error">
Could not load services
</AlertTitle>
{error.message}
</Alert>
</Content>
</Page>
);
Expand Down
Loading