Personal Telegram developer console for GitHub
test: require source-backed menu status and metadata
davoodmehraban89 committed
Oct 2, 2026 at 22:14 UTC
09d846eb98508c1694131d4ad48c6a26c2b8a53f
1 file changed
+76
-68
test/menu.test.js
+76
-68
@@ -1,20 +1,52 @@
1
import { describe, it } from 'node:test';
2
-import assert from 'node:assert';
3
-import { GitHubService } from '../src/github.js';
2
+import assert from 'node:assert/strict';
3
import { MenuManager } from '../src/menu.js';
4
6
-describe('Nexa Dev Bot - MenuManager & State Navigation', () => {
7
- const github = new GitHubService();
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
10
- it('1. Main Menu has correct sections and buttons', () => {
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'));
13
- assert.ok(view.reply_markup?.inline_keyboard);
14
-
15
- const buttons = view.reply_markup.inline_keyboard.flat();
16
- const callbacks = buttons.map(b => b.callback_data);
17
-
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'));
@@ -22,92 +54,68 @@ describe('Nexa Dev Bot - MenuManager & State Navigation', () => {
54
assert.ok(callbacks.includes('menu:security'));
55
});
56
25
- it('2. Repositories list displays projects and has back button to main', async () => {
57
+ it('repositories list renders discovered projects and a back button', async () => {
58
const view = await menu.getReposListView();
59
assert.ok(view.text.includes('فهرست مخزنها'));
28
- assert.ok(view.text.includes('Nexa Dev > 📁 مخزنها'));
29
-
60
const buttons = view.reply_markup.inline_keyboard.flat();
31
- const btnTexts = buttons.map(b => b.text);
32
- const callbacks = buttons.map(b => b.callback_data);
33
-
34
- assert.ok(btnTexts.some(t => t.includes('Factor-easy')));
35
- assert.ok(btnTexts.some(t => t.includes('Finora-Invoice')));
36
- assert.ok(callbacks.includes('repo:Factor-easy'));
37
- assert.ok(callbacks.includes('menu:main'), 'Should have back button to main menu');
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
40
- it('3. Repository detail menu has sub-operations and back button to repos list', async () => {
66
+ it('repository detail is based on live repository metadata', async () => {
67
const view = await menu.getRepoDetailView('Factor-easy');
42
- assert.ok(view.text.includes('پروژه: Factor-easy'));
43
- assert.ok(view.text.includes('Nexa Dev > 📁 مخزنها > Factor-easy'));
44
-
45
- const buttons = view.reply_markup.inline_keyboard.flat();
46
- const callbacks = buttons.map(b => b.callback_data);
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'));
52
- assert.ok(callbacks.includes('menu:repos'), 'Back button must return to repos list');
78
+ assert.ok(callbacks.includes('menu:repos'));
79
});
80
55
- it('4. Pull Requests view renders all target PRs with back to repo detail', async () => {
56
- const view = await menu.getPullRequestsView('Factor-easy');
57
- assert.ok(view.text.includes('Pull Requestهای پروژه Factor-easy'));
58
- assert.ok(view.text.includes('#43'));
59
- assert.ok(view.text.includes('Ops: strengthen long-running execution heartbeat rule'));
60
- assert.ok(view.text.includes('#40'));
61
- assert.ok(view.text.includes('#39'));
62
- assert.ok(view.text.includes('#28'));
63
- assert.ok(view.text.includes('#6'));
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
65
- const buttons = view.reply_markup.inline_keyboard.flat();
66
- const callbacks = buttons.map(b => b.callback_data);
67
- assert.ok(callbacks.includes('repo:Factor-easy'), 'Back button must return to repo detail');
68
- });
86
+ const commitsView = await menu.getCommitsView('Factor-easy');
87
+ assert.ok(commitsView.text.includes('87b25b1'));
88
70
- it('5. Commits view displays recent commits and back button', async () => {
71
- const view = await menu.getCommitsView('Factor-easy');
72
- assert.ok(view.text.includes('آخرین Commitهای پروژه Factor-easy'));
73
- assert.ok(view.text.includes('87b25b1'));
89
+ const filesView = await menu.getFilesView('Factor-easy');
90
+ assert.ok(filesView.text.includes('src'));
91
75
- const callbacks = view.reply_markup.inline_keyboard.flat().map(b => b.callback_data);
76
- assert.ok(callbacks.includes('repo:Factor-easy'));
92
+ const statusView = await menu.getRepoStatusView('Factor-easy');
93
+ assert.ok(statusView.text.includes('CI'));
94
+ assert.ok(statusView.text.includes('main'));
95
});
96
79
- it('6. Files view displays directory structure and back button', async () => {
80
- const view = await menu.getFilesView('Factor-easy');
81
- assert.ok(view.text.includes('ساختار فایلهای پروژه Factor-easy'));
82
- assert.ok(view.text.includes('src'));
83
-
84
- const callbacks = view.reply_markup.inline_keyboard.flat().map(b => b.callback_data);
85
- assert.ok(callbacks.includes('repo:Factor-easy'));
86
- });
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
88
- it('7. Service status view displays infrastructure SLA and back button', () => {
89
- const view = menu.getServiceStatusView();
90
- assert.ok(view.text.includes('وضعیت سیستم و سرویسهای فعال'));
91
- assert.ok(view.text.includes('Cloudflare Worker'));
101
+ const pingView = await menu.renderByCallback('tool:ping');
102
+ assert.doesNotMatch(pingView.text, /12ms|پایدار است/);
103
93
- const callbacks = view.reply_markup.inline_keyboard.flat().map(b => b.callback_data);
94
- assert.ok(callbacks.includes('menu:main'));
104
+ const securityView = menu.getSecurityView();
105
+ assert.doesNotMatch(securityView.text, /5000 req\/hr|فعال و ایمن|Fine-grained Personal Access Token/i);
106
});
107
97
- it('8. renderByCallback handles dynamic routing and navigation hierarchy', async () => {
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
101
- const reposView = await menu.renderByCallback('menu:repos');
102
- assert.ok(reposView.text.includes('فهرست مخزنها'));
103
-
112
const repoView = await menu.renderByCallback('repo:Factor-easy');
105
- assert.ok(repoView.text.includes('پروژه: Factor-easy'));
113
+ assert.ok(repoView.text.includes('Factor-easy'));
114
115
const prView = await menu.renderByCallback('pr:Factor-easy');
108
- assert.ok(prView.text.includes('Pull Requestهای پروژه Factor-easy'));
116
+ assert.ok(prView.text.includes('Pull Request'));
117
110
- const pingView = await menu.renderByCallback('tool:ping');
111
- assert.ok(pingView.text.includes('Pong!'));
118
+ const backCallbacks = prView.reply_markup.inline_keyboard.flat().map(b => b.callback_data);
119
+ assert.ok(backCallbacks.includes('repo:Factor-easy'));
120
});
121
});