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.
47 lines
2.1 KiB
TypeScript
47 lines
2.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { isUnknownMailbox } from "@/lib/mailbox/mailboxRoute";
|
|
import type { Mailbox } from "@/jmap/types";
|
|
|
|
/**
|
|
* Issue #111: a folder id the account does not have rendered the ordinary
|
|
* empty state — "Nothing here. This folder is empty" — which is a claim about
|
|
* a folder that is not there. A stale link read as a folder that had emptied
|
|
* itself rather than one that was gone.
|
|
*
|
|
* The interesting case is not the unknown id. It is `loaded`: the folder list
|
|
* arrives after the first paint, so for a moment *every* id is unknown,
|
|
* including the right one. A version without that gate sends the reader to
|
|
* their inbox from the folder they asked for, on every cold load, and looks
|
|
* exactly like a flaky link.
|
|
*/
|
|
|
|
const boxes = (...ids: string[]): Record<string, Mailbox> =>
|
|
Object.fromEntries(ids.map((id) => [id, { id, name: id } as Mailbox]));
|
|
|
|
describe("spotting a folder the account does not have", () => {
|
|
it("is unknown when the list is loaded and does not contain it", () => {
|
|
expect(isUnknownMailbox({ mailboxId: "ghost", mailboxes: boxes("a", "b"), loaded: true })).toBe(true);
|
|
});
|
|
|
|
it("is not unknown when the list contains it", () => {
|
|
expect(isUnknownMailbox({ mailboxId: "a", mailboxes: boxes("a", "b"), loaded: true })).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("what it refuses to call unknown", () => {
|
|
it("says nothing before the folder list has arrived", () => {
|
|
// The whole point. Every id is unknown at this moment, the real one too.
|
|
expect(isUnknownMailbox({ mailboxId: "a", mailboxes: {}, loaded: false })).toBe(false);
|
|
expect(isUnknownMailbox({ mailboxId: "ghost", mailboxes: {}, loaded: false })).toBe(false);
|
|
});
|
|
|
|
it("says nothing when there is no folder in the address", () => {
|
|
// /mail has its own redirect to the inbox; this must not race it.
|
|
expect(isUnknownMailbox({ mailboxId: undefined, mailboxes: boxes("a"), loaded: true })).toBe(false);
|
|
});
|
|
|
|
it("says nothing on a search, which has no folder to be wrong about", () => {
|
|
expect(isUnknownMailbox({ mailboxId: "ghost", mailboxes: boxes("a"), loaded: true, search: true })).toBe(false);
|
|
});
|
|
});
|