获取 DialogSet.add():测试时添加的对话框无效

bil*_*ton 3 mocha.js node.js botframework

我正在尝试为我的机器人对话框构建一些测试。我将相同的测试代码(和修改后的测试数据)与两个具有相同对话框名称的不同机器人一起使用。因此,两个机器人的 test.js 文件是相同的。但是,当我尝试在第二个机器人上通过 Mocha 运行我的测试时,我得到了一个Error: DialogSet.add(): Invalid dialog being added.每次测试的消息。我的第一个机器人不会发生这种情况。我什至尝试将第二个机器人中的对话框文件替换为(工作)中的对话框文件,但我仍然遇到相同的错误。因此,我在机器人之间找不到任何不同之处。我什至用第一个机器人的文件替换了所有有问题的文件(测试、测试数据/对话和对话框本身),但仍然出现相同的错误。最后,机器人之间的所有 botbuilder 包和其他依赖项都是相同的版本。我在这里不知所措......有人有任何想法吗?

这是正在调用的对话框。我省略了实际的对话框步骤,但这应该与问题无关,因为所有的对话框添加活动都发生在构造函数中。

const { TextPrompt, ChoicePrompt, ConfirmPrompt, ChoiceFactory, ComponentDialog, WaterfallDialog, DialogSet, DialogTurnStatus } = require('botbuilder-dialogs');
const { VistaServiceHelper } = require('../helpers/vistaServiceHelper');
const { TrackingServiceHelper } = require('../helpers/trackingServiceHelper');
const { CosmosDbStorage } = require('botbuilder-azure');

const LINE_PROMPT = 'linePrompt';
const ORDER_PROMPT = 'orderPrompt';
const CRITERIA_PROMPT = 'criteriaPrompt';
const SEARCH_CRITERIA = ['GO', 'PO'];
const WATERFALL_DIALOG = 'waterfallDialog';
const CONFIRM_PROMPT = 'confirmPrompt';

// Static texts
const escalateMessage = `Escalation message here`

const msDay = 86400000;

class viewOrderDialog extends ComponentDialog {
    constructor(dialogId, userDialogStateAccessor, userState) {
        super(dialogId);

        this.addDialog(new ChoicePrompt(CRITERIA_PROMPT));
        this.addDialog(new TextPrompt(ORDER_PROMPT));
        this.addDialog(new TextPrompt(LINE_PROMPT, this.validateLineNumber));
        this.addDialog(new ConfirmPrompt(CONFIRM_PROMPT));
        this.addDialog(new WaterfallDialog(WATERFALL_DIALOG, [
            this.requestOrderNumber.bind(this),
            this.selectSearchCriteria.bind(this),
            this.displayLineItems.bind(this),
            this.displayLineStatus.bind(this),
            this.loopStep.bind(this)
        ]));

        this.initialDialogId = WATERFALL_DIALOG;

        this.integrationLog = new CosmosDbStorage({
            serviceEndpoint: process.env.ACTUAL_SERVICE_ENDPOINT,
            authKey: process.env.ACTUAL_AUTH_KEY,
            databaseId: process.env.DATABASE,
            collectionId: 'integration-logs'
        });

        this.queryData = {};

    } // End constructor
Run Code Online (Sandbox Code Playgroud)

bil*_*ton 5

我能够通过删除项目的 node_modules 文件夹中的 botbuilder-testing 文件夹并重新运行来解决这个问题npm install botbuilder-testing(即使我已经在 package.json 中确认了版本,并且 package-lock.json 显示了最新版本并运行了npm installnpm update)。

看来这确实源于某种版本控制问题,无论出于何种原因,只有完全删除文件夹并重新安装才能修复它。