Personal Telegram developer console for GitHub

design/cloudflare-ops-read
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 121 lines 4.91 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 [{ number: 43, title: 'Ops: strengthen long-running execution heartbeat rule', author: 'davoodmehraban89', state: 'open', merged: false }];
26 },
27 async listCommits() {
28 return [{ sha: '87b25b1', message: 'feat: mobile GitHub repository browser UX', author: 'davoodmehraban89', date: '2026-10-02' }];
29 },
30 async listFiles() {
31 return [{ name: 'src', path: 'src', type: 'dir', size: 0 }];
32 },
33 async getRepoStatus() {
34 return {
35 defaultBranch: 'main',
36 lastRuns: [{ name: 'CI', status: 'completed', conclusion: 'success', commit: 'fix mobile menu' }]
37 };
38 }
39 };
40
41 describe('Nexa Dev Bot - MenuManager & Navigation', () => {
42 const menu = new MenuManager(github);
43
44 it('main menu exposes the required top-level sections without claiming an unverified GitHub connection', () => {
45 const view = menu.getMainMenuView();
46 assert.ok(view.text.includes('Nexa Dev Bot'));
47 assert.doesNotMatch(view.text, /✅\s*متصل|تایید شده/);
48
49 const callbacks = view.reply_markup.inline_keyboard.flat().map(b => b.callback_data);
50 assert.ok(callbacks.includes('menu:repos'));
51 assert.ok(callbacks.includes('menu:status'));
52 assert.ok(callbacks.includes('menu:tools'));
53 assert.ok(callbacks.includes('menu:settings'));
54 assert.ok(callbacks.includes('menu:security'));
55 });
56
57 it('repositories list renders discovered projects and a back button', async () => {
58 const view = await menu.getReposListView();
59 assert.ok(view.text.includes('فهرست مخزن‌ها'));
60 const buttons = view.reply_markup.inline_keyboard.flat();
61 assert.ok(buttons.some(b => b.text.includes('Factor-easy')));
62 assert.ok(buttons.some(b => b.callback_data === 'repo:Factor-easy'));
63 assert.ok(buttons.some(b => b.callback_data === 'menu:main'));
64 });
65
66 it('repository detail is based on live repository metadata', async () => {
67 const view = await menu.getRepoDetailView('Factor-easy');
68 assert.ok(view.text.includes('davoodmehraban89/Factor-easy'));
69 assert.ok(view.text.includes('main'));
70 assert.ok(view.text.includes('خصوصی'));
71 assert.doesNotMatch(view.text, /اتصال GitHub: ✅ تایید شده/);
72
73 const callbacks = view.reply_markup.inline_keyboard.flat().map(b => b.callback_data);
74 assert.ok(callbacks.includes('files:Factor-easy'));
75 assert.ok(callbacks.includes('pr:Factor-easy'));
76 assert.ok(callbacks.includes('commits:Factor-easy'));
77 assert.ok(callbacks.includes('status:Factor-easy'));
78 assert.ok(callbacks.includes('menu:repos'));
79 });
80
81 it('pull requests, commits, files and workflow status render source-backed data', async () => {
82 const prView = await menu.getPullRequestsView('Factor-easy');
83 assert.ok(prView.text.includes('#43'));
84 assert.ok(prView.text.includes('Ops: strengthen long-running execution heartbeat rule'));
85
86 const commitsView = await menu.getCommitsView('Factor-easy');
87 assert.ok(commitsView.text.includes('87b25b1'));
88
89 const filesView = await menu.getFilesView('Factor-easy');
90 assert.ok(filesView.text.includes('src'));
91
92 const statusView = await menu.getRepoStatusView('Factor-easy');
93 assert.ok(statusView.text.includes('CI'));
94 assert.ok(statusView.text.includes('main'));
95 });
96
97 it('service, tools and security views do not fabricate measurements or SLA claims', async () => {
98 const serviceView = menu.getServiceStatusView();
99 assert.doesNotMatch(serviceView.text, /100% SLA|Realtime/i);
100
101 const pingView = await menu.renderByCallback('tool:ping');
102 assert.doesNotMatch(pingView.text, /12ms|پایدار است/);
103
104 const securityView = menu.getSecurityView();
105 assert.doesNotMatch(securityView.text, /5000 req\/hr|فعال و ایمن|Fine-grained Personal Access Token/i);
106 });
107
108 it('callback router preserves hierarchical back navigation', async () => {
109 const mainView = await menu.renderByCallback('menu:main');
110 assert.ok(mainView.text.includes('Nexa Dev Bot'));
111
112 const repoView = await menu.renderByCallback('repo:Factor-easy');
113 assert.ok(repoView.text.includes('Factor-easy'));
114
115 const prView = await menu.renderByCallback('pr:Factor-easy');
116 assert.ok(prView.text.includes('Pull Request'));
117
118 const backCallbacks = prView.reply_markup.inline_keyboard.flat().map(b => b.callback_data);
119 assert.ok(backCallbacks.includes('repo:Factor-easy'));
120 });
121 });