Compare commits

..
Author SHA1 Message Date
陈大猫 409a5857e2 test(plugins): sync Database 0.3.2 brand fixture and list avatar assertions
#4525 synced the fallback catalog Database entry to 0.3.2, but the
reviewed brand-icon fixture still listed 0.3.1, so resolveCatalogBrandIcon
correctly refused the bind. Icon bytes are unchanged between those
commits; only version and commit are updated.

After #4524 the installed list avatar is a 32px details button, and the
48px slot exists only in the detail view. The state-pill test now covers
both layouts.
2026-11-29 09:16:21 +08:00
2 changed files with 19 additions and 7 deletions

No files matched your search

+2 -2
View File
@@ -1,9 +1,9 @@
[
{
"id": "com.binaricat.netcatty-database",
"version": "0.3.1",
"version": "0.3.2",
"repository": "binaricat/netcatty-database-plugin",
"commit": "84928ba5ca9638e509a11b7a578c400c0a320d06",
"commit": "81c3dd7ad9193b0d3a44df1531daeb6c758b4ee8",
"icon": {
"kind": "package",
"light": "assets/plugin-icon-light.png",
@@ -7,19 +7,27 @@ import { PluginPackageManager } from './PluginPackageManager';
import type { usePluginManager } from '../../../application/state/usePluginManager';
test('state pill exposes actual state, opposite action, focus styling and pending disable without granting permissions', async () => {
const globals = globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean };
const globals = globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean; requestAnimationFrame?: typeof requestAnimationFrame };
const previous = globals.IS_REACT_ACT_ENVIRONMENT; globals.IS_REACT_ACT_ENVIRONMENT = true;
const previousRaf = globals.requestAnimationFrame;
globals.requestAnimationFrame ??= (fn) => { fn(0); return 0; };
const calls: unknown[] = [];
const plugin = { id: 'com.test.pill', activeVersion: '1.0.0', enabled: true, manifest: { name: 'Pill' }, runtime: {} } as NetcattyInstalledPlugin;
const plugin = { id: 'com.test.pill', activeVersion: '1.0.0', enabled: true, manifest: { name: 'Pill', engines: { netcatty: '*', api: '*' } }, runtime: {} } as NetcattyInstalledPlugin;
const manager = { available: true, plugins: [plugin], busy: false, setEnabled: async (...args: unknown[]) => { calls.push(args); } } as unknown as ReturnType<typeof usePluginManager>;
let renderer: ReactTestRenderer;
const render = (enabled: boolean, busy = false) => <I18nProvider locale="en"><PluginPackageManager manager={{ ...manager, busy, plugins: [{ ...plugin, enabled }] }} /></I18nProvider>;
try {
await act(async () => { renderer = create(render(true)); });
const pill = () => renderer.root.findAllByType('button').find((node) => node.props['aria-pressed'] !== undefined)!;
const listAvatar = () => renderer.root.findAllByType('button').find((node) => node.props['aria-label'] === 'View details Pill' && typeof node.props.className === 'string' && node.props.className.includes('h-8 w-8'));
const detailLogoSlot = () => renderer.root.findAllByType('div').find((node) => node.props.className === 'flex h-12 w-12 shrink-0 items-center justify-center');
assert.ok(listAvatar(), 'list card renders 32px avatar details button');
assert.doesNotMatch(listAvatar()!.props.className, /\bbg-/, 'list avatar has no extra decorative background');
assert.equal(detailLogoSlot(), undefined, 'list render does not include the 48px detail logo slot');
await act(async () => listAvatar()!.props.onClick());
assert.ok(detailLogoSlot(), 'logo keeps its 48px layout slot without an extra decorative background');
assert.doesNotMatch(detailLogoSlot()!.props.className, /\bbg-/);
assert.equal(pill().props['aria-pressed'], true);
const logoSlot = renderer.root.findAllByType('div').find((node) => node.props.className === 'flex h-12 w-12 shrink-0 items-center justify-center');
assert.ok(logoSlot, 'logo keeps its 48px layout slot without an extra decorative background');
assert.equal(pill().props['aria-label'], 'Disable Pill');
assert.ok(pill().children.includes('Enabled'));
assert.match(pill().props.className, /rounded-full/);
@@ -39,5 +47,9 @@ test('state pill exposes actual state, opposite action, focus styling and pendin
assert.match(pill().props.className, /bg-muted/);
assert.equal(pill().props.style, undefined);
await act(async () => renderer.unmount());
} finally { globals.IS_REACT_ACT_ENVIRONMENT = previous; }
} finally {
globals.IS_REACT_ACT_ENVIRONMENT = previous;
if (previousRaf === undefined) Reflect.deleteProperty(globals, 'requestAnimationFrame');
else globals.requestAnimationFrame = previousRaf;
}
});