test(ui): CheckpointsTable covers fragment layout + locale sub-line

This commit is contained in:
hsiegeln
2026-04-23 17:08:57 +02:00
parent 177673ba62
commit 9c1bd24f16

View File

@@ -26,25 +26,27 @@ const stoppedDep: Deployment = {
};
function expand() {
fireEvent.click(screen.getByRole('button', { name: /checkpoints/i }));
fireEvent.click(screen.getByRole('button', { name: /expand|collapse/i }));
}
describe('CheckpointsTable', () => {
it('defaults to collapsed — header visible, rows hidden', () => {
it('defaults to collapsed — label + trigger visible, rows hidden', () => {
wrap(<CheckpointsTable deployments={[stoppedDep]} versions={[v6]}
currentDeploymentId={null} jarRetentionCount={5} onSelect={() => {}} />);
expect(screen.getByRole('button', { name: /checkpoints \(1\)/i })).toBeInTheDocument();
expect(screen.getByText('Checkpoints')).toBeInTheDocument();
expect(screen.getByRole('button', { name: /expand \(1\)/i })).toBeInTheDocument();
expect(screen.queryByText('v6')).toBeNull();
expect(screen.queryByText('my-app-1.2.3.jar')).toBeNull();
});
it('clicking header expands to show rows', () => {
it('clicking trigger expands to show rows; label flips to Collapse', () => {
wrap(<CheckpointsTable deployments={[stoppedDep]} versions={[v6]}
currentDeploymentId={null} jarRetentionCount={5} onSelect={() => {}} />);
expand();
expect(screen.getByText('v6')).toBeInTheDocument();
expect(screen.getByText('my-app-1.2.3.jar')).toBeInTheDocument();
expect(screen.getByText('alice')).toBeInTheDocument();
expect(screen.getByRole('button', { name: /collapse \(1\)/i })).toBeInTheDocument();
});
it('row click invokes onSelect with deploymentId', () => {
@@ -105,4 +107,23 @@ describe('CheckpointsTable', () => {
expand();
expect(screen.getByText(/show older \(5\)/i)).toBeInTheDocument();
});
it('Deployed sub-line is locale-formatted (not the raw ISO)', () => {
wrap(<CheckpointsTable deployments={[stoppedDep]} versions={[v6]}
currentDeploymentId={null} jarRetentionCount={5} onSelect={() => {}} />);
expand();
// Raw ISO would contain 'T' and end in 'Z' — localized form must not.
const raw = '2026-04-23T10:35:00Z';
expect(screen.queryByText(raw)).toBeNull();
// Use the createdBy cell as an anchor and walk to the sibling Deployed cell.
const row = screen.getByText('alice').closest('tr')!;
const cells = row.querySelectorAll('td');
// Column order: Version, JAR, Deployed by, Deployed, Strategy, Outcome, chevron
const deployedCell = cells[3];
expect(deployedCell).toBeDefined();
const text = deployedCell.textContent ?? '';
expect(text).not.toContain('T10:35');
expect(text).not.toContain('Z');
expect(text.length).toBeGreaterThan(0);
});
});