/* Copyright (C) 2025 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import assert from 'node:assert/strict'; import test from 'node:test'; import React from 'react'; import { renderToStaticMarkup } from 'react-dom/server'; import * as ant from '@ant-design/icons'; import * as icons from '../../src/components/common/icons/ActionIcons.js'; import { loadFrontendModule } from './helpers/frontendModule.js'; test('common action glyphs render Ant Design icons with their existing accessible props', () => { for (const name of [ 'Search', 'Plus', 'RefreshCw', 'Copy', 'Trash2', 'X', 'Save', 'Eye', 'EyeOff', 'Download', 'Settings', 'GitCompare', 'TestTube2', 'Eraser', 'PanelLeftOpen', 'Bold', 'Moon', 'Sun', ]) { const html = renderToStaticMarkup( React.createElement(icons[name], { size: 18, 'aria-label': name, 'data-testid': name, }), ); assert.match(html, /app-action-icon/); assert.match(html, /anticon/); assert.match(html, /font-size:18px/); assert.ok(html.includes(`aria-label="${name}"`)); assert.doesNotMatch(html, /lucide/); } }); test('action icons preserve refs, class names, explicit style, symbolic size and color', () => { const ref = React.createRef(); const node = icons.Copy.render( { size: 'large', color: 'currentColor', className: 'custom', style: { fontSize: 22 }, strokeWidth: 1.5, }, ref, ); assert.equal(node.type, ant.CopyOutlined); assert.equal(node.ref, ref); assert.equal(node.props.style.fontSize, 22); assert.equal(node.props.style.color, 'currentColor'); assert.match(node.props.className, /custom/); assert.equal(node.props.strokeWidth, undefined); assert.equal(icons.ArrowUpRight.render({}, null).props.rotate, 45); }); test('favorite toggles retain filled stars and an unmatched heartbeat retains its original glyph', () => { assert.equal( icons.Star.render({ fill: 'currentColor' }, null).type, ant.StarFilled, ); assert.equal( icons.Star.render({ fill: 'none' }, null).type, ant.StarOutlined, ); assert.match( renderToStaticMarkup(React.createElement(icons.Activity)), /lucide/, ); }); test('legacy icon names retain size presets and now resolve to Ant Design', async () => { const legacy = await loadFrontendModule( new URL('../../src/components/ui/icons.jsx', import.meta.url), { react: React }, ); const html = renderToStaticMarkup( React.createElement(legacy.IconSearch, { size: 'small' }), ); assert.match(html, /font-size:14px/); assert.match(html, /anticon-search/); assert.doesNotMatch(html, /lucide/); assert.match( renderToStaticMarkup(React.createElement(legacy.IconPulse)), /lucide/, ); });