Personal Telegram developer console for GitHub
test: cover bot pending input precedence
davoodmehraban89 committed
Oct 3, 2026 at 13:16 UTC
452a646fdca84f31c2bd5bade4966f7d0edfef9b
1 file changed
+36
-1
test/github-workspace-integration.test.js
+36
-1
@@ -1,5 +1,6 @@
1
import test from 'node:test';
2
import assert from 'node:assert/strict';
3
+import { NexaDevBot } from '../src/bot.js';
4
import { PluginRouter } from '../src/core/router.js';
5
import { PluginRegistry } from '../src/core/plugin-registry.js';
6
import { ActionPolicy } from '../src/core/action-policy.js';
@@ -167,7 +168,7 @@ test('oversized multibyte draft input is visibly rejected without mutating the o
168
await plugin.resolveCallback(`wtext:${WORKSPACE_ID}`, { ownerId: OWNER }).execute();
169
const before = workspaces.workspace.draftText;
170
const pending = await workspaces.getPendingInput({ ownerId: OWNER });
170
- const route = plugin.resolveMessage({ pending, text: '😀'.repeat(3000) }, { ownerId: OWNER });
171
+ const route = plugin.resolveMessage({ pending, text: '😀'.repeat(3001) }, { ownerId: OWNER });
172
const view = await route.execute();
173
assert.match(view.text, /12,000|12000|3,000|3000|مجاز|حد/i);
174
assert.equal(workspaces.workspace.draftText, before);
@@ -221,3 +222,37 @@ test('READY rejects no-change, reuses identical material and mints a new intent
222
assert.notEqual(commit3, commit1);
223
assert.deepEqual(github.calls, []);
224
});
225
+
226
+test('bot preserves command precedence and routes raw pending workspace text exactly once', async () => {
227
+ const bot = new NexaDevBot({});
228
+ const calls = [];
229
+ bot.telegram = {
230
+ async sendMessage(chatId, text, replyMarkup) {
231
+ calls.push(['sendMessage', chatId, text, replyMarkup]);
232
+ return { ok: true };
233
+ }
234
+ };
235
+ bot.workspaceStore = {
236
+ isConfigured: () => true,
237
+ async getPendingInput({ ownerId }) {
238
+ calls.push(['getPendingInput', ownerId]);
239
+ return { workspaceId: WORKSPACE_ID, mode: 'draft' };
240
+ }
241
+ };
242
+ bot.router = {
243
+ async dispatchMessage(payload, context) {
244
+ calls.push(['dispatchMessage', structuredClone(payload), structuredClone(context)]);
245
+ return { text: 'workspace accepted', reply_markup: { inline_keyboard: [] } };
246
+ }
247
+ };
248
+
249
+ await bot.handleMessage({ chat: { id: 7 }, from: { id: 42 }, text: '/status' });
250
+ assert.equal(calls.some(call => call[0] === 'getPendingInput'), false);
251
+ assert.equal(calls.some(call => call[0] === 'dispatchMessage'), false);
252
+
253
+ calls.length = 0;
254
+ await bot.handleMessage({ chat: { id: 7 }, from: { id: 42 }, text: ' exact draft text \n' });
255
+ const dispatch = calls.find(call => call[0] === 'dispatchMessage');
256
+ assert.equal(dispatch[1].text, ' exact draft text \n');
257
+ assert.deepEqual(dispatch[2], { isOwner: true, ownerId: OWNER });
258
+});