Skip to content

Commit

Permalink
DEVEXP-524: E2E Voice/Callouts (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
asein-sinch authored Sep 23, 2024
1 parent 5d22da2 commit 4b3a899
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 11 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/run-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ jobs:
token: ${{ secrets.PAT_CI }}
fetch-depth: 0
path: sinch-sdk-mockserver
- name: Build custom Docker image
run: |
cd sinch-sdk-mockserver
docker build -t sinch-sdk-mockserver -f Dockerfile .
- name: Install Docker Compose
run: |
sudo apt-get update
Expand All @@ -44,11 +40,6 @@ jobs:
run: |
cd sinch-sdk-mockserver
docker-compose up -d
- name: Wait for the mock servers to be healthy
run: |
cd sinch-sdk-mockserver
chmod +x ./scripts/healthcheck.sh
./scripts/healthcheck.sh
- name: Create target directories for feature files
run: |
mkdir -p ./packages/fax/tests/e2e/features
Expand All @@ -57,6 +48,7 @@ jobs:
mkdir -p ./packages/elastic-sip-trunking/tests/e2e/features
mkdir -p ./packages/sms/tests/e2e/features
mkdir -p ./packages/verification/tests/e2e/features
mkdir -p ./packages/voice/tests/e2e/features
- name: Copy feature files
run: |
cp sinch-sdk-mockserver/features/fax/*.feature ./packages/fax/tests/e2e/features/
Expand All @@ -65,6 +57,7 @@ jobs:
cp sinch-sdk-mockserver/features/elastic-sip-trunking/*.feature ./packages/elastic-sip-trunking/tests/e2e/features/
cp sinch-sdk-mockserver/features/sms/*.feature ./packages/sms/tests/e2e/features/
cp sinch-sdk-mockserver/features/verification/*.feature ./packages/verification/tests/e2e/features/
cp sinch-sdk-mockserver/features/voice/*.feature ./packages/voice/tests/e2e/features/
- name: Run e2e tests
run: |
yarn install
Expand Down
8 changes: 8 additions & 0 deletions packages/voice/cucumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
default: [
'tests/e2e/features/**/*.feature',
'--require-module ts-node/register',
'--require tests/rest/v1/**/*.steps.ts',
`--format-options '{"snippetInterface": "synchronous"}'`,
].join(' '),
};
3 changes: 2 additions & 1 deletion packages/voice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"scripts": {
"build": "yarn run clean && yarn run compile",
"clean": "rimraf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo",
"compile": "tsc -p tsconfig.build.json && tsc -p tsconfig.tests.json && rimraf dist/tests tsconfig.build.tsbuildinfo"
"compile": "tsc -p tsconfig.build.json && tsc -p tsconfig.tests.json && rimraf dist/tests tsconfig.build.tsbuildinfo",
"test:e2e": "cucumber-js"
},
"dependencies": {
"@sinch/sdk-client": "^1.1.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Destination } from '../destination';
import { ConferenceDtmfOptions } from '../conference-dtmf-options';
import { MusicOnHold } from '../enums';

/**
* The conference callout calls a phone number or a user. When the call is answered, it's connected to a conference room.
Expand Down Expand Up @@ -28,7 +29,7 @@ export interface ConferenceCalloutRequest {
/** The text that will be spoken as a greeting. */
greeting?: string;
/** Means "music-on-hold." It's an optional parameter that specifies what the first participant should listen to while they're alone in the conference, waiting for other participants to join. It can take one of these pre-defined values:<ul><li>`ring` (progress tone)</li><li>`music1` (music file)</li><li>`music2` (music file)</li><li>`music3` (music file)</li></ul></br>If no “music-on-hold” is specified, the user will only hear silence. */
mohClass?: string;
mohClass?: MusicOnHold;
/** Used to input custom data. */
custom?: string;
/** can be either “pstn” for PSTN endpoint or “mxp” for data (app or web) clients. */
Expand Down
121 changes: 121 additions & 0 deletions packages/voice/tests/rest/v1/callouts/callouts.steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import { CalloutsApi, VoiceService, Voice } from '../../../../src';
import { Given, When, Then } from '@cucumber/cucumber';
import * as assert from 'assert';

let calloutsApi: CalloutsApi;
let ttsCallResponse: Voice.CalloutResponse;

Given('the Voice service "Callouts" is available', () => {
const voiceService = new VoiceService({
applicationKey: 'appKey',
applicationSecret: 'appSecret',
voiceHostname: 'http://localhost:3019',
});
calloutsApi = voiceService.callouts;
});

When('I send a request to make a TTS call', async () => {
ttsCallResponse = await calloutsApi.tts({
ttsCalloutRequestBody: {
method: 'ttsCallout',
ttsCallout: {
cli: '+12015555555',
destination: {
type: 'number',
endpoint: '+12017777777',
},
locale: 'en-US',
text: 'Hello, this is a call from Sinch.',
},
},
});
});

Then('the callout response contains the TTS call ID', () => {
assert.equal(ttsCallResponse.callId, '1ce0ffee-ca11-ca11-ca11-abcdef000001');
});

When('I send a request to make a Conference call with the "Callout" service', async () => {
ttsCallResponse = await calloutsApi.conference({
conferenceCalloutRequestBody: {
method: 'conferenceCallout',
conferenceCallout: {
cli: '+12015555555',
destination: {
type: 'number',
endpoint: '+12017777777',
},
conferenceId: 'myConferenceId-E2E',
locale: 'en-US',
greeting: 'Welcome to this conference call.',
mohClass: 'music1',
},
},
});
});

Then('the callout response contains the Conference call ID', () => {
assert.equal(ttsCallResponse.callId, '1ce0ffee-ca11-ca11-ca11-abcdef000002');
});

When('I send a request to make a Custom call', async () => {
ttsCallResponse = await calloutsApi.custom({
customCalloutRequestBody: {
method: 'customCallout',
customCallout: {
cli: '+12015555555',
destination: {
type: 'number',
endpoint: '+12017777777',
},
custom: 'Custom text',
ice: Voice.customCalloutHelper.formatIceResponse(
Voice.iceActionHelper.connectPstn({
number: '+12017777777',
cli: '+12015555555',
}),
Voice.iceInstructionHelper.say('Welcome to Sinch.', 'en-US/male'),
Voice.iceInstructionHelper.startRecording({
destinationUrl: 'To specify',
credentials: 'To specify',
}),
),
ace: Voice.customCalloutHelper.formatAceResponse(
Voice.aceActionHelper.runMenu({
locale: 'Kimberly',
enableVoice: true,
barge: true,
menus: [
{
id: 'main',
mainPrompt: '#tts[Welcome to the main menu. Press 1 to confirm order or 2 to cancel]',
repeatPrompt: '#tts[We didn\'t get your input, please try again]',
timeoutMills: 5000,
options: [
{
dtmf: '1',
action: 'menu(confirm)',
},
{
dtmf: '2',
action: 'return(cancel)',
},
],
},
{
id: 'confirm',
mainPrompt: '#tts[Thank you for confirming your order. Enter your 4-digit PIN.]',
maxDigits: 4,
},
],
}),
),
pie: 'https://callback-server.com/voice',
},
},
});
});

Then('the callout response contains the Custom call ID', () => {
assert.equal(ttsCallResponse.callId, '1ce0ffee-ca11-ca11-ca11-abcdef000003');
});

0 comments on commit 4b3a899

Please sign in to comment.