Simulated upload list with progress bars, 3 at a time
You are building the upload tray of a file-sharing app. Users can add as many files as they like, but the server accepts only 3 uploads at a time. Build a UI where every click of a button adds a simulated upload with its own progress bar. Up to three bars fill at the same time, and every other file waits for a free slot.
File 1, File 2, File 3, and so on.MAX_CONCURRENT_UPLOADS (3) files upload at once. A new file starts right away when a slot is free. Otherwise it is queued.UPLOAD_DURATION_MS (2000 ms). It must not jump straight to 100%.Uploading: 3 · Queued: 2 · Done: 0. Any separator works between the three parts.No files yet instead of the list.Both constants are already declared at the top of the starter code.
Click "Add file" 5 times in a row:
0 s File 1-3 uploading, File 4-5 queued Uploading: 3 · Queued: 2 · Done: 0
1 s File 1-3 at about 50%, File 4-5 at 0%
2 s File 1-3 done, File 4-5 start Uploading: 2 · Queued: 0 · Done: 3
4 s everything is done Uploading: 0 · Queued: 0 · Done: 5
Click "Add file" 3 times, wait 1 second, then click it 4 more times:
1 s File 1-3 at about 50%, File 4-7 queued Uploading: 3 · Queued: 4 · Done: 0
2 s File 1-3 done, File 4, 5 and 6 start Uploading: 3 · Queued: 1 · Done: 3
File 7 keeps waiting until one of them finishes
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:
No files yet is visible before the first click and gone after it.File 1, File 2, …) appear in the order they were added.<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.Uploading: N, Queued: N and Done: N with the right counts. The colon is optional.Capitalization and extra spacing don’t matter.