mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-04 08:15:41 +00:00
The offline section of Settings > Backup & reset now shows, per account, the space each part takes, the last sync, a first sync's progress with the time left, the window and attachment choices, and clearing the account. All conflicts, calendar and contacts too, are listed there and counted in the banner. - the organisation's caps beat the user's choice and the desktop default, and every path that takes a scope goes through `effectiveScope` - the desktop app keeps mail without asking, says so once, and stays off for an account where the user turned it off - `navigator.storage.persist()` is asked on turning it on, and a refusal warns with a way to ask again; Safari gets the 7-day hint when not installed - a store the browser deleted is noticed, says what was lost and syncs again - a full disk says so, with what to do - those who had offline mode keep it, with the 30 days they had - Keep offline in the Files app's menu
51 lines
2.4 KiB
TypeScript
51 lines
2.4 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { minutesLeft, nextProgress, progressWorthShowing } from '../sync-progress';
|
|
|
|
const event = (phase: string, done: number, total: number | null) => ({ area: 'mail', phase, done, total });
|
|
|
|
describe('the time left', () => {
|
|
it('says nothing until it has seen enough', () => {
|
|
const start = nextProgress(undefined, event('bodies', 0, 1000), 0);
|
|
expect(minutesLeft(start)).toBeNull();
|
|
expect(minutesLeft(nextProgress(start, event('bodies', 100, 1000), 1_000))).toBeNull();
|
|
});
|
|
|
|
it('works from the rate of this phase', () => {
|
|
const start = nextProgress(undefined, event('bodies', 0, 6000), 0);
|
|
// 100 a second: 59 s left rounds up.
|
|
expect(minutesLeft(nextProgress(start, event('bodies', 100, 6000), 1_000))).toBeNull();
|
|
expect(minutesLeft(nextProgress(start, event('bodies', 600, 6000), 6_000))).toBe(1);
|
|
});
|
|
|
|
it('while listing, counts the bodies that come after', () => {
|
|
const start = nextProgress(undefined, event('list', 0, 50_000), 0);
|
|
const left = minutesLeft(nextProgress(start, event('list', 7_000, 50_000), 5_000));
|
|
// Bench rig: 35 s to list, about 7 minutes in all.
|
|
expect(left).toBeGreaterThanOrEqual(5);
|
|
expect(left).toBeLessThanOrEqual(10);
|
|
});
|
|
|
|
it('starts over with each phase', () => {
|
|
const list = nextProgress(undefined, event('list', 1000, 1000), 0);
|
|
const bodies = nextProgress(list, event('bodies', 10, 1000), 60_000);
|
|
expect(bodies.startedAt).toBe(60_000);
|
|
expect(bodies.startedDone).toBe(10);
|
|
});
|
|
|
|
it('has no time without a total, or when done', () => {
|
|
const open = nextProgress(undefined, event('list', 0, null), 0);
|
|
expect(minutesLeft(nextProgress(open, event('list', 500, null), 10_000))).toBeNull();
|
|
const done = nextProgress(undefined, event('bodies', 0, 100), 0);
|
|
expect(minutesLeft(nextProgress(done, event('bodies', 100, 100), 10_000))).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('what is worth a line', () => {
|
|
it('a big job or an unknown one, not a few new messages', () => {
|
|
expect(progressWorthShowing(undefined)).toBe(false);
|
|
expect(progressWorthShowing(nextProgress(undefined, event('bodies', 1, 3), 0))).toBe(false);
|
|
expect(progressWorthShowing(nextProgress(undefined, event('bodies', 1, 500), 0))).toBe(true);
|
|
expect(progressWorthShowing(nextProgress(undefined, event('list', 500, null), 0))).toBe(true);
|
|
});
|
|
});
|