From 2477350981a2d8055e11eb0f6aad043d282c29f0 Mon Sep 17 00:00:00 2001 From: Marco Ponchia Date: Thu, 19 Dec 2024 18:14:34 +0100 Subject: [PATCH] Refactor env var for test --- packages/active-campaign-client/.env.example | 11 ++++++----- .../__tests__/helpers/manageListSubscription.test.ts | 4 ++-- .../src/clients/activeCampaignClient.ts | 8 ++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/active-campaign-client/.env.example b/packages/active-campaign-client/.env.example index 3def88bca..68bb08ca8 100644 --- a/packages/active-campaign-client/.env.example +++ b/packages/active-campaign-client/.env.example @@ -1,10 +1,11 @@ -AC_BASE_URL=your_account_url -AC_API_KEY=your_api_key SENDER_URL=localhost:3000 AWS_REGION="region" -AWS_USER_POOL_ID="region_DFWF81fRa" -COGNITO_USER_ID=66ae52a0-f051-7080-04a1-465b3a4f44cc -LIST_NAME=test-webinar-1732097286071 +COGNITO_USER_POOL_ID="region_DFWF81fRa" AC_BASE_URL_PARAM='/ac/base_url' AC_API_KEY_PARAM='/ac/api_key' + +TEST_AC_BASE_URL=your_account_url +TEST_AC_API_KEY=your_api_key TEST_AC_LIST_ID=28 +TEST_COGNITO_USER_ID=66ae52a0-f051-7080-04a1-465b3a4f44cc +TEST_LIST_NAME=test-webinar-1732097286071 diff --git a/packages/active-campaign-client/src/__tests__/helpers/manageListSubscription.test.ts b/packages/active-campaign-client/src/__tests__/helpers/manageListSubscription.test.ts index a49abb0dd..61e97cea0 100644 --- a/packages/active-campaign-client/src/__tests__/helpers/manageListSubscription.test.ts +++ b/packages/active-campaign-client/src/__tests__/helpers/manageListSubscription.test.ts @@ -5,8 +5,8 @@ import { } from '../../helpers/manageListSubscription'; describe.skip('manage list subscription', () => { - const cognitoUserId = process.env.COGNITO_USER_ID || ''; - const listName = process.env.LIST_NAME || ''; + const cognitoUserId = process.env.TEST_COGNITO_USER_ID || ''; + const listName = process.env.TEST_LIST_NAME || ''; it('should subscribe the contact to the list', async () => { const result = await addContactToList(cognitoUserId, listName); diff --git a/packages/active-campaign-client/src/clients/activeCampaignClient.ts b/packages/active-campaign-client/src/clients/activeCampaignClient.ts index 32ad57ce3..e0f1f9e79 100644 --- a/packages/active-campaign-client/src/clients/activeCampaignClient.ts +++ b/packages/active-campaign-client/src/clients/activeCampaignClient.ts @@ -57,8 +57,8 @@ export class ActiveCampaignClient { params?: Record ): Promise { const [apiKey, baseUrl] = await Promise.all([ - getParameter(this.apiKeyParam, this.ssm, process.env.AC_API_KEY), - getParameter(this.baseUrlParam, this.ssm, process.env.AC_BASE_URL), + getParameter(this.apiKeyParam, this.ssm, process.env.TEST_AC_API_KEY), + getParameter(this.baseUrlParam, this.ssm, process.env.TEST_AC_BASE_URL), ]); return new Promise((resolve, reject) => { // Parse the base URL to get hostname and path and remove any trailing slashes from the baseUrl @@ -160,9 +160,9 @@ export class ActiveCampaignClient { async getLists(ids?: readonly string[]) { const limitParams = { limit: '1000' }; - return this.makeRequest( + return this.makeRequest<{ readonly lists: readonly ActiveCampaignList[] }>( 'GET', - `/api/3/lists`, + '/api/3/lists', undefined, ids && ids.length > 0 ? { ids: ids.join(','), ...limitParams }