Personal Telegram developer console for GitHub
test: capture live Issues permission and empty Releases UX
davoodmehraban89 committed
Oct 3, 2026 at 10:53 UTC
ea2446c9f980a4012869fc355136d03e318f2366
1 file changed
+51
test/github-live-findings.test.js
new
+51
@@ -0,0 +1,51 @@
1
+import test from 'node:test';
2
+import assert from 'node:assert/strict';
3
+import { NexaDevBot } from '../src/bot.js';
4
+import { createGitHubPlugin } from '../src/plugins/github/plugin.js';
5
+
6
+test('Issues 403 tells the owner the exact fine-grained permission required', async () => {
7
+ const bot = new NexaDevBot({
8
+ TELEGRAM_BOT_TOKEN: 'telegram-test-token',
9
+ TELEGRAM_WEBHOOK_SECRET: 'webhook-test-secret',
10
+ GITHUB_TOKEN: 'github-test-token'
11
+ });
12
+ const edits = [];
13
+ bot.telegram.answerCallbackQuery = async () => ({ ok: true });
14
+ bot.telegram.editMessageText = async (chatId, messageId, text, replyMarkup) => {
15
+ edits.push({ chatId, messageId, text, replyMarkup });
16
+ return { ok: true };
17
+ };
18
+ bot.router.dispatchCallback = async () => {
19
+ throw new Error('GitHub issues failed: 403 Resource not accessible by personal access token');
20
+ };
21
+
22
+ const result = await bot.handleCallbackQuery({
23
+ id: 'cb-issues-permission',
24
+ data: 'issues:123',
25
+ from: { id: 42 },
26
+ message: { chat: { id: 42 }, message_id: 99 }
27
+ });
28
+
29
+ assert.equal(result.ok, false);
30
+ assert.equal(result.edited, true);
31
+ assert.equal(edits.length, 1);
32
+ assert.match(edits[0].text, /Issues/i);
33
+ assert.match(edits[0].text, /Read/i);
34
+ assert.match(edits[0].text, /fine-grained|Fine-grained/i);
35
+});
36
+
37
+test('empty Releases view clearly states that GitHub has no releases for the repository', async () => {
38
+ const github = {
39
+ async getRepository(id) { return { id: String(id), name: 'nexa-dev-bot', defaultBranch: 'main' }; },
40
+ async listReleases() { return []; }
41
+ };
42
+ const menu = {
43
+ async getReposListView() { return { text: 'repos', reply_markup: { inline_keyboard: [] } }; },
44
+ async renderByCallback() { return { text: 'menu', reply_markup: { inline_keyboard: [] } }; }
45
+ };
46
+ const plugin = createGitHubPlugin({ github, menu });
47
+ const view = await plugin.resolveCallback('releases:123').execute();
48
+
49
+ assert.match(view.text, /هیچ Release منتشرشدهای برای این مخزن در GitHub وجود ندارد/);
50
+ assert.doesNotMatch(view.text, /Releaseی یافت نشد/);
51
+});