Files
dawnline/web/tests/morph.test.ts
T
Aemeath 4f12ca19e7
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
Dawnline 0.10.0
- Portal redesigned from scratch. No header bar: the page opens with the
  server's name and the person's and fades under the edges. Device cards
  show the status, the last 7 days (hover a day for its figures) and a
  Connect or Update button; "Your access" folds into rows: what they can
  reach (with the names at home), data this month day by day, and when
  access ends. The page follows the system's light or dark theme
- Adding a device: pick the kind (PC, Mobile, Router, Other) and a name, or
  add it from the device itself with the page's QR code. The set-up sheet
  then shows the app for that system and the connection, waits for the
  first connection, says "<device> connected" and closes on its own
- Switching apps in the set-up sheet changes only what differs: the old
  words blur into the new ones, and the menu path is shown for iOS and
  Android in one line. Names, numbers and statuses that change on the page
  morph in place
- Dialogs open in the middle on a computer, on the same spring as the menu;
  buttons that wait for the router show a spinner at once
- A paused account gets one card that says so; the page's messages are
  short and no longer send people to the admin. A QR code of the page sits
  beside the breadcrumb, to open it on another device
- Allowed hours are shown in the visitor's own time zone
- The portal's Title setting is gone: the page and its tab take the
  server's name. A title set before is removed on upgrade
- The admin names .conf files after the server too, as the portal does
  (Outline-Home.conf); its device menu says "Download AmneziaWG config" and
  "Copy AmneziaVPN config", and its QR codes use the portal's round look in
  the admin's light or dark colours
- README rewritten, with screenshots made from a demo cast
  (scripts/capture-screenshots.mjs --demo)
2026-10-19 21:07:14 +03:00

44 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { kept } from '../src/portal/ui/morph';
/** The letters a morph keeps, as the new text shows them (the rest come in). */
const keeps = (from: string, to: string) =>
kept([...from], [...to])
.map(([, j]) => [...to][j])
.join('');
describe('kept letters', () => {
it('keeps what the two share at the end together', () => {
expect(kept([...'iPad'], [...'Kitchen iPad'])).toEqual([
[0, 8],
[1, 9],
[2, 10],
[3, 11],
]);
});
it('keeps what they share at the start and at the end, and changes only the middle', () => {
expect(keeps('2 of 3', '3 of 3')).toBe(' of 3');
expect(keeps('Kitchen tablet', 'Kitchen iPad')).toBe('Kitchen a');
});
it('finds the letters in common between two different words', () => {
expect(keeps('Scan', 'Create')).toBe('a');
expect(keeps('Last 7 days', 'Thu 15 Oct')).toContain(' ');
});
it('keeps nothing between texts with nothing in common, and everything between equal ones', () => {
expect(kept([...'abc'], [...'xyz'])).toEqual([]);
expect(keeps('Connected', 'Connected')).toBe('Connected');
});
it('pairs indexes in order on both sides', () => {
const pairs = kept([...'Not set up yet'], [...'Connected']);
pairs.forEach(([i, j], n) => {
if (!n) return;
expect(i).toBeGreaterThan(pairs[n - 1][0]);
expect(j).toBeGreaterThan(pairs[n - 1][1]);
});
});
});