39ea1474a5
- Web: Union-Mitglied, Constraints, Icon, Registry-Eintrag, wire-Funktion, Katalog, Seiten-Verdrahtung, Tests und i18n (de/en) fuer den Typ link entfernt; link-widget.tsx/.test.tsx geloescht - API: create-widget.dto.ts (@IsIn-Liste) und widget-module-map.ts (Kommentare) auf sieben Typen angepasst; schema.prisma unveraendert - Neue Migration 20260916120000_remove_link_widget: eine idempotente DELETE-Anweisung auf WidgetInstance, FavoriteLink kaskadiert ueber den bestehenden FK; wird in diesem Auftrag NICHT ausgefuehrt - Neuer widget-wrapper-Test belegt den grauen Fallback fuer unbekannte Widget-Typen (Bestandsverhalten, jetzt festgeschrieben) - Handbuch (Widget-Tabelle, Einstellungs-Hinweise) und CHANGELOG (Geaendert/Entfernt/Behoben) aktualisiert - Web: 52 Dateien / 344 Tests gruen, tsc Exit 0; API: tsc Exit 0, dashboard-Spec 31 Tests gruen Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
79 lines
3.1 KiB
TypeScript
79 lines
3.1 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { WIDGET_CONSTRAINTS, type WidgetType } from './widget-registry';
|
|
|
|
/**
|
|
* DASH-11: Every WidgetType entry in WIDGET_CONSTRAINTS must have
|
|
* the four numeric grid-constraint fields: minW, minH, defaultW, defaultH.
|
|
*/
|
|
|
|
const ALL_WIDGET_TYPES: WidgetType[] = [
|
|
// Existing types
|
|
'clock',
|
|
'search',
|
|
'calendar',
|
|
'note',
|
|
// New types (Phase 8)
|
|
'calculator',
|
|
'favorites',
|
|
'stopwatch',
|
|
];
|
|
|
|
describe('WIDGET_CONSTRAINTS (DASH-11)', () => {
|
|
it('contains entries for all expected widget types', () => {
|
|
for (const type of ALL_WIDGET_TYPES) {
|
|
expect(
|
|
WIDGET_CONSTRAINTS,
|
|
`WIDGET_CONSTRAINTS must contain key "${type}"`,
|
|
).toHaveProperty(type);
|
|
}
|
|
});
|
|
|
|
it.each(ALL_WIDGET_TYPES)(
|
|
'WIDGET_CONSTRAINTS["%s"] has numeric minW, minH, defaultW, defaultH',
|
|
(type) => {
|
|
const constraints = WIDGET_CONSTRAINTS[type];
|
|
|
|
expect(typeof constraints.minW, `${type}.minW must be a number`).toBe('number');
|
|
expect(typeof constraints.minH, `${type}.minH must be a number`).toBe('number');
|
|
expect(typeof constraints.defaultW, `${type}.defaultW must be a number`).toBe('number');
|
|
expect(typeof constraints.defaultH, `${type}.defaultH must be a number`).toBe('number');
|
|
|
|
expect(constraints.minW, `${type}.minW must be >= 1`).toBeGreaterThanOrEqual(1);
|
|
expect(constraints.minH, `${type}.minH must be >= 1`).toBeGreaterThanOrEqual(1);
|
|
expect(constraints.defaultW, `${type}.defaultW >= minW`).toBeGreaterThanOrEqual(constraints.minW);
|
|
expect(constraints.defaultH, `${type}.defaultH >= minH`).toBeGreaterThanOrEqual(constraints.minH);
|
|
},
|
|
);
|
|
|
|
it('WIDGET_CONSTRAINTS contains new Phase-8 keys', () => {
|
|
expect(Object.keys(WIDGET_CONSTRAINTS)).toContain('calculator');
|
|
expect(Object.keys(WIDGET_CONSTRAINTS)).toContain('favorites');
|
|
expect(Object.keys(WIDGET_CONSTRAINTS)).toContain('stopwatch');
|
|
});
|
|
|
|
it('Test A (quick-260916-dyv): Minima = kleinste bedienbare Kachel je Typ, Vorgaben unveraendert (quick-260916-iex: Link-Widget entfernt, sieben Typen)', () => {
|
|
// Raster 24 Spalten / 20 px (quick-260916-bwo). Die Minima sind seit
|
|
// quick-260916-dyv inhaltsgetrieben (Rechnung im Plan), die Vorgaben
|
|
// (defaultW/defaultH) bleiben das Doppelte der alten 12-Spalten-Werte.
|
|
// 3 und 9 sind ungerade — die bwo-Pruefung "jeder Wert ist gerade" entfaellt.
|
|
expect(WIDGET_CONSTRAINTS).toEqual({
|
|
clock: { minW: 2, minH: 2, defaultW: 4, defaultH: 4 },
|
|
search: { minW: 6, minH: 2, defaultW: 12, defaultH: 4 },
|
|
calendar: { minW: 6, minH: 8, defaultW: 8, defaultH: 12 },
|
|
note: { minW: 4, minH: 4, defaultW: 6, defaultH: 8 },
|
|
calculator: { minW: 3, minH: 10, defaultW: 6, defaultH: 10 },
|
|
favorites: { minW: 3, minH: 3, defaultW: 6, defaultH: 10 },
|
|
stopwatch: { minW: 4, minH: 3, defaultW: 6, defaultH: 6 },
|
|
});
|
|
|
|
let counted = 0;
|
|
for (const type of ALL_WIDGET_TYPES) {
|
|
for (const field of ['minW', 'minH', 'defaultW', 'defaultH'] as const) {
|
|
expect(typeof WIDGET_CONSTRAINTS[type][field]).toBe('number');
|
|
counted++;
|
|
}
|
|
}
|
|
expect(counted).toBe(28);
|
|
});
|
|
});
|