Dawnline 0.16.3
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions
- Move Dawnline to Services in LuCI and update links and documentation. - Make activity messages clearer, including device renames and person-specific history. - Prune redundant frontend tests.
This commit is contained in:
1 parent
f2b5ba101b
commit
b0d9982796
37 files changed
+452
-243
No files matched your search
@@ -10,11 +10,6 @@ const days: Pair[] = [
|
||||
];
|
||||
|
||||
describe('mirrored bars', () => {
|
||||
it('splits the height between the two directions around the hairline', () => {
|
||||
const m = mirror(days, 64);
|
||||
expect(m.top + m.bottom + 3).toBe(64);
|
||||
});
|
||||
|
||||
it('fits both peaks on one scale, the tighter one filling its half', () => {
|
||||
const m = mirror(days, 64);
|
||||
expect(120 * m.scale).toBeLessThanOrEqual(m.top);
|
||||
@@ -22,11 +17,6 @@ describe('mirrored bars', () => {
|
||||
expect(Math.max(120 * m.scale - m.top, 40 * m.scale - m.bottom)).toBeCloseTo(0);
|
||||
});
|
||||
|
||||
it('keeps 55–80% of the height for downloads, however lopsided the days', () => {
|
||||
expect(mirror([[0, 100]], 64).top).toBe(Math.round(61 * 0.8));
|
||||
expect(mirror([[100, 1]], 64).top).toBe(Math.round(61 * 0.55));
|
||||
});
|
||||
|
||||
it('draws a month without traffic', () => {
|
||||
const m = mirror([[0, 0]], 34);
|
||||
expect(Number.isFinite(m.scale)).toBe(true);
|
||||
|
||||
+3
-25
@@ -11,22 +11,9 @@ const run = (x: number, t: number, frames = 1): number[] => {
|
||||
};
|
||||
|
||||
describe('caret glide', () => {
|
||||
it('is 90% of the way in about 134 ms (8–9 frames), a touch over, then rests exactly on its target', () => {
|
||||
const xs = run(0, 100);
|
||||
expect(xs[7]).toBeLessThan(90);
|
||||
expect(xs[8]).toBeGreaterThanOrEqual(90);
|
||||
const peak = Math.max(...xs);
|
||||
expect(peak).toBeGreaterThan(101);
|
||||
expect(peak).toBeLessThan(103);
|
||||
expect(xs.at(-1)).toBe(100);
|
||||
expect(xs.length).toBeLessThan(40);
|
||||
});
|
||||
|
||||
it('goes the same way to the left', () => {
|
||||
const xs = run(100, 0);
|
||||
expect(xs[8]).toBeLessThanOrEqual(10);
|
||||
expect(Math.min(...xs)).toBeGreaterThan(-3);
|
||||
expect(xs.at(-1)).toBe(0);
|
||||
it('settles exactly on its target in either direction', () => {
|
||||
expect(run(0, 100).at(-1)).toBe(100);
|
||||
expect(run(100, 0).at(-1)).toBe(0);
|
||||
});
|
||||
|
||||
it('takes a late frame as up to 2.5 frames, and is simply there after a long gap', () => {
|
||||
@@ -84,13 +71,4 @@ describe('caret places', () => {
|
||||
expect(places(field({ value: long, start: 0, end: 22 }), mono)).toEqual({ caret: 216, start: 16, end: 216, range: true });
|
||||
expect(places(field({ value: long, start: 0, end: 22, scroll: 20 }), mono)).toEqual({ caret: 216, start: 16, end: 216, range: true });
|
||||
});
|
||||
|
||||
it('measures only the text before each end', () => {
|
||||
const seen: string[] = [];
|
||||
places(field({ value: 'iPad', start: 1, end: 3 }), (s) => {
|
||||
seen.push(s);
|
||||
return mono(s);
|
||||
});
|
||||
expect(seen).toEqual(['i', 'iPa']);
|
||||
});
|
||||
});
|
||||
@@ -56,6 +56,33 @@ describe('events', () => {
|
||||
expect(isProblem({ ts: 1, sys: { ts: 1, src: 'awg', level: 'down', msg: '' } })).toBe(true);
|
||||
expect(isProblem({ ts: 1, ev: ev({ type: 'connect' }) })).toBe(false);
|
||||
});
|
||||
it('renders portal and unattributed renames, including saved names of removed devices', () => {
|
||||
for (const by of ['portal', undefined] as const) {
|
||||
const event = ev({ type: 'device_changed', by, person: 'p1', device: 'd1', detail: 'renamed from Мяточька ПК' });
|
||||
expect(text(eventText({ people }, event))).toBe(
|
||||
by === 'portal'
|
||||
? 'Person Myata renamed device Phone on their portal · was Мяточька ПК'
|
||||
: 'Device Myata · Phone renamed · was Мяточька ПК',
|
||||
);
|
||||
expect(text(eventText({ people: [] }, { ...event, pname: 'Myata', dname: 'Phone' }))).toBe(text(eventText({ people }, event)));
|
||||
}
|
||||
});
|
||||
it('omits the person only in their own activity and preserves the actor', () => {
|
||||
const st = { people };
|
||||
const rename = ev({ type: 'device_changed', by: 'portal', person: 'p1', device: 'd1', detail: 'renamed from Old' });
|
||||
expect(text(eventText(st, rename, 'p1'))).toBe('Device Phone renamed on the portal · was Old');
|
||||
expect(text(eventText(st, { ...rename, by: 'admin' }, 'p1'))).toBe('You renamed device Phone · was Old');
|
||||
expect(text(eventText(st, rename, 'another-person'))).toBe(text(eventText(st, rename)));
|
||||
expect(text(eventText(st, ev({ type: 'disconnect', person: 'p1', device: 'd1' }), 'p1'))).toBe('Device Phone went offline');
|
||||
expect(text(eventText(st, ev({ person: 'p1', device: 'd1', detail: '1.2.3.4' }), 'p1'))).toBe('Device Phone connected from 1.2.3.4');
|
||||
expect(text(eventText(st, ev({ type: 'roam', person: 'p1', device: 'd1', detail: '1 → 2' }), 'p1').slice(0, 3))).toBe(
|
||||
'Device Phone changed network ',
|
||||
);
|
||||
expect(text(eventText(st, ev({ type: 'expiring', person: 'p1', detail: '3 days' }), 'p1'))).toBe('Access ends in 3 days');
|
||||
expect(text(eventText(st, ev({ type: 'device_added', by: 'portal', person: 'p1', detail: 'Tablet' }), 'p1'))).toBe(
|
||||
'Device Tablet added on the portal',
|
||||
);
|
||||
});
|
||||
it('says what happened', () => {
|
||||
const st = { people };
|
||||
expect(text(eventText(st, ev({ person: 'p1', device: 'd1', detail: '1.2.3.4', where: 'Berlin' })))).toBe(
|
||||
|
||||
@@ -5,8 +5,6 @@ import {
|
||||
date,
|
||||
dayDiff,
|
||||
daysLeft,
|
||||
defaultName,
|
||||
DEVICE_NAME_MAX,
|
||||
deviceNameFits,
|
||||
endsIn,
|
||||
endsSoon,
|
||||
@@ -14,7 +12,6 @@ import {
|
||||
fmtDay,
|
||||
kb,
|
||||
shiftDay,
|
||||
todayOf,
|
||||
validDeviceName,
|
||||
} from '../src/shared/format';
|
||||
import { plural } from '../src/shared/i18n';
|
||||
@@ -62,9 +59,7 @@ describe('router days', () => {
|
||||
expect(endsIn(2)).toBe('ends tomorrow');
|
||||
expect(endsIn(7)).toBe('ends in 7 days');
|
||||
});
|
||||
it('takes today from a series', () => {
|
||||
expect(todayOf([{ day: '2026-10-15' }, { day: '2026-10-16' }])).toBe('2026-10-16');
|
||||
});
|
||||
|
||||
it('shows a router day as that day in any time zone', () => {
|
||||
expect(fmtDay('2026-10-01')).toBe('1 Oct 2026');
|
||||
expect(date('2026-10-01')).toBe('1 Oct 2026');
|
||||
@@ -84,7 +79,6 @@ describe('numbers', () => {
|
||||
|
||||
describe('device names', () => {
|
||||
it('take letters of any language, digits, spaces and - _ . up to the limit', () => {
|
||||
expect(DEVICE_NAME_MAX).toBe(20);
|
||||
expect(validDeviceName('Kitchen iPad')).toBe(true);
|
||||
expect(validDeviceName('my-pc_2.home')).toBe(true);
|
||||
expect(validDeviceName('Мой ноутбук')).toBe(true);
|
||||
@@ -120,9 +114,4 @@ describe('device names', () => {
|
||||
expect(fitName('Living room TV ab xy', ' 2')).toBe('Living room TV ab 2');
|
||||
expect(validDeviceName(fitName('Redmi Note 13 Pro+ 5G', ' 12'))).toBe(true);
|
||||
});
|
||||
|
||||
it('names a device after its kind', () => {
|
||||
expect(defaultName('phone')).toBe('Phone');
|
||||
expect(defaultName('other')).toBe('Device');
|
||||
});
|
||||
});
|
||||
+3
-11
@@ -2,19 +2,11 @@ import { describe, expect, it } from 'vitest';
|
||||
import { arc, cityPlaces, devicePlaces, separate, type MapData } from '../src/admin/map';
|
||||
|
||||
describe('arc (mapcn buildArcCoordinates)', () => {
|
||||
it('runs from one point to the other in 64 steps', () => {
|
||||
it('runs from one point to the other', () => {
|
||||
const pts = arc([-0.1276, 51.5074], [-74.006, 40.7128]);
|
||||
expect(pts).toHaveLength(65);
|
||||
expect(pts[0]).toEqual([-0.1276, 51.5074]);
|
||||
expect(pts[64][0]).toBeCloseTo(-74.006);
|
||||
expect(pts[64][1]).toBeCloseTo(40.7128);
|
||||
});
|
||||
|
||||
it('bends to the left of travel by a fifth of the distance', () => {
|
||||
// Due east 10°: the control point sits 2° north of the middle, the curve's peak half of that.
|
||||
const mid = arc([0, 0], [10, 0])[32];
|
||||
expect(mid[0]).toBeCloseTo(5);
|
||||
expect(mid[1]).toBeCloseTo(1);
|
||||
expect(pts.at(-1)![0]).toBeCloseTo(-74.006);
|
||||
expect(pts.at(-1)![1]).toBeCloseTo(40.7128);
|
||||
});
|
||||
|
||||
it('takes the short way across the antimeridian', () => {
|
||||
|
||||
@@ -35,13 +35,4 @@ describe('motion', () => {
|
||||
expect(s.at(s.duration)).toBe(1);
|
||||
}
|
||||
});
|
||||
|
||||
it('gives the bouncy spring its overshoot and the smooth one none', () => {
|
||||
const peak = (s: typeof BOUNCY) => Math.max(...Array.from({ length: 200 }, (_, i) => s.at((s.duration * i) / 200)));
|
||||
// skiper103: about 11% past the end, settled well inside a second.
|
||||
expect(peak(BOUNCY)).toBeGreaterThan(1.08);
|
||||
expect(peak(BOUNCY)).toBeLessThan(1.15);
|
||||
expect(BOUNCY.duration).toBeLessThan(900);
|
||||
expect(peak(SMOOTH)).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
@@ -1,21 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
BAND,
|
||||
FLAT,
|
||||
arrived,
|
||||
bandMiddle,
|
||||
moment,
|
||||
msAt,
|
||||
placeKey,
|
||||
replayStays,
|
||||
shares,
|
||||
shimmerOpacity,
|
||||
stays,
|
||||
stretches,
|
||||
ticks,
|
||||
timeline,
|
||||
visits,
|
||||
} from '../src/admin/places/model';
|
||||
import { moment, msAt, placeKey, replayStays, shares, stays, stretches, ticks, timeline, visits } from '../src/admin/places/model';
|
||||
import type { GeoPoint, LogEvent } from '../src/shared/types';
|
||||
|
||||
const D = 'd_1';
|
||||
@@ -148,16 +132,6 @@ describe('replay', () => {
|
||||
const ms = msAt(st, steps, 38000);
|
||||
expect(moment(st, steps, ms).t).toBeCloseTo(38000, -1);
|
||||
});
|
||||
|
||||
it('runs the shimmer from before the place it leaves to past the next', () => {
|
||||
expect(bandMiddle(0)).toBeCloseTo(-BAND / 2);
|
||||
expect(bandMiddle(1)).toBeCloseTo(1 + BAND / 2);
|
||||
expect(arrived(bandMiddle(0.3))).toBe(false);
|
||||
expect(arrived(1 - FLAT)).toBe(true);
|
||||
const ex = shimmerOpacity(0.5);
|
||||
expect(ex[0]).toBe('interpolate');
|
||||
expect(ex.slice(3)).toEqual([0, 1, FLAT, 1, BAND / 2, 0]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ticks', () => {
|
||||
|
||||
+2
-29
@@ -7,42 +7,15 @@ const KEY = `vpn://${'A1b2C3d4'.repeat(180)}`;
|
||||
const HUGE = 'A1b2C3d4'.repeat(425);
|
||||
|
||||
describe('qr', () => {
|
||||
it('draws the plain look as black squares on white in one path', () => {
|
||||
const svg = qrSvg(LINK);
|
||||
expect(svg).toContain('fill="#fff"');
|
||||
expect(svg).toContain('shape-rendering="crispEdges"');
|
||||
expect(svg).not.toContain('evenodd');
|
||||
});
|
||||
|
||||
it('draws the night look as light dots on black with eyes, marked on links only', () => {
|
||||
it('omits the centre mark on dense codes', () => {
|
||||
const link = qrSvg(LINK, 3, true, 'night');
|
||||
expect(link).toContain('fill="#0a0a0a"');
|
||||
expect(link).toContain('fill-rule="evenodd"');
|
||||
expect(link).not.toContain('crispEdges');
|
||||
// The mark's light tile on a short code, none on a dense one.
|
||||
expect(link).toContain('fill="#f2f2f2"/><g transform');
|
||||
expect(link).toContain('<g transform');
|
||||
expect(denseQr(KEY)).toBe(true);
|
||||
expect(qrSvg(KEY, 3, true, 'night')).not.toContain('<g transform');
|
||||
});
|
||||
|
||||
it('draws the day look with the night shapes, dark on white', () => {
|
||||
const night = qrSvg(LINK, 3, true, 'night');
|
||||
const day = qrSvg(LINK, 3, true, 'day');
|
||||
expect(day).toMatch(/<rect width="(\d+)" height="\1" fill="#ffffff"\/>/);
|
||||
expect(day).toContain('fill-rule="evenodd"');
|
||||
expect(day).not.toContain('crispEdges');
|
||||
// The same dots and eyes as at night, in the other colours; the mark's tile turns dark.
|
||||
expect(day.replace(/#ffffff/g, 'BG').replace(/#0a0a0a/g, 'FG')).toBe(night.replace(/#0a0a0a/g, 'BG').replace(/#f2f2f2/g, 'FG'));
|
||||
});
|
||||
|
||||
it('gives a dense night code fuller dots', () => {
|
||||
expect(qrSvg(LINK, 3, true, 'night')).toContain('a0.42 0.42');
|
||||
expect(qrSvg(KEY, 3, true, 'night')).toContain('a0.48 0.48');
|
||||
});
|
||||
|
||||
it('says a 3.4 KB text does not fit instead of throwing, and keeps it from the camera', () => {
|
||||
expect(HUGE.length).toBe(3400);
|
||||
expect(() => qrFits(HUGE)).not.toThrow();
|
||||
expect(qrFits(HUGE)).toBe(false);
|
||||
expect(scannable(HUGE)).toBe(false);
|
||||
// It still fits a code, but too fine to read off a screen.
|
||||
|
||||
+10
-12
@@ -2,19 +2,17 @@ import { describe, expect, it } from 'vitest';
|
||||
import { labelFade } from '../src/portal/ui/seg';
|
||||
|
||||
describe('picker names on a pick', () => {
|
||||
it('blurs the picked name in a beat after the pill, and folds a shown one whole', () => {
|
||||
expect(labelFade({ width: 0, full: 90, opacity: 0 }, true)).toEqual({ duration: 280, delay: 70 });
|
||||
expect(labelFade({ width: 90, full: 90, opacity: 1 }, false)).toEqual({ duration: 220, delay: 0 });
|
||||
});
|
||||
|
||||
it('runs only what is left of a fade turned back half-way', () => {
|
||||
it('shortens a fade interrupted part-way', () => {
|
||||
// Picked again while it was folding away: it comes back from 40% at once.
|
||||
const opening = labelFade({ width: 0, full: 90, opacity: 0 }, true);
|
||||
const closing = labelFade({ width: 90, full: 90, opacity: 1 }, false);
|
||||
const back = labelFade({ width: 36, full: 90, opacity: 0.4 }, true);
|
||||
expect(back.duration).toBeCloseTo(168);
|
||||
expect(back.delay).toBeCloseTo(42);
|
||||
// Left while it was still coming in: it folds from the wider of its width and its opacity.
|
||||
expect(labelFade({ width: 45, full: 90, opacity: 0.2 }, false).duration).toBeCloseTo(110);
|
||||
expect(labelFade({ width: 9, full: 90, opacity: 0.7 }, false).duration).toBeCloseTo(154);
|
||||
expect(back.duration).toBeGreaterThan(0);
|
||||
expect(back.duration).toBeLessThan(opening.duration);
|
||||
expect(back.delay).toBeLessThanOrEqual(opening.delay);
|
||||
// Interrupted while opening: either width or opacity can keep the closing fade active.
|
||||
expect(labelFade({ width: 45, full: 90, opacity: 0.2 }, false).duration).toBeLessThan(closing.duration);
|
||||
expect(labelFade({ width: 9, full: 90, opacity: 0.7 }, false).duration).toBeLessThan(closing.duration);
|
||||
});
|
||||
|
||||
it('leaves a folded name alone and a shown one picked again as it is', () => {
|
||||
@@ -25,7 +23,7 @@ describe('picker names on a pick', () => {
|
||||
|
||||
it('keeps to its bounds when the readings are off (no width to measure, opacity past 1)', () => {
|
||||
expect(labelFade({ width: 30, full: 0, opacity: 0 }, false).duration).toBe(0);
|
||||
expect(labelFade({ width: 200, full: 90, opacity: 0 }, false).duration).toBe(220);
|
||||
expect(labelFade({ width: 200, full: 90, opacity: 0 }, false)).toEqual(labelFade({ width: 90, full: 90, opacity: 0 }, false));
|
||||
expect(labelFade({ width: 0, full: 90, opacity: 1.2 }, true).duration).toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,6 @@ import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
addLink,
|
||||
appsFor,
|
||||
deviceNoun,
|
||||
importPath,
|
||||
importSteps,
|
||||
inWebview,
|
||||
@@ -53,12 +52,6 @@ describe('setup', () => {
|
||||
expect(wantsAdd('')).toBe(false);
|
||||
});
|
||||
|
||||
it('names the device being set up by its kind, not its name', () => {
|
||||
expect(deviceNoun('phone')).toBe('phone');
|
||||
expect(deviceNoun('computer')).toBe('computer');
|
||||
expect(deviceNoun('other')).toBe('device');
|
||||
});
|
||||
|
||||
it('knows whether the page is open on the device being set up', () => {
|
||||
expect(sameDevice('phone', 'ios')).toBe(true);
|
||||
expect(sameDevice('phone', 'mac')).toBe(false);
|
||||
|
||||
+1
-21
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { wayState, type WayState } from '../src/portal/way';
|
||||
import { wayState } from '../src/portal/way';
|
||||
import type { Device, SetupState } from '../src/shared/types';
|
||||
|
||||
/** When the sheet opened (router clock). */
|
||||
@@ -73,24 +73,4 @@ describe('the set-up sheet’s way', () => {
|
||||
expect(wayState(dev({ online: false, handshake: OPENED + 9, setup: null }), OPENED)).toBe('waiting');
|
||||
expect(wayState(undefined, OPENED)).toBe('waiting');
|
||||
});
|
||||
|
||||
it('follows a whole set-up: knocks, no data, imported again, connected', () => {
|
||||
const seen: WayState[] = [];
|
||||
const answers: Partial<Device>[] = [
|
||||
{},
|
||||
{ setup: setup('trying') },
|
||||
{ setup: setup('trying') },
|
||||
// The network let it through, but the phone holds an old configuration.
|
||||
{ online: true, handshake: OPENED + 40 },
|
||||
{ online: true, handshake: OPENED + 40, setup: setup('nodata', OPENED + 52) },
|
||||
// Gone offline: plain waiting, no line of its own.
|
||||
{ online: false, handshake: OPENED + 40 },
|
||||
{ online: true, handshake: OPENED + 300, setup: setup('flowing', OPENED + 300) },
|
||||
];
|
||||
for (const a of answers) {
|
||||
const st = wayState(dev(a), OPENED);
|
||||
if (st !== seen[seen.length - 1]) seen.push(st);
|
||||
}
|
||||
expect(seen).toEqual(['waiting', 'trying', 'waiting', 'nodata', 'waiting', 'connected']);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user