Personal Telegram developer console for GitHub

feat/studio-g0-foundation
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 156 lines 5.17 KB
Raw
1 import { describe, it } from 'node:test';
2 import assert from 'node:assert/strict';
3 import { MenuManager } from '../src/menu.js';
4
5 const github = {
6 owner: 'davoodmehraban89',
7 async listRepositories() {
8 return [
9 { id: 'Factor-easy', name: 'Factor-easy', private: true },
10 { id: 'nexa-dev-bot', name: 'nexa-dev-bot', private: true }
11 ];
12 },
13 async getRepository(repo) {
14 return {
15 id: repo,
16 name: repo,
17 fullName: `davoodmehraban89/${repo}`,
18 private: true,
19 description: 'Repository description',
20 defaultBranch: 'main',
21 archived: false
22 };
23 },
24 async listPullRequests() {
25 return [
26 {
27 number: 43,
28 title: 'Ops: strengthen long-running execution heartbeat rule',
29 author: 'davoodmehraban89',
30 state: 'open',
31 merged: false
32 }
33 ];
34 },
35 async listCommits() {
36 return [
37 {
38 sha: '87b25b1',
39 message: 'feat: mobile GitHub repository browser UX',
40 author: 'davoodmehraban89',
41 date: '2026-10-02'
42 }
43 ];
44 },
45 async listFiles() {
46 return [{ name: 'src', path: 'src', type: 'dir', size: 0 }];
47 },
48 async getRepoStatus() {
49 return {
50 defaultBranch: 'main',
51 lastRuns: [
52 {
53 name: 'CI',
54 status: 'completed',
55 conclusion: 'success',
56 commit: 'fix mobile menu'
57 }
58 ]
59 };
60 }
61 };
62
63 describe('Nexa Dev Bot - MenuManager & Navigation', () => {
64 const menu = new MenuManager(github);
65
66 it('main menu exposes the required top-level sections without claiming an unverified GitHub connection', () => {
67 const view = menu.getMainMenuView();
68 assert.ok(view.text.includes('Nexa Dev Bot'));
69 assert.doesNotMatch(view.text, /✅\s*متصل|تایید شده/);
70
71 const callbacks = view.reply_markup.inline_keyboard
72 .flat()
73 .map((b) => b.callback_data);
74 assert.ok(callbacks.includes('menu:repos'));
75 assert.ok(callbacks.includes('menu:status'));
76 assert.ok(callbacks.includes('menu:tools'));
77 assert.ok(callbacks.includes('menu:settings'));
78 assert.ok(callbacks.includes('menu:security'));
79 });
80
81 it('repositories list renders discovered projects and a back button', async () => {
82 const view = await menu.getReposListView();
83 assert.ok(view.text.includes('فهرست مخزن‌ها'));
84 const buttons = view.reply_markup.inline_keyboard.flat();
85 assert.ok(buttons.some((b) => b.text.includes('Factor-easy')));
86 assert.ok(buttons.some((b) => b.callback_data === 'repo:Factor-easy'));
87 assert.ok(buttons.some((b) => b.callback_data === 'menu:main'));
88 });
89
90 it('repository detail is based on live repository metadata', async () => {
91 const view = await menu.getRepoDetailView('Factor-easy');
92 assert.ok(view.text.includes('davoodmehraban89/Factor-easy'));
93 assert.ok(view.text.includes('main'));
94 assert.ok(view.text.includes('خصوصی'));
95 assert.doesNotMatch(view.text, /اتصال GitHub: ✅ تایید شده/);
96
97 const callbacks = view.reply_markup.inline_keyboard
98 .flat()
99 .map((b) => b.callback_data);
100 assert.ok(callbacks.includes('files:Factor-easy'));
101 assert.ok(callbacks.includes('pr:Factor-easy'));
102 assert.ok(callbacks.includes('commits:Factor-easy'));
103 assert.ok(callbacks.includes('status:Factor-easy'));
104 assert.ok(callbacks.includes('menu:repos'));
105 });
106
107 it('pull requests, commits, files and workflow status render source-backed data', async () => {
108 const prView = await menu.getPullRequestsView('Factor-easy');
109 assert.ok(prView.text.includes('#43'));
110 assert.ok(
111 prView.text.includes(
112 'Ops: strengthen long-running execution heartbeat rule'
113 )
114 );
115
116 const commitsView = await menu.getCommitsView('Factor-easy');
117 assert.ok(commitsView.text.includes('87b25b1'));
118
119 const filesView = await menu.getFilesView('Factor-easy');
120 assert.ok(filesView.text.includes('src'));
121
122 const statusView = await menu.getRepoStatusView('Factor-easy');
123 assert.ok(statusView.text.includes('CI'));
124 assert.ok(statusView.text.includes('main'));
125 });
126
127 it('service, tools and security views do not fabricate measurements or SLA claims', async () => {
128 const serviceView = menu.getServiceStatusView();
129 assert.doesNotMatch(serviceView.text, /100% SLA|Realtime/i);
130
131 const pingView = await menu.renderByCallback('tool:ping');
132 assert.doesNotMatch(pingView.text, /12ms|پایدار است/);
133
134 const securityView = menu.getSecurityView();
135 assert.doesNotMatch(
136 securityView.text,
137 /5000 req\/hr|فعال و ایمن|Fine-grained Personal Access Token/i
138 );
139 });
140
141 it('callback router preserves hierarchical back navigation', async () => {
142 const mainView = await menu.renderByCallback('menu:main');
143 assert.ok(mainView.text.includes('Nexa Dev Bot'));
144
145 const repoView = await menu.renderByCallback('repo:Factor-easy');
146 assert.ok(repoView.text.includes('Factor-easy'));
147
148 const prView = await menu.renderByCallback('pr:Factor-easy');
149 assert.ok(prView.text.includes('Pull Request'));
150
151 const backCallbacks = prView.reply_markup.inline_keyboard
152 .flat()
153 .map((b) => b.callback_data);
154 assert.ok(backCallbacks.includes('repo:Factor-easy'));
155 });
156 });