Skip to content

Commit

Permalink
DEVEXP-507: E2E ElasticSipTrunking/CountryPermissions (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
asein-sinch authored Jul 26, 2024
1 parent f0e172c commit 27bc7ad
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/run-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ jobs:
mkdir -p ./packages/fax/tests/e2e/features
mkdir -p ./packages/numbers/tests/e2e/features
mkdir -p ./packages/conversation/tests/e2e/features
mkdir -p ./packages/elastic-sip-trunking/tests/e2e/features
- name: Copy feature files
run: |
cp sinch-sdk-mockserver/features/fax/*.feature ./packages/fax/tests/e2e/features/
cp sinch-sdk-mockserver/features/numbers/*.feature ./packages/numbers/tests/e2e/features/
cp sinch-sdk-mockserver/features/conversation/*.feature ./packages/conversation/tests/e2e/features/
cp sinch-sdk-mockserver/features/elastic-sip-trunking/*.feature ./packages/elastic-sip-trunking/tests/e2e/features/
- name: Run e2e tests
run: |
yarn install
Expand Down
8 changes: 8 additions & 0 deletions packages/elastic-sip-trunking/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/elastic-sip-trunking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { CountryPermissionsApi, ElasticSipTrunkingService, ElasticSipTrunking } from '../../../../src';
import { Given, Then, When } from '@cucumber/cucumber';
import assert from 'assert';

let countryPermissionsApi: CountryPermissionsApi;
let countryPermissionsListResponse: ElasticSipTrunking.ListCountryPermissionsResponse;
let countryPermissions: ElasticSipTrunking.CountryPermission;

Given('the Elastic SIP Trunking service "Country Permissions" is available', function () {
const elasticSipTrunkingService = new ElasticSipTrunkingService({
projectId: 'tinyfrog-jump-high-over-lilypadbasin',
keyId: 'keyId',
keySecret: 'keySecret',
authHostname: 'http://localhost:3011',
elasticSipTrunkingHostname: 'http://localhost:3016',
});
countryPermissionsApi = elasticSipTrunkingService.countryPermissions;
});

When('I send a request to list the EST countries permissions', async () => {
countryPermissionsListResponse = await countryPermissionsApi.list({});
});

Then('the response contains the list of EST countries permissions', () => {
assert.ok(countryPermissionsListResponse.countryPermissions);
assert.equal(countryPermissionsListResponse.countryPermissions.length, 51);
});

When('I send a request to retrieve an EST country\'s permissions', async () => {
countryPermissions = await countryPermissionsApi.get({
isoCode: 'SE',
});
});

Then('the response contains the EST country\'s permissions details', () => {
assert.equal(countryPermissions.isoCode, 'SE');
assert.equal(countryPermissions.name, 'Sweden');
assert.equal(countryPermissions.continent, 'Europe');
assert.deepEqual(countryPermissions.countryDialingCodes, ['+46']);
assert.equal(countryPermissions.enabled, false);
});

When('I send a request to update an EST country\'s permissions', async () => {
countryPermissions = await countryPermissionsApi.update({
isoCode: 'SE',
updateCountryPermissionRequestBody: {
enabled: true,
},
});
});

Then('the response contains the EST country\'s permissions details with updated data', () => {
assert.equal(countryPermissions.isoCode, 'SE');
assert.equal(countryPermissions.name, 'Sweden');
assert.equal(countryPermissions.continent, 'Europe');
assert.deepEqual(countryPermissions.countryDialingCodes, ['+46']);
assert.equal(countryPermissions.enabled, true);
});

0 comments on commit 27bc7ad

Please sign in to comment.