agent-workspace-ui-smoke-test.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. const assert = require('assert/strict');
  3. const crypto = require('crypto');
  4. const fs = require('fs');
  5. const path = require('path');
  6. const packageRoot = path.resolve(__dirname, '..');
  7. const sourceRoot = process.env.AGENT_HOUSE_DASHBOARD_DIR
  8. ? path.resolve(process.env.AGENT_HOUSE_DASHBOARD_DIR)
  9. : path.resolve(packageRoot, '..', 'agent-house', '.claude', 'plugins', 'qiwei-assistant', 'mcp', 'src', 'dashboard');
  10. const dashboardRoot = path.join(packageRoot, 'mcp', 'src', 'dashboard');
  11. const assets = ['index.html', 'app.js', 'styles.css'];
  12. function digest(filePath) {
  13. return crypto.createHash('sha256').update(fs.readFileSync(filePath)).digest('hex');
  14. }
  15. assert(fs.existsSync(sourceRoot), `agent-house dashboard source not found: ${sourceRoot}`);
  16. for (const asset of assets) {
  17. const source = path.join(sourceRoot, asset);
  18. const target = path.join(dashboardRoot, asset);
  19. assert.equal(digest(target), digest(source), `${asset} is not synchronized with agent-house`);
  20. }
  21. const html = fs.readFileSync(path.join(dashboardRoot, 'index.html'), 'utf8');
  22. const app = fs.readFileSync(path.join(dashboardRoot, 'app.js'), 'utf8');
  23. assert.match(html, /20260807-voice-preview-persist/);
  24. assert.match(app, /AGENT_SNAPSHOT_KEY/);
  25. assert.match(app, /\/api\/accounts\/switch/);
  26. assert.match(app, /voicePreview/);
  27. assert.match(app, /openSessionConversation/);
  28. console.log(JSON.stringify({ status: 'ok', synchronized: assets }, null, 2));