fix(files): an upload is said once in any order, copy buttons speak, a link list that failed says so
- The queue holds an upload it sees land done while this tab's upload still waits for its answer, so the dialog's notice is the only one whichever comes first; another device's upload follows after. - One `useCopyFeedback` for every Copy beside a value (token, share link, set-password link): Copied for a moment, a notice a screen reader hears, a warning when the clipboard refuses; the token dialog's two Copy buttons are named by what they copy. - The share dialog's link list shows loading, and a load error with Retry, never "no links" — and no New link beside a list it has not seen. - The settings texts say that signing out elsewhere or a password change revokes the API tokens. - DESIGN.md logs the folder-link decisions; the design lab keeps only the chosen renderings of the Links, Tokens and Files rounds.
This commit is contained in:
@@ -7,15 +7,18 @@ import type { QueueJob } from "./api";
|
||||
import {
|
||||
clearFinished,
|
||||
forgetFinished,
|
||||
noteAnnounced,
|
||||
noteQueue,
|
||||
resetQueueWatch,
|
||||
takeUnannounced,
|
||||
uploadEnded,
|
||||
uploadStarted,
|
||||
useFinished,
|
||||
} from "./downloadQueue";
|
||||
import { renderHook } from "@testing-library/react";
|
||||
|
||||
const job = (id: number, status: string) => ({ id, status }) as unknown as QueueJob;
|
||||
const upload = (id: number) =>
|
||||
({ id, status: "done", source_kind: "upload" }) as unknown as QueueJob;
|
||||
const finishedIds = () => renderHook(() => useFinished()).result.current.map((j) => j.id);
|
||||
|
||||
beforeEach(resetQueueWatch);
|
||||
@@ -44,12 +47,39 @@ describe("downloadQueue · a finish", () => {
|
||||
|
||||
it("a finish its own action announced is kept for the tray but not announced again", () => {
|
||||
noteQueue([]);
|
||||
noteAnnounced(7); // an upload, done in the answer that made it
|
||||
noteQueue([job(7, "done"), job(8, "done")]);
|
||||
uploadStarted();
|
||||
uploadEnded(7); // an upload, done in the answer that made it
|
||||
noteQueue([upload(7), job(8, "done")]);
|
||||
expect(takeUnannounced().map((j) => j.id)).toEqual([8]);
|
||||
expect(finishedIds()).toEqual([7, 8]);
|
||||
});
|
||||
|
||||
it("an upload the queue sees done before its own answer arrives is still said once, by it", () => {
|
||||
noteQueue([]);
|
||||
uploadStarted();
|
||||
noteQueue([upload(7)]); // the server committed it; the answer is still on its way
|
||||
expect(takeUnannounced()).toEqual([]);
|
||||
uploadEnded(7);
|
||||
expect(takeUnannounced()).toEqual([]);
|
||||
expect(finishedIds()).toEqual([7]);
|
||||
});
|
||||
|
||||
it("another device's upload landing meanwhile is announced once this tab's upload answers", () => {
|
||||
noteQueue([]);
|
||||
uploadStarted();
|
||||
noteQueue([upload(7), upload(9)]);
|
||||
uploadEnded(7);
|
||||
expect(takeUnannounced().map((j) => j.id)).toEqual([9]);
|
||||
});
|
||||
|
||||
it("an upload that failed announced nothing: what landed meanwhile is announced", () => {
|
||||
noteQueue([]);
|
||||
uploadStarted();
|
||||
noteQueue([upload(9)]);
|
||||
uploadEnded(null);
|
||||
expect(takeUnannounced().map((j) => j.id)).toEqual([9]);
|
||||
});
|
||||
|
||||
it("a failure is not a finish; closing the tray forgets what finished", () => {
|
||||
noteQueue([job(1, "running"), job(2, "running")]);
|
||||
noteQueue([job(1, "error"), job(2, "done")]);
|
||||
|
||||
Reference in New Issue
Block a user