Files
Megamenu/tests/validate-static-assets.js
Torsten Brendgen 50b85468f1 feat: Enhance MegaMenu with localization, caching, and new properties
- Added localization support for loading states, empty navigation, and submenu actions in both German and English.
- Introduced new properties in IMenuItem for description, openInNewWindow, and external links.
- Updated SPTermStorePickerService to handle cache versioning and language-specific caching.
- Implemented a new MegaMenuCore service for handling term properties, cache management, and navigation URL resolution.
- Refactored TaxonomyNavigationService to build menu hierarchy and filter hidden terms.
- Added automated tests for MegaMenu core functionalities and static asset validation.
- Removed unused ItemDictionary service.
- Created a comprehensive ToDo document outlining the implementation status and future tasks.
2026-07-20 21:34:24 +02:00

45 lines
1.5 KiB
JavaScript

'use strict';
var fs = require('fs');
function assert(name, condition) {
if (!condition) {
throw new Error('FAILED: ' + name);
}
console.log('OK:', name);
}
function read(path) {
return fs.readFileSync(path, 'utf8');
}
function validatePreview(path) {
var html = read(path);
var start = html.indexOf('<script>');
var end = html.indexOf('</script>', start);
assert(path + ' contains script', start >= 0 && end > start);
new Function(html.substring(start + 8, end));
assert(path + ' script syntax', true);
assert(path + ' uses production CSS', html.indexOf('../classic/megamenu-classic.css') >= 0);
assert(path + ' has mobile toggle', html.indexOf('mega-menu-mobile-toggle') >= 0);
assert(path + ' has accessible submenu toggle', html.indexOf('menu-item-toggle') >= 0 && html.indexOf('aria-controls') >= 0);
}
function validateStyle(path) {
var css = read(path);
var opening = (css.match(/\{/g) || []).length;
var closing = (css.match(/\}/g) || []).length;
assert(path + ' balanced blocks', opening === closing);
['mega-menu-mobile-toggle', 'menu-item-toggle', 'flyout-toggle', 'mega-menu-description'].forEach(function (className) {
assert(path + ' contains ' + className, css.indexOf(className) >= 0);
});
}
validatePreview('preview/mega-menu-preview.html');
validatePreview('preview/flyout-menu-preview.html');
validateStyle('classic/megamenu-classic.css');
validateStyle('src/extensions/megaMenu/MegaMenu.module.scss');
console.log('Static MegaMenu asset tests passed.');