Files
oikos/test-browser-loader.mjs
Ulas Kalayci c4cb52d042 feat(nav): shared sub-tabs component for settings and kitchen
Extracts the tab-bar UI into a reusable renderSubTabs() utility
(public/utils/sub-tabs.js + public/styles/sub-tabs.css) so all
sub-module navigation shares one implementation and visual style.

- Settings: replaces template-literal <nav class="settings-tabs">
  with renderSubTabs(); tabs now show icon + label (pill-style),
  group separators via separatorBefore, panel switching via onChange
- Kitchen: renderKitchenTabsBar() becomes a thin wrapper around
  renderSubTabs(); kitchen-tabs.css keeps only layout adjustment rules
- CSS: kitchen-tab* rules removed from kitchen-tabs.css,
  settings-tab-btn* rules removed from settings.css; both now
  inherit from sub-tabs.css
- tokens.css: adds --sub-tabs-height (52px default;
  kitchen overrides to --kitchen-tabs-height: 56px)
- test-browser-loader.mjs: resolves browser-absolute /utils/*.js
  imports to public/ directory for Node test compatibility

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 07:33:54 +02:00

35 lines
1.2 KiB
JavaScript

/**
* test-browser-loader.mjs - Node.js Custom Loader für Tests
* Zweck: Browser-absolute Pfade (/foo.js) auf Stubs umleiten, damit
* Frontend-Module im Node-Test-Kontext importierbar sind.
* Verwendung: node --loader ./test-browser-loader.mjs test-xxx.js
* Dependencies: none
*/
const STUBS = {
'/i18n.js': `
export const t = (key) => key;
export const initI18n = async () => {};
export const setLocale = async () => {};
export const getLocale = () => 'de';
export const getSupportedLocales = () => ['de', 'en'];
export const formatDate = (d) => String(d);
export const formatTime = (d) => String(d);
`,
};
export async function resolve(specifier, context, nextResolve) {
if (STUBS[specifier]) {
return {
shortCircuit: true,
url: `data:text/javascript,${encodeURIComponent(STUBS[specifier])}`,
};
}
// Browser-absolute paths (/foo.js, /utils/bar.js) → public/foo.js, public/utils/bar.js
if (specifier.startsWith('/') && !specifier.startsWith('//')) {
const resolved = new URL('public' + specifier, import.meta.url).href;
return nextResolve(resolved, context);
}
return nextResolve(specifier, context);
}