Skip to content

Commit 7594f4a

Browse files
author
Jonathan Wenger
committed
Add test and pipeline updates.
1 parent d11cf90 commit 7594f4a

File tree

4 files changed

+88
-14
lines changed

4 files changed

+88
-14
lines changed

.github/workflows/npm-publish.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/setup-node@v3
14+
with:
15+
node-version: 20
16+
registry-url: "https://registry.npmjs.org"
17+
- uses: actions/checkout@v3
1418
- name: Set env
1519
run: |
1620
echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
@@ -21,33 +25,42 @@ jobs:
2125
- run: npm ci
2226
- run: npm run build
2327
# Step to retrieve the bearer token
24-
- name: Retrieve bearer token
25-
id: get_bearer_token
28+
- name: Retrieve bearer token for EInvoicing
29+
id: get_bearer_token_einvoicing
2630
run: |
2731
response=$(curl -X POST ${{secrets.OKTA_ACCESS_TOKEN_URL}}/connect/token \
2832
-H "Content-Type: application/x-www-form-urlencoded" \
2933
-d "grant_type=client_credentials&client_id=${{secrets.OKTA_CLIENT_ID}}&client_secret=${{secrets.OKTA_CLIENT_SECRET}}")
3034
token=$(echo $response | jq -r '.access_token')
31-
echo "BEARER_TOKEN=${token}" >> $GITHUB_ENV
35+
echo "BEARER_TOKEN_EINVOICING=${token}" >> $GITHUB_ENV
36+
37+
- name: Retrieve bearer token for A1099
38+
id: get_bearer_token_a1099
39+
run: |
40+
response=$(curl -X POST ${{secrets.AI_SBX_URL}}/connect/token \
41+
-H "Content-Type: application/x-www-form-urlencoded" \
42+
-d "grant_type=client_credentials&client_id=${{secrets.AI_CLIENT_ID_A1099}}&client_secret=${{secrets.AI_CLIENT_SECRET_A1099}}")
43+
token=$(echo $response | jq -r '.access_token')
44+
echo "BEARER_TOKEN_A1099=${token}" >> $GITHUB_ENV
3245
3346
# Use the bearer token as an environment variable in the npm test command
3447
- name: Run npm test with bearer token
3548
run: npm run test
3649
env:
37-
BEARER_TOKEN: ${{ env.BEARER_TOKEN }}
38-
- uses: actions/setup-node@v2
39-
with:
40-
node-version: 16
41-
registry-url: "https://registry.npmjs.org"
50+
BEARER_TOKEN_EINVOICING: ${{ env.BEARER_TOKEN_EINVOICING }}
51+
BEARER_TOKEN_A1099: ${{ env.BEARER_TOKEN_A1099 }}
52+
4253
- name: Update package.json version
4354
run: |
4455
jq --arg version "$VERSION" '.version = $version' package.json > temp.json && mv temp.json package.json
56+
4557
- name: Update resources
4658
uses: test-room-7/action-update-file@v1
4759
with:
4860
file-path: package.json
4961
commit-msg: Commit npm package version
5062
github-token: ${{ secrets.GITHUB_TOKEN }}
63+
5164
- run: cp ./README.md ./dist/README.md
5265
- run: cp ./package.json ./dist/package.json
5366
- run: npm publish ./dist

.github/workflows/test.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,23 @@ jobs:
2323
run: npm ci --loglevel=silly
2424

2525
# Step to retrieve the bearer token
26-
- name: Retrieve bearer token
27-
id: get_bearer_token
26+
- name: Retrieve bearer token for EInvoicing
27+
id: get_bearer_token_einvoicing
2828
run: |
2929
response=$(curl -X POST ${{secrets.OKTA_ACCESS_TOKEN_URL}}/connect/token \
3030
-H "Content-Type: application/x-www-form-urlencoded" \
3131
-d "grant_type=client_credentials&client_id=${{secrets.OKTA_CLIENT_ID}}&client_secret=${{secrets.OKTA_CLIENT_SECRET}}")
3232
token=$(echo $response | jq -r '.access_token')
33-
echo "BEARER_TOKEN=${token}" >> $GITHUB_ENV
33+
echo "BEARER_TOKEN_EINVOICING=${token}" >> $GITHUB_ENV
34+
35+
- name: Retrieve bearer token for A1099
36+
id: get_bearer_token_a1099
37+
run: |
38+
response=$(curl -X POST ${{secrets.AI_SBX_URL}}/connect/token \
39+
-H "Content-Type: application/x-www-form-urlencoded" \
40+
-d "grant_type=client_credentials&client_id=${{secrets.AI_CLIENT_ID_A1099}}&client_secret=${{secrets.AI_CLIENT_SECRET_A1099}}")
41+
token=$(echo $response | jq -r '.access_token')
42+
echo "BEARER_TOKEN_A1099=${token}" >> $GITHUB_ENV
3443
3544
- name: Build
3645
run: npm run build
@@ -39,4 +48,5 @@ jobs:
3948
- name: Run npm test with bearer token
4049
run: npm test
4150
env:
42-
BEARER_TOKEN: ${{ env.BEARER_TOKEN }}
51+
BEARER_TOKEN_EINVOICING: ${{ env.BEARER_TOKEN_EINVOICING }}
52+
BEARER_TOKEN_A1099: ${{ env.BEARER_TOKEN_A1099 }}

tests/a1099/index.spec.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import "dotenv/config";
2+
import { Runtime } from "../../src/index";
3+
import { AvaTaxEnvironment, Configuration } from "../../src/runtime";
4+
import { Issuers1099Api, CompaniesW9Api, Forms1099Api, FormsW9Api } from "../../src/apis/A1099/V2";
5+
import { ApiClient } from "../../src/runtime";
6+
7+
const configParams: Runtime.ConfigurationParameters = {
8+
appName: "asv-sdk-test-app",
9+
appVersion: "1.0",
10+
environment: AvaTaxEnvironment.QA,
11+
machineName: "test-machine",
12+
timeout: 3000,
13+
bearerToken: process.env.BEARER_TOKEN_A1099,
14+
};
15+
16+
describe("A1099 API", () => {
17+
const config = new Configuration(configParams);
18+
19+
it("should retrieve a list of issuers", async () => {
20+
const runtime = new ApiClient(config);
21+
const api = new Issuers1099Api(runtime);
22+
const result = await api.getIssuers({ $top: 10, $skip: 0, count: true, countOnly: false, xCorrelationId: "2bbbed41-2466-4cf6-9cca-a3258bdc8eba" });
23+
expect(result).toBeDefined();
24+
expect(result.value).toBeDefined();
25+
});
26+
27+
it("should retrieve a list of companies", async () => {
28+
const runtime = new ApiClient(config);
29+
const api = new CompaniesW9Api(runtime);
30+
const result = await api.getCompanies({ $top: 10, $skip: 0, count: true, countOnly: false, xCorrelationId: "2bbbed41-2466-4cf6-9cca-a3258bdc8eba" });
31+
expect(result).toBeDefined();
32+
expect(result.value).toBeDefined();
33+
});
34+
35+
it("should list 1099 forms", async () => {
36+
const runtime = new ApiClient(config);
37+
const api = new Forms1099Api(runtime);
38+
const result = await api.list1099Forms({ $top: 10, $skip: 0, xCorrelationId: "2bbbed41-2466-4cf6-9cca-a3258bdc8eba" });
39+
expect(result).toBeDefined();
40+
expect(result.data).toBeDefined();
41+
});
42+
43+
// Uncomment when ready to test W9 forms
44+
// it("should list W9 forms", async () => {
45+
// const runtime = new ApiClient(config);
46+
// const api = new FormsW9Api(runtime);
47+
// const result = await api.listW9Forms({ $top: 10, $skip: 0, $count: true });
48+
// expect(result).toBeDefined();
49+
// expect(result.value).toBeDefined();
50+
// });
51+
});

tests/einvoicing/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const configParams: Runtime.ConfigurationParameters = {
1010
environment: AvaTaxEnvironment.Sandbox,
1111
machineName: "test-machine",
1212
timeout: 3000,
13-
bearerToken: process.env.BEARER_TOKEN,
13+
bearerToken: process.env.BEARER_TOKEN_EINVOICING,
1414
};
1515
const scopes = "avatax_api";
1616

0 commit comments

Comments
 (0)