UNPKG

@makingchatbots/genesys-cloud-chatbot-tester-cli

Version:

[![npm](https://img.shields.io/npm/v/@makingchatbots/genesys-cloud-chatbot-tester-cli)](https://www.npmjs.com/package/@makingchatbots/genesys-cloud-chatbot-tester-cli) [![Follow me on LinkedIn for updates](https://img.shields.io/badge/Follow%20for%20updat

26 lines (25 loc) 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseScenarioStep = parseScenarioStep; exports.extractScenarios = extractScenarios; function parseScenarioStep(step) { if ('say' in step) { return async (convo) => await convo.sendText(step.say); } if ('waitForReplyContaining' in step) { return async (convo, context) => await convo.waitForResponseWithTextContaining(step.waitForReplyContaining, { timeoutInSeconds: context.timeoutInSeconds, }); } if ('waitForReplyMatching' in step) { return async (convo, context) => await convo.waitForResponseWithTextMatchingPattern(new RegExp(step.waitForReplyMatching, 'im'), { timeoutInSeconds: context.timeoutInSeconds }); } throw new Error(`Unsupported step ${step}`); } function extractScenarios(testScript, sessionConfig) { return Object.entries(testScript.scenarios ?? []).map(([scenarioName, actions]) => ({ sessionConfig, name: scenarioName, steps: actions.map(parseScenarioStep), })); }