-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49f821e
commit e50d061
Showing
15 changed files
with
665 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,7 @@ | |
"ignoreRegExpLiterals": true, | ||
"ignorePattern": "^import.+|test" | ||
} | ||
] | ||
], | ||
"new-cap": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Build and test Sinch Node.js SDK | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [18.x, 20.x] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: yarn install | ||
- run: npx eslint "packages/**/src/**/*.ts" | ||
- run: npx eslint "packages/**/tests/**/*.ts" | ||
- run: yarn run build | ||
- run: yarn run test | ||
|
||
# Start the mock server | ||
- name: Start the mock server | ||
run: | | ||
git clone https://github.com/sinch/doppelganger.git sinch-sdk-mockserver | ||
cd sinch-sdk-mockserver | ||
git checkout upgrade-to-typescript | ||
yarn install | ||
yarn compile | ||
AUTH_PORT=8020 NUMBERS_PORT=8021 SMS_PORT=8022 CONVERSATION_PORT=8023 VERIFICATION_PORT=8024 VOICE_PORT=8025 FAX_PORT=8026 node --experimental-specifier-resolution=node dist/index.js | ||
# Wait for mock server to start | ||
- name: Wait for Mock Server | ||
run: sleep 15 | ||
|
||
# Run tests | ||
- run: yarn run e2e | ||
|
||
# Stop mock server after tests | ||
- name: Stop Mock Server | ||
run: | | ||
cd mockserver | ||
pkill -f "node --experimental-specifier-resolution=node dist/index.js" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-e2e/features/step-definitions/**/*.ts', | ||
`--format-options '{"snippetInterface": "synchronous"}'`, | ||
].join(' '), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Feature: [Fax][Faxes] | ||
E2E test for Fax/Faxes API | ||
|
||
Scenario: [Send] send a fax | ||
Given the Fax service is available | ||
When I send a request to send a fax | ||
Then the response contains a fax object | ||
|
||
Scenario: [Get] retrieve a fax | ||
Given the Fax service is available | ||
When I send a request to retrieve a fax | ||
Then the response contains a fax object | ||
|
||
Scenario: [List] lists faxes | ||
Given the Fax service is available | ||
When I send a request to list faxes | ||
Then the response contains "2" faxes | ||
|
||
Scenario: [List] lists all faxes | ||
Given the Fax service is available | ||
When I send a request to list all the faxes | ||
Then the faxes list contains "3" faxes | ||
|
||
Scenario: [DownloadContent] download a fax content | ||
Given the Fax service is available | ||
When I send a request to download a fax content as PDF | ||
Then the response contains a PDF document | ||
|
||
Scenario: [DeleteContent] delete a fax content | ||
Given the Fax service is available | ||
When I send a request to delete a fax content on the server | ||
Then the response contains no data |
80 changes: 80 additions & 0 deletions
80
packages/fax/tests-e2e/features/step-definitions/faxes.steps.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { Given, When, Then } from '@cucumber/cucumber'; | ||
import { Fax, FaxService } from '../../../src'; | ||
import { FileBuffer, PageResult } from '@sinch/sdk-client'; | ||
import * as assert from 'assert'; | ||
|
||
let faxService: FaxService; | ||
let listResponse: PageResult<Fax>; | ||
const faxList: Fax[] = []; | ||
let fax: Fax; | ||
let fileBuffer: FileBuffer; | ||
let deleteContentResponse: void; | ||
|
||
Given('the Fax service is available', function () { | ||
faxService = new FaxService({ | ||
projectId: 'projectId', | ||
keyId: 'keyId', | ||
keySecret: 'keySecret', | ||
authBaseUrl: 'http://localhost:5039', | ||
}); | ||
faxService.setBasePath('http://localhost:5045'); | ||
}); | ||
|
||
When('I send a request to list faxes', async function () { | ||
listResponse = await faxService.faxes.list({}); | ||
}); | ||
|
||
When('I send a request to list all the faxes', async function () { | ||
for await (const fax of faxService.faxes.list({})) { | ||
faxList.push(fax); | ||
} | ||
}); | ||
|
||
When('I send a request to send a fax', async function () { | ||
fax = await faxService.faxes.send({ | ||
sendFaxRequestBody: { | ||
to: '+1234567890', | ||
contentUrl: 'https://developers.sinch.com/fax/fax.pdf', | ||
}, | ||
}); | ||
}); | ||
|
||
When('I send a request to retrieve a fax', async function () { | ||
fax = await faxService.faxes.get({ | ||
id: 'FAXID', | ||
}); | ||
}); | ||
|
||
When('I send a request to download a fax content as PDF', async function () { | ||
fileBuffer = await faxService.faxes.downloadContent({ | ||
id: 'FAXID', | ||
}); | ||
}); | ||
|
||
When('I send a request to delete a fax content on the server', async function () { | ||
deleteContentResponse = await faxService.faxes.deleteContent({ | ||
id: 'FAXID', | ||
}); | ||
}); | ||
|
||
Then('the response contains {string} faxes', function (expectedAnswer: string) { | ||
const expectedFaxes = parseInt(expectedAnswer, 10); | ||
assert.strictEqual(listResponse.data.length, expectedFaxes); | ||
}); | ||
|
||
Then('the faxes list contains {string} faxes', function (expectedAnswer: string) { | ||
const expectedFaxes = parseInt(expectedAnswer, 10); | ||
assert.strictEqual(faxList.length, expectedFaxes); | ||
}); | ||
|
||
Then('the response contains a fax object', function () { | ||
assert.ok(fax.id); | ||
}); | ||
|
||
Then('the response contains a PDF document', function () { | ||
assert.ok(fileBuffer.fileName); | ||
}); | ||
|
||
Then('the response contains no data', function () { | ||
assert.deepEqual(deleteContentResponse, {}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.