Files
wordpress-theme-aksrt/tests/widget-system/icon-card-contract.test.cjs
T
kate522 f7cedc7163 fix(header): unify top icon-card size and layout
Add a single always-loaded header-cards.css that normalizes the
顶部多功能组件图标卡片 geometry (equal-width cells, fixed 45px icon
badge, zibll mobile padding) across all pages, and enqueue it from
ScriptsPart1b. Remove the orphan header-components.css + subdirectory
that were never enqueued. Repoint the icon-card contract test at the
new stylesheet.
2026-08-19 18:34:48 +08:00

39 lines
1.9 KiB
JavaScript

'use strict';
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const test = require('node:test');
const root = path.resolve(__dirname, '..', '..');
const read = (file) => fs.readFileSync(path.join(root, file), 'utf8');
test('icon card renderers keep vertical and horizontal Zibll DOM contracts separate', () => {
const helper = read('inc/helpers/aksrt-icon-cards.php');
const widgets = read('src/WidgetSystem/Renderers/GeneralRenderer.php');
const header = read('inc/helpers/homepage/header-components.php');
assert.match(helper, /<div class="icon-card /);
assert.match(helper, /<div class="icon-cover-card aksrt-icon-cover-card flex ac /);
assert.match(helper, /icon-cover-icon badg cir/);
assert.match(helper, /icon-cover-desc ml10 flex1 px12-sm/);
assert.match(helper, /aksrt-icon-cover-card/);
assert.match(widgets, /'customize_icon' => \$card\['customize_icon'\] \?\? ''/);
assert.match(widgets, /'custom_icon'\s+=> \$card\['custom_icon'\] \?\? ''/);
assert.match(widgets, /'icon_image'\s+=> \$card\['icon_image'\] \?\? ''/);
assert.match(header, /empty\(\$card\['custom_icon'\]\)/);
});
test('homepage horizontal cards use the shared compact card contract and retain Zibll responsive rules', () => {
const css = read('assets/css/frontend/header-cards.css');
const baseCss = read('assets/css/frontend/base.css');
const widgetCss = read('assets/widgets/frontend.css');
assert.match(baseCss, /\.icon-cover-card\.aksrt-icon-cover-card\s*\{\s*padding:\s*10px;\s*font-size:\s*16px;/);
assert.match(css, /\.icon-cover-card\.zib-widget[\s\S]*?padding:\s*10px;/);
assert.match(css, /\.icon-cover-card\.padding-10[\s\S]*?padding:\s*2px;/);
assert.doesNotMatch(css, /\.header-slider-card \.icon-cover-icon\.badg\.cir/);
assert.doesNotMatch(css, /\.header-slider-card \.icon-cover-icon img/);
assert.doesNotMatch(widgetCss, /aksrt-widget-icon-cards \.icon-cover-card/);
});