Personal Telegram developer console for GitHub

feat/ops-console-v2-1
audit/commit-drilldown audit/finalize-workspace-menu-security audit/ops-actionability audit/pr-menu-consolidation audit/status-menu-consolidation audit/telegram-menu-e2e audit/telegram-menu-e2e-wave2 chore/actions-node24-runtime cleanup/remove-diag design/cloudflare-ops-read docs/control-plane-2-7-design docs/guide-v2-1-sync docs/menu-audit-final-sync docs/phase2-acceptance-closeout docs/phase2-multifile-design feat/bootstrap-worker feat/cloudflare-ops-read feat/cp2-multifile-final feat/cp2-multifile-workspace feat/cp3-github-write-final feat/cp4-cloudflare-ops-final feat/cp5-cicd-control-plane feat/cp6-incident-manager feat/cp7-automation-engine feat/deep-file-browser feat/final-delivery-16-20 feat/github-advanced-read feat/in-app-guide-v2 feat/navigation-recovery-ux-v2 feat/ops-console-v2-1 feat/persistent-menu-code-input feat/phase2-multifile-workspace feat/phase2-multifile-workspace-v2 feat/plugin-foundation-v1 feat/safe-github-ops feat/self-register-webhook feat/studio-g0-foundation feat/telegram-main-inline-menu feat/telegram-pr-merge feat/ux-platform-8-12 feat/v3a-readonly-copilot feat/workspace-file-upload feature/mobile-repo-browser feature/multi-file-change-set fix/approval-expiry-feedback fix/callback-resilience-and-docs fix/ci-actions-pagination fix/cloudflare-fetch-binding fix/editor-request-body-cap fix/editor-safe-file-options fix/issues-permission-release-empty-ux fix/main-menu-callback-fallback fix/phase2-file-editor-selection fix/phase2-final-ux fix/phase2-workspace-ref-persistence fix/production-auto-deploy fix/provider-write-error-feedback fix/repository-id-navigation-fallback fix/repository-pr-navigation fix/telegram-callback-updates fix/telegram-runtime-diagnostics fix/workspace-editor-flow-v2 fix/workspace-recovery-validation hardening/ci-zero-test-telegram-token hardening/pr1-destructive-totp hardening/pr2-kill-switch main multifile-workspace nexa/edit-BwJEIIY3PW nexa/edit-IPHT8irO7b nexa/edit-b4Od3BIMYd p2-multifile phase2-20261005 phase2-20261005-a phase2-20261005-b phase2-20261005-c phase2-20261005-d phase2-20261005-e phase2-20261005-f phase2-20261005-g phase2-20261005-h phase2-20261005-i phase2-20261005-j phase2-20261005-k phase2-20261005-l phase2-20261005-m phase2-20261005-n phase2-20261005-o phase2-20261005-p phase2-20261005-q phase2-20261005-r phase2-20261005-s phase2-20261005-t phase2-20261005-u phase2-20261005-v phase2-20261005-w phase2-20261005-x phase2-20261005-y phase2-20261005-z phase2-acceptance-closeout phase2-add-file-hotfix phase2-change-set phase2-design-20261005 phase2-design-final phase2-implementation phase2-multifile-implementation phase2-multifile-spec phase2-spec-final phase2-workspace phase2/multifile-workspace plan/nexa-studio-v2-reviewed security/remove-telegram-setup spec/repository-workspace-editor v3a/multifile work/multifile
js 115 lines 5.13 KB
Raw
1 import { describe, it } from 'node:test';
2 import assert from 'node:assert/strict';
3 import { GuideMenuManager } from '../src/guide-menu.js';
4 import { GuidedNexaDevBot } from '../src/guide-bot.js';
5
6 const github = {
7 owner: 'davoodmehraban89',
8 async listRepositories() { return []; },
9 async getRepository(repo) {
10 return { id: repo, name: String(repo), fullName: `davoodmehraban89/${repo}`, private: true, defaultBranch: 'main', archived: false };
11 }
12 };
13
14 function callbacks(view) {
15 return (view.reply_markup?.inline_keyboard || []).flat().map(button => button.callback_data).filter(Boolean);
16 }
17
18 describe('Nexa Dev Bot - in-app V2 guide', () => {
19 const menu = new GuideMenuManager(github);
20
21 it('exposes Guide from the main inline menu', () => {
22 const view = menu.getMainMenuView();
23 assert.ok(callbacks(view).includes('menu:help'));
24 assert.ok(view.reply_markup.inline_keyboard.flat().some(button => button.text.includes('راهنما')));
25 });
26
27 it('guide index and pages explain every major V2 control with navigable chapters', async () => {
28 const index = await menu.renderByCallback('menu:help');
29 assert.match(index.text, /راهنمای Nexa Dev.*V2/);
30 const indexCallbacks = callbacks(index);
31 for (const callback of ['help:1', 'help:2', 'help:3', 'help:4', 'help:5', 'help:6']) {
32 assert.ok(indexCallbacks.includes(callback), `missing ${callback}`);
33 }
34
35 const menuHelp = await menu.renderByCallback('help:1');
36 for (const label of ['منوی اصلی', 'پروژه‌ها', 'وضعیت', 'ابزارها', 'امنیت', 'راهنما']) {
37 assert.ok(menuHelp.text.includes(label), `menu guide missing ${label}`);
38 }
39
40 const repoHelp = await menu.renderByCallback('help:2');
41 for (const label of ['فایل‌ها', 'Pull Request', 'Commit', 'CI / Actions', 'Branches', 'Issues', 'Releases']) {
42 assert.ok(repoHelp.text.includes(label), `repo guide missing ${label}`);
43 }
44
45 const workspaceHelp = await menu.renderByCallback('help:3');
46 for (const label of ['Edit', 'Editor', 'بارگذاری فایل', 'Paste متن', 'پیام Commit', 'Diff', 'آماده Commit', 'لغو Draft']) {
47 assert.ok(workspaceHelp.text.includes(label), `workspace guide missing ${label}`);
48 }
49
50 const ciHelp = await menu.renderByCallback('help:5');
51 for (const label of ['Job', 'Artifacts', 'log', 'اجرای مجدد', 'لغو Workflow', 'بروزرسانی', 'جدیدتر', 'قدیمی‌تر']) {
52 assert.ok(ciHelp.text.includes(label), `CI guide missing ${label}`);
53 }
54 });
55
56 it('documents the operational diagnostics, read-only configuration and Security Center controls', async () => {
57 const menuHelp = await menu.renderByCallback('help:1');
58 for (const label of ['خودآزمایی', 'تست اتصال GitHub', 'Runtime', 'Plugin Registry', 'پیکربندی', 'فقط‌خواندنی']) {
59 assert.ok(menuHelp.text.includes(label), `operational guide missing ${label}`);
60 }
61
62 const securityHelp = await menu.renderByCallback('help:6');
63 for (const label of ['مرکز امنیت', 'سیاست عملیات', 'Safe Approval', 'Replay']) {
64 assert.ok(securityHelp.text.includes(label), `security guide missing ${label}`);
65 }
66 });
67
68 it('documents the complete file-edit flow from project selection through branch-only Safe Approval commit', async () => {
69 const view = await menu.renderByCallback('help:4');
70 const expected = [
71 'پروژه‌ها',
72 'فایل‌ها',
73 'Edit',
74 'Editor',
75 'ذخیره Draft',
76 'Diff',
77 'پیام Commit',
78 'آماده Commit',
79 'Safe Approval',
80 'تأیید و اجرا',
81 'nexa/edit-',
82 'main'
83 ];
84 for (const item of expected) assert.ok(view.text.includes(item), `file-edit guide missing ${item}`);
85 assert.match(view.text, /main.*مستقیم.*تغییر|شاخه.*پیش.?فرض.*تغییر.*نمی/);
86 });
87
88 it('keeps every guide page and callback within Telegram limits', async () => {
89 const encoder = new TextEncoder();
90 for (const callback of ['menu:help', 'help:1', 'help:2', 'help:3', 'help:4', 'help:5', 'help:6']) {
91 const view = await menu.renderByCallback(callback);
92 assert.ok(view.text.length <= 4096, `${callback} exceeds Telegram message limit`);
93 for (const value of callbacks(view)) {
94 assert.ok(encoder.encode(value).length <= 64, `${value} exceeds Telegram callback limit`);
95 }
96 }
97 });
98
99 it('keeps Guide in the persistent bottom keyboard and routes its text without consuming workspace input', async () => {
100 const bot = new GuidedNexaDevBot({});
101 const sent = [];
102 bot.telegram.sendMessage = async (chatId, text, replyMarkup) => {
103 sent.push({ chatId, text, replyMarkup });
104 return { ok: true };
105 };
106
107 await bot.handleMessage({ chat: { id: 1 }, from: { id: 1 }, text: '/start' });
108 const quickKeyboard = sent[0].replyMarkup.keyboard.flat().map(button => button.text);
109 assert.ok(quickKeyboard.includes('📘 راهنما'));
110
111 sent.length = 0;
112 await bot.handleMessage({ chat: { id: 1 }, from: { id: 1 }, text: '📘 راهنما' });
113 assert.match(sent[0].text, /راهنمای Nexa Dev.*V2/);
114 });
115 });