Takes the flat module count from 66 to 42, continuing what admin/ and
calendar/ started.
lib/mailbox/ archiveDate, emptyFolder, folderMove, labelTree,
mailboxName, mailboxRoute
lib/sieve/ sieve, sieveApply, sieveFolders
lib/input/ keyboard, swipe, touch, listSelection, dropUpload
lib/notify/ notify, webpush, webpushEnable
lib/sw/ swCache, swFacts, staleBuild
lib/text/ html, markdown, text, emlName
FOUR THINGS THE FILENAMES GET WRONG, each checked by reading the file
rather than trusting what it is called:
- appFolder is not a mailbox. It is the `ihasmail` folder in JMAP
*Files*, where the client keeps signature images and synced settings.
It stays flat.
- format holds no formatting of text. It re-exports the date and clock
formatters, so it belongs with dates/datetime, not with text/.
- preview is the file viewer deciding what it can show without
downloading, and source is where to point someone asking for this
instance's AGPL source. Neither is about text.
- notify is not Web Push. It is the tab title, the favicon badge and
the new-mail sound -- in-app notification, which is why it sits with
webpush rather than under sw/ with the service worker's own concerns.
threadScroll stays flat too: it decides where a conversation opens, which
is view state rather than a gesture, and input/ is honest only if
everything in it interprets something the reader did.
No behavior change. Almost every reference was on the @/ alias; eight
relative imports in files that did not move, or that moved away from a
sibling, needed rewriting by hand.
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { comboOf, keyboard } from "@/lib/input/keyboard";
|
|
|
|
/*
|
|
* A "keydown" that carries no key. Chrome's password autofill dispatches one
|
|
* as a plain Event when a saved login is picked, and comboOf read `key.length`
|
|
* off it -- an uncaught TypeError in the console on every sign-in.
|
|
*/
|
|
|
|
let pop: (() => void) | null = null;
|
|
|
|
afterEach(() => {
|
|
pop?.();
|
|
pop = null;
|
|
});
|
|
|
|
describe("a keydown with no key", () => {
|
|
it("has no combo", () => {
|
|
expect(comboOf(new Event("keydown") as KeyboardEvent)).toBeNull();
|
|
});
|
|
|
|
it("reaches no binding and throws nothing", () => {
|
|
const handler = vi.fn();
|
|
pop = keyboard.pushScope("test", [{ keys: "e", description: "Archive", group: "Mail", handler }]);
|
|
const errors: unknown[] = [];
|
|
const onError = (ev: ErrorEvent) => errors.push(ev.error);
|
|
window.addEventListener("error", onError);
|
|
try {
|
|
window.dispatchEvent(new Event("keydown", { bubbles: true }));
|
|
} finally {
|
|
window.removeEventListener("error", onError);
|
|
}
|
|
expect(errors).toEqual([]);
|
|
expect(handler).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("leaves real keys alone", () => {
|
|
expect(comboOf(new KeyboardEvent("keydown", { key: "e" }))).toBe("e");
|
|
expect(comboOf(new KeyboardEvent("keydown", { key: "E", shiftKey: true }))).toBe("E");
|
|
expect(comboOf(new KeyboardEvent("keydown", { key: "Enter", ctrlKey: true }))).toMatch(/enter$/);
|
|
});
|
|
});
|