Files
LangBot/web/tests/unit/wizard-page-bot.test.mjs
T
Hyu fde04e64f6 Merge remote-tracking branch 'origin/master' into dev/4.11.x
# Conflicts:
#	src/langbot/pkg/api/http/controller/groups/pipelines/pipelines.py
#	src/langbot/pkg/api/http/service/bot.py
#	src/langbot/pkg/provider/runners/localagent.py
#	src/langbot/templates/metadata/pipeline/ai.yaml
#	tests/unit_tests/api/service/test_bot_service.py
#	tests/unit_tests/provider/runners/test_difysvapi_runner.py
#	tests/unit_tests/utils/test_safe_regex.py
#	web/src/app/infra/entities/adapter-categories.ts
#	web/src/app/wizard/page.tsx
#	web/src/i18n/locales/en-US.ts
#	web/src/i18n/locales/ja-JP.ts
#	web/src/i18n/locales/zh-Hans.ts
#	web/tests/e2e/plugin-page-auth.spec.ts
2026-08-31 17:17:47 +08:00

73 lines
2.3 KiB
JavaScript

import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
import { fileURLToPath } from 'node:url';
const currentDirectory = path.dirname(fileURLToPath(import.meta.url));
const wizardSource = fs.readFileSync(
path.resolve(currentDirectory, '../../src/app/wizard/page.tsx'),
'utf8',
);
const widgetSource = fs.readFileSync(
path.resolve(
currentDirectory,
'../../../src/langbot/templates/embed/widget.js',
),
'utf8',
);
test('shows the test-only notice only when the wizard opts in', () => {
assert.match(
wizardSource,
/widget\.js\?preview=wizard&v=\$\{Date\.now\(\)\}/,
);
assert.match(wizardSource, /script\.dataset\.testNotice = testNotice/);
assert.match(
wizardSource,
/testNotice=\{t\('wizard\.botConfig\.pageBotTestNotice'\)\}/,
);
assert.match(widgetSource, /getAttribute\("data-test-notice"\)/);
assert.match(widgetSource, /if \(scriptTestNotice\)/);
assert.match(widgetSource, /testNotice\.textContent = scriptTestNotice/);
});
test('keeps the 4.11 AgentRunner marketplace installation flow', () => {
assert.match(wizardSource, /RUNNER_COMPONENT_FILTER = 'AgentRunner'/);
assert.match(wizardSource, /installPluginFromMarketplace\(/);
assert.match(wizardSource, /runnerPluginPrefix\(plugin\)/);
assert.match(wizardSource, /registrationDeadline/);
});
test('requires an observed message only for the message-reply scenario', () => {
assert.match(
wizardSource,
/selectedScenario !== 'message_reply' \|\| messageReceived/,
);
assert.match(
wizardSource,
/requiresMessageVerification=\{selectedScenario === 'message_reply'\}/,
);
assert.match(wizardSource, /onMessageReceived=\{handleMessageReceived\}/);
});
test('warns local-account users after the bot receives an IM message', () => {
assert.match(
wizardSource,
/messageReceived && userInfo\?\.account_type !== 'space'/,
);
assert.match(
wizardSource,
/wizard\.botConfig\.messageReceivedLocalAccountWarning/,
);
assert.match(wizardSource, /<AlertTriangle className="size-3 text-white"/);
});
test('offers the HTTP Bot test through the signed inbound API', () => {
assert.match(
wizardSource,
/testHttpBotInbound\(createdBotUuid, testMessage\.trim\(\)\)/,
);
assert.match(wizardSource, /wizard\.botConfig\.sendHttpTest/);
});