mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-08-02 12:54:32 +00:00
Some checks are pending
E2E Tests / E2E Test (Linux) - sandbox:docker (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:none (push) Waiting to run
E2E Tests / E2E Test - macOS (push) Waiting to run
E2E Tests / cron-interactive E2E (nightly) (push) Waiting to run
E2E Tests / web-shell Browser Regression (push) Waiting to run
SDK Java / ubuntu-latest / Java 11 (push) Waiting to run
SDK Java / ubuntu-latest / Java 17 (push) Waiting to run
SDK Java / macos-latest / Java 21 (push) Waiting to run
SDK Java / ubuntu-latest / Java 21 (push) Waiting to run
SDK Java / windows-latest / Java 21 (push) Waiting to run
SDK Java / Real daemon E2E / Java 11 (push) Waiting to run
* feat(web-shell): add Channel management page * fix(web-shell): address Channel manager review blockers
82 lines
2.2 KiB
TypeScript
82 lines
2.2 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
isPluginShadowPanel,
|
|
installWebShellShadowStyles,
|
|
resolveWebShellShadowDom,
|
|
} from './shadowDom';
|
|
|
|
describe('isPluginShadowPanel', () => {
|
|
it.each(['plugins', 'extensions', 'mcp', 'skills', 'agents', 'channels'])(
|
|
'includes the %s management surface',
|
|
(panel) => {
|
|
expect(isPluginShadowPanel(panel)).toBe(true);
|
|
},
|
|
);
|
|
|
|
it.each([null, 'settings', 'status', 'sessions'])(
|
|
'excludes the %s non-plugin surface',
|
|
(panel) => {
|
|
expect(isPluginShadowPanel(panel)).toBe(false);
|
|
},
|
|
);
|
|
});
|
|
|
|
describe('resolveWebShellShadowDom', () => {
|
|
it('keeps Shadow DOM disabled by default', () => {
|
|
expect(resolveWebShellShadowDom(undefined)).toEqual({
|
|
plugins: false,
|
|
portals: false,
|
|
styles: undefined,
|
|
});
|
|
});
|
|
|
|
it('enables both scenes for the boolean shorthand', () => {
|
|
expect(resolveWebShellShadowDom(true)).toEqual({
|
|
plugins: true,
|
|
portals: true,
|
|
});
|
|
});
|
|
|
|
it('resolves plugin and portal scenes independently', () => {
|
|
expect(
|
|
resolveWebShellShadowDom({
|
|
plugins: true,
|
|
portals: false,
|
|
styles: '.custom {}',
|
|
}),
|
|
).toEqual({
|
|
plugins: true,
|
|
portals: false,
|
|
styles: '.custom {}',
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('installWebShellShadowStyles', () => {
|
|
it('copies package CSS before consumer CSS and cleans up both', () => {
|
|
const packageStyle = document.createElement('style');
|
|
packageStyle.dataset.qwenWebShell = 'component';
|
|
packageStyle.textContent = '[data-web-shell-root] { color: black; }';
|
|
document.head.appendChild(packageStyle);
|
|
const host = document.createElement('div');
|
|
const shadowRoot = host.attachShadow({ mode: 'open' });
|
|
|
|
const cleanup = installWebShellShadowStyles(
|
|
shadowRoot,
|
|
'.consumer-content { color: rebeccapurple; }',
|
|
);
|
|
|
|
expect(
|
|
Array.from(shadowRoot.querySelectorAll('style')).map(
|
|
(style) => style.textContent,
|
|
),
|
|
).toEqual([
|
|
'[data-web-shell-root] { color: black; }',
|
|
'.consumer-content { color: rebeccapurple; }',
|
|
]);
|
|
cleanup();
|
|
packageStyle.remove();
|
|
expect(shadowRoot.querySelector('style')).toBeNull();
|
|
});
|
|
});
|