mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-12 03:36:59 +00:00
fix(ui): use Docker health status terms on container cards (#1696)
Per-container metadata showed healthcheck passing/failing instead of Docker's healthy/unhealthy/starting, which disagreed with the stack pill. Render the normalized healthStatus token directly and document the same terms. Closes #1677
This commit is contained in:
@@ -549,3 +549,58 @@ describe('containers load states', () => {
|
||||
expect(screen.queryByRole('button', { name: /Monitor / })).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('ContainersHealth Docker health status labels', () => {
|
||||
const OLD_PHRASES = ['healthcheck passing', 'healthcheck failing', 'healthcheck starting'] as const;
|
||||
const HEALTH_TOKENS = ['healthy', 'unhealthy', 'starting'] as const;
|
||||
|
||||
function metaLine(): HTMLElement {
|
||||
const parent = screen.getByText('up 2 hours').parentElement;
|
||||
if (!parent) throw new Error('expected meta line parent');
|
||||
return parent;
|
||||
}
|
||||
|
||||
function metaSpanTexts(meta: HTMLElement = metaLine()): Array<string | null> {
|
||||
return Array.from(meta.querySelectorAll('span')).map((el) => el.textContent);
|
||||
}
|
||||
|
||||
function renderWithHealth(healthStatus?: ContainerInfo['healthStatus']) {
|
||||
const base = container([{ PrivatePort: 80, PublicPort: 8080 }]);
|
||||
return renderHealth(
|
||||
healthStatus === undefined ? base : ({ ...base, healthStatus } as ContainerInfo),
|
||||
);
|
||||
}
|
||||
|
||||
function expectNoLegacyPhrases(meta: HTMLElement) {
|
||||
for (const phrase of OLD_PHRASES) {
|
||||
expect(meta.textContent).not.toContain(phrase);
|
||||
}
|
||||
}
|
||||
|
||||
it.each(HEALTH_TOKENS)('renders exact meta-line token for healthStatus %s', (token) => {
|
||||
renderWithHealth(token);
|
||||
const meta = metaLine();
|
||||
const labels = metaSpanTexts(meta);
|
||||
expect(labels[0]).toBe('up 2 hours');
|
||||
expect(labels).toContain(token);
|
||||
expect(labels.filter((t) => t === token)).toHaveLength(1);
|
||||
expectNoLegacyPhrases(meta);
|
||||
expect(screen.getByRole('link', { name: /8080/ })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it.each([
|
||||
['none', 'none'],
|
||||
['omitted', undefined],
|
||||
] as const)('omits a health token when healthStatus is %s', (_case, healthStatus) => {
|
||||
renderWithHealth(healthStatus);
|
||||
const meta = metaLine();
|
||||
const labels = metaSpanTexts(meta);
|
||||
expect(labels).toContain('up 2 hours');
|
||||
for (const token of HEALTH_TOKENS) {
|
||||
expect(labels).not.toContain(token);
|
||||
}
|
||||
expect(labels.filter((t) => t === '·')).toHaveLength(1);
|
||||
expectNoLegacyPhrases(meta);
|
||||
expect(screen.getByRole('link', { name: /8080/ })).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -64,9 +64,7 @@ const healthcheckLabel = (
|
||||
health?: 'healthy' | 'unhealthy' | 'starting' | 'none',
|
||||
): string | null => {
|
||||
if (!health || health === 'none') return null;
|
||||
if (health === 'healthy') return 'healthcheck passing';
|
||||
if (health === 'unhealthy') return 'healthcheck failing';
|
||||
return 'healthcheck starting';
|
||||
return health;
|
||||
};
|
||||
|
||||
type StackPill = {
|
||||
|
||||
Reference in New Issue
Block a user