Skip to content

Commit

Permalink
Set WaterfallStepContext.Parent correctly (#2728)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricDahlvang committed Aug 19, 2020
1 parent 339b6ec commit 8e006ec
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 60 deletions.
2 changes: 1 addition & 1 deletion libraries/botbuilder-dialogs/src/waterfallStepContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class WaterfallStepContext<O extends object = {}> extends DialogContext {
public constructor(dc: DialogContext, info: WaterfallStepInfo<O>) {
super(dc.dialogs, dc, { dialogStack: dc.stack });
this._info = info;
this.parent = dc;
this.parent = dc.parent;
}

/**
Expand Down
59 changes: 0 additions & 59 deletions libraries/botbuilder-dialogs/tests/waterfallDialog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,63 +634,4 @@ describe('WaterfallDialog', function () {
}, DialogReason.cancelCalled);
assert(trackEventCalled, 'trackEvent was never called.');
});

it('should waterfall parent be equal to Component Dialog.', (done) => {
const conversationState = new ConversationState(new MemoryStorage());
const dialogState = conversationState.createProperty('dialog');

const waterfall = new WaterfallDialog('waterfall', [
step => ({ status: DialogTurnStatus.complete, result: step })
]);

const component = new ComponentDialog('composite');
component.addDialog(waterfall);

const dialogs = new DialogSet(dialogState);
dialogs.add(component);

const adapter = new TestAdapter(async turnContext => {
const dc = await dialogs.createContext(turnContext);

const results = await dc.beginDialog('composite');

if (results.status === DialogTurnStatus.complete) {
const waterfallParent = results.result.parent.parent;

assert.strictEqual(waterfallParent.dialogs.dialogs['composite'], component, 'WaterfallDialog "waterfall" parent should be equal to ComponentDialog "composite".');
done();
} else {
done(new Error('status results not completed'));
}
});

adapter.send('Hi');
});

it('should waterfall parent be equal to Dialog Context.', (done) => {
const conversationState = new ConversationState(new MemoryStorage());
const dialogState = conversationState.createProperty('dialog');

const waterfall = new WaterfallDialog('waterfall', [
step => ({ status: DialogTurnStatus.complete, result: step })
]);

const dialogs = new DialogSet(dialogState);
dialogs.add(waterfall);

const adapter = new TestAdapter(async turnContext => {
const dc = await dialogs.createContext(turnContext);
const results = await dc.beginDialog('waterfall');

if (results.status === DialogTurnStatus.complete) {
assert.deepStrictEqual(results.result.parent, dc, 'waterfall parent should be equal to Dialog Context.');
done();
} else {
done(new Error('status results not completed'));
}
});

adapter.send('Hi');
});

});

0 comments on commit 8e006ec

Please sign in to comment.