Sequential install steps with progress bars, cancel, and resume
A desktop app ships with a small installer. Installing runs a fixed list of steps one after another: a step only starts when the one before it has finished. Each step has its own progress bar, and an overall percentage shows how far the whole install has come. The user can cancel halfway and resume later without redoing the steps that already finished.
The starter code includes the steps:
const STEPS = [
{ name: 'Download package', durationMs: 2000 },
{ name: 'Verify checksum', durationMs: 500 },
{ name: 'Extract files', durationMs: 1500 },
{ name: 'Configure app', durationMs: 1000 },
];
STEPS order, with its name, a progress bar (0% to 100%) and its status.durationMs (Download package is at 50% after 1 second). It must not jump straight to 100%.Overall: N%, where N is the time completed so far divided by the total time of all steps (5000 ms), times 100, rounded down. Finished steps count with their full duration, the running step with the time it has run, and waiting steps with 0. Before installing it reads Overall: 0%.Overall: 100% is shown, the text Installation complete appears, and there is no Install, Cancel or Resume button anymore (remove it or disable it).Click Install
0 s Download package Running 0% Overall: 0%
1 s Download package Running 50% Overall: 20%
2.1 s Download package Done, Verify checksum 20% Overall: 42%
2.5 s Verify checksum Done, Extract files Running 0% Overall: 50%
5 s every step Done, "Installation complete" Overall: 100%
Click Install, then click Cancel at 2.75 s
2.75 s Extract files back to 0% and Waiting Overall: 50%
(Download package and Verify checksum stay Done)
later nothing moves, the button reads Resume
Click Resume
+1.5 s Extract files Done, Configure app Running Overall: 80%
+2.5 s "Installation complete"
Date.now() or performance.now()) on each tick keeps bars accurate.The tests click your button and read the screen like a user would. You don’t need test ids, specific class names, or an exact HTML structure. The tests replace the browser clock (setTimeout, setInterval, requestAnimationFrame, Date and performance.now) with a fake clock that they move forward by hand, so you can use any of those APIs. They check that:
STEPS order.<progress max="100"> element whose value is the percentage, or an element with role="progressbar" and an aria-valuenow from 0 to 100. Don’t render any other progress bars.Waiting, Running and Done appear once per step, in step order, and nowhere else on the page.Overall: N% and Installation complete appear as described.Capitalization and extra spacing don’t matter.