Files
AetherForge/server/web/src/components/Forge/ForgeProgressBar.test.tsx
AetherForge 6ab43a468b
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Forge success label and real progress bar tied to server compile stages.
Replace Dispensed with Forged in the reveal modal, poll builder/progress with indeterminate-until-first-byte UX, and emit interpolated compile progress during long garble builds.
2026-06-08 19:48:46 -07:00

49 lines
1.7 KiB
TypeScript

/**
* @vitest-environment happy-dom
*/
import { describe, expect, it } from 'vitest';
import { cleanup, render, screen } from '@testing-library/react';
import ForgeProgressBar, {
FORGE_INITIAL_STAGE,
isForgeProgressIndeterminate,
} from './ForgeProgressBar';
describe('isForgeProgressIndeterminate', () => {
it('is indeterminate before server reports progress', () => {
expect(isForgeProgressIndeterminate(FORGE_INITIAL_STAGE, 0)).toBe(true);
expect(isForgeProgressIndeterminate('', 0)).toBe(true);
});
it('is determinate once server reports pct or stage advances', () => {
expect(isForgeProgressIndeterminate('Compiling agent', 20)).toBe(false);
expect(isForgeProgressIndeterminate(FORGE_INITIAL_STAGE, 5)).toBe(false);
});
});
describe('ForgeProgressBar', () => {
it('renders nothing when not building', () => {
const { container } = render(
<ForgeProgressBar building={false} stage="" progress={0} />,
);
expect(container.firstChild).toBeNull();
});
it('shows indeterminate track before server progress', () => {
const { container } = render(
<ForgeProgressBar building stage={FORGE_INITIAL_STAGE} progress={0} />,
);
expect(screen.getByText('…')).toBeInTheDocument();
expect(container.querySelector('.forge-progress-track.indeterminate')).toBeTruthy();
cleanup();
});
it('shows server stage and pct when progress is reported', () => {
const { container } = render(
<ForgeProgressBar building stage="Compiling agent" progress={42} />,
);
expect(screen.getByText('Compiling agent')).toBeInTheDocument();
expect(screen.getByText('42%')).toBeInTheDocument();
expect(container.querySelector('.forge-progress-track.indeterminate')).toBeNull();
});
});