添加 U20 辅助控制器验证器测试
@@ -0,0 +1,99 @@
import assert from'node:assert/strict';
import fs from'node:fs';
import ts from'typescript';
const componentPath='src/components/PlayerBarAuxiliaryControls.tsx';
const componentSource=fs.readFileSync(componentPath,'utf8');
const transpiled=ts.transpileModule(componentSource,{
compilerOptions: {
jsx: ts.JsxEmit.ReactJSX,
module: ts.ModuleKind.ESNext,
target: ts.ScriptTarget.ES2022,
strict: true,
},
fileName: componentPath,
reportDiagnostics: true,
});
const errors=(transpiled.diagnostics??[]).filter(
(diagnostic)=>diagnostic.category===ts.DiagnosticCategory.Error,
);
assert.equal(errors.length,0,auxiliary controls TypeScript diagnostics: ${errors.map((item)=>item.messageText).join('; ')});
for(const marker of[
'export function PlayerAuxiliaryControls',
'export function PlayerCompatibilityMarkers',
'AUXILIARY_ICON_BUTTON_BASE_CLASS',
'AUXILIARY_ICON_BUTTON_IDLE_CLASS',
'aria-label="辅助播放控制"',
'aria-label={播放完成策略:${completionLabel}}',
'aria-haspopup="menu"',
'aria-expanded={showPlaylistDropdown}',
'aria-pressed={desktopLyricsActive}',
'aria-pressed={isMuted}',
'',
'',
'',
'mvp59-player-beta-chips',
'mvp79-player-ui-bugfix',
]){
assert.ok(componentSource.includes(marker),auxiliary control contract missing: ${marker});
}
for(const forbidden of[
'useState(',
'useEffect(',
'useMemo(',
'localStorage',
'window.yangKura',
'setTimeout(',
'useAudioPlayer',
'onAddToPlaylist',
'setToastMessage',
'toggleCompletionMode(',
'toggleMute(',
]){
assert.ok(!componentSource.includes(forbidden),auxiliary controls crossed behavior boundary: ${forbidden});
}
const playerBar=fs.readFileSync('src/components/PlayerBar.tsx','utf8');
for(const marker of[
"import { PlayerAuxiliaryControls, PlayerCompatibilityMarkers } from './PlayerBarAuxiliaryControls';",
'const handleTogglePlaylist = () => {',
'const handleToggleDesktopLyrics = () => {',
'const handleMoreActions = () => {',
"setToastMessage(desktopLyricsActive ? '歌词浮窗已关闭' : '歌词浮窗已开启')",
"setToastMessage('更多播放操作将在后续版本开放')",
' toggleCompletionMode?.()}',
'onSelectPlaylist={handlePlaylistSelect}',
'onToggleDesktopLyrics={handleToggleDesktopLyrics}',
'onToggleMute={toggleMute}',
'onMoreActions={handleMoreActions}',
'