Getting DialogSet.add(): Invalid dialog being added when testing

…衆ロ難τιáo~ 提交于 2020-01-06 05:47:11

问题


I'm trying to build some tests for my bot dialogs. I'm using the same test code (and modified test data) with two different bots with the identical dialog names. As such, the test.js file is the same for both bots. However, when I try to run my tests via Mocha on the second bot, I am getting an Error: DialogSet.add(): Invalid dialog being added. message for each test. This does not happen with my first bot. I even tried replacing the dialog file in the second bot with the one from the (working) first, and I still got the same error. As such I can't find anything different between the bots. I even replaced all of the files in question (the test, the test data/conversation, and the dialog itself) with the files from the first bot and still got the same error. Lastly, all botbuilder packages and other dependencies are the same version between the bots. I'm at a loss here...anyone have any ideas?

Here is the dialog that is being called. I left out the actual dialog steps but that shouldn't be relevant to the issue since all of the Dialog add activity happens in the constructor.

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

回答1:


I was able to fix this by deleting the botbuilder-testing folder inside the project's node_modules folder and rerunning npm install botbuilder-testing (even though I had already confirmed version in package.json and package-lock.json were showing latest version and had run npm install and npm update).

It appears this did stem from some sort of versioning issue and for whatever reason, only completely deleting the folder and reinstalling fixed it.



来源:https://stackoverflow.com/questions/58440065/getting-dialogset-add-invalid-dialog-being-added-when-testing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!