Repository: 8398a7/action-slack (ts)

Issue:
Add Support for GitHub Enterprise Instances
Hi, I wanted to use this action on an on premises GitHub Enterprise Server that has it's own url (e.g. https://git.acme.com) 

I was hoping it would be possible to add a new input to the `action.yml` to support passing in a url for a Git instance that would default to GitHub.com if unfilled. 

Right now it looks like the `message` field will use the instance url for it's link but the others do not.

https://github.com/8398a7/action-slack/blob/9c613f82be50ba1c5d845d3448861aba03da3d0b/src/fields.ts#L140

There might be a way to do it dynamically because this is how the `message` field gets the url for the link
https://github.com/8398a7/action-slack/blob/9c613f82be50ba1c5d845d3448861aba03da3d0b/src/fields.ts#L73-L81

Pull request description:
Issue/129
close #129

Patch:
diff --git a/README.md b/README.md
index 621f2a1..c91200d 100644
--- a/README.md
+++ b/README.md
@@ -48,3 +48,17 @@ steps:
 ```
 
 <img width="501" alt="custom" src="https://user-images.githubusercontent.com/8043276/85949864-2b3df300-b994-11ea-9388-f4ff1aebc292.png">
+
+## For GitHub Enterprise
+
+```yaml
+steps:
+  - uses: 8398a7/action-slack@v3
+    with:
+      github_base_url: https://your.ghe.com # Specify your GHE
+      status: ${{ job.status }}
+      fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
+    env:
+      SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
+    if: always()
+```
diff --git a/action.yml b/action.yml
index a797172..eaeb853 100644
--- a/action.yml
+++ b/action.yml
@@ -62,6 +62,10 @@ inputs:
     description: Use this if you wish to use a different GitHub token than the one provided by the workflow.
     required: true
     default: ${{ github.token }}
+  github_base_url:
+    description: Specify if you want to use GitHub Enterprise.
+    default: ""
+    required: false
 runs:
   using: node12
   main: dist/index.js
diff --git a/src/client.ts b/src/client.ts
index a14e7c3..bb90c42 100644
--- a/src/client.ts
+++ b/src/client.ts
@@ -44,7 +44,12 @@ export class Client {
   private octokit: Octokit;
   private with: With;
 
-  constructor(props: With, token: string, webhookUrl?: string | null) {
+  constructor(
+    props: With,
+    token: string,
+    gitHubBaseUrl: string,
+    webhookUrl?: string | null,
+  ) {
     this.with = props;
     if (this.with.fields === '') this.with.fields = 'repo,commit';
 
@@ -57,6 +62,7 @@ export class Client {
     this.fieldFactory = new FieldFactory(
       this.with.fields,
       this.jobName,
+      gitHubBaseUrl,
       this.octokit,
     );
   }
diff --git a/src/fields.ts b/src/fields.ts
index d0b4372..45a4b41 100644
--- a/src/fields.ts
+++ b/src/fields.ts
@@ -11,11 +11,19 @@ export class FieldFactory {
   private octokit: Octokit;
   private fields: string[];
   private jobName: string;
+  private gitHubBaseUrl: string;
 
-  constructor(fields: string, jobName: string, octokit: Octokit) {
+  constructor(
+    fields: string,
+    jobName: string,
+    gitHubBaseUrl: string,
+    octokit: Octokit,
+  ) {
     this.fields = fields.replace(/ /g, '').split(',');
     this.jobName = jobName;
     this.octokit = octokit;
+    this.gitHubBaseUrl =
+      gitHubBaseUrl === '' ? 'https://github.com' : gitHubBaseUrl;
   }
 
   includes(field: string) {
@@ -137,7 +145,7 @@ export class FieldFactory {
     }
 
     const jobId = currentJob.id;
-    const value = `<https://github.com/${owner}/${context.repo.repo}/runs/${jobId}|${this.jobName}>`;
+    const value = `<${this.gitHubBaseUrl}/${owner}/${context.repo.repo}/runs/${jobId}|${this.jobName}>`;
     process.env.AS_JOB = value;
 
     return value;
@@ -147,10 +155,9 @@ export class FieldFactory {
     const { sha } = context;
     const { owner, repo } = context.repo;
 
-    const value = `<https://github.com/${owner}/${repo}/commit/${sha}|${sha.slice(
-      0,
-      8,
-    )}>`;
+    const value = `<${
+      this.gitHubBaseUrl
+    }/${owner}/${repo}/commit/${sha}|${sha.slice(0, 8)}>`;
     process.env.AS_COMMIT = value;
     return value;
   }
@@ -158,7 +165,7 @@ export class FieldFactory {
   private async repo(): Promise<string> {
     const { owner, repo } = context.repo;
 
-    const value = `<https://github.com/${owner}/${repo}|${owner}/${repo}>`;
+    const value = `<${this.gitHubBaseUrl}/${owner}/${repo}|${owner}/${repo}>`;
     process.env.AS_REPO = value;
     return value;
   }
@@ -179,7 +186,7 @@ export class FieldFactory {
     const sha = context.payload.pull_request?.head.sha ?? context.sha;
     const { owner, repo } = context.repo;
 
-    const value = `<https://github.com/${owner}/${repo}/commit/${sha}/checks|${context.workflow}>`;
+    const value = `<${this.gitHubBaseUrl}/${owner}/${repo}/commit/${sha}/checks|${context.workflow}>`;
     process.env.AS_WORKFLOW = value;
     return value;
   }
@@ -188,7 +195,7 @@ export class FieldFactory {
     const sha = context.payload.pull_request?.head.sha ?? context.sha;
     const { owner, repo } = context.repo;
 
-    const value = `<https://github.com/${owner}/${repo}/commit/${sha}/checks|action>`;
+    const value = `<${this.gitHubBaseUrl}/${owner}/${repo}/commit/${sha}/checks|action>`;
     process.env.AS_ACTION = value;
     return value;
   }
diff --git a/src/main.ts b/src/main.ts
index 1f666e2..347c85b 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -17,6 +17,7 @@ async function run(): Promise<void> {
     const fields = core.getInput('fields');
     const job_name = core.getInput('job_name');
     const github_token = core.getInput('github_token');
+    const github_base_url = core.getInput('github_base_url');
 
     core.debug(`status: ${status}`);
     core.debug(`mention: ${mention}`);
@@ -31,6 +32,7 @@ async function run(): Promise<void> {
     core.debug(`payload: ${payload}`);
     core.debug(`fields: ${fields}`);
     core.debug(`job_name: ${job_name}`);
+    core.debug(`github_base_url: ${github_base_url}`);
 
     const client = new Client(
       {
@@ -46,6 +48,7 @@ async function run(): Promise<void> {
         job_name,
       },
       github_token,
+      github_base_url,
       process.env.SLACK_WEBHOOK_URL,
     );
 


Test patch:
diff --git a/__tests__/client.test.ts b/__tests__/client.test.ts
index 7332d97..e08cc4a 100644
--- a/__tests__/client.test.ts
+++ b/__tests__/client.test.ts
@@ -9,6 +9,7 @@ import {
   getApiFixture,
   newWith,
   gitHubToken,
+  gitHubBaseUrl,
   webhookUrl,
 } from './helper';
 
@@ -43,25 +44,30 @@ describe('8398a7/action-slack', () => {
     it('is returns an exception because the environment variable does not exist', () => {
       const withParams = newWith();
       expect(() => {
-        new Client(withParams, gitHubToken, process.env.NOT_FOUND_ENV);
+        new Client(
+          withParams,
+          gitHubToken,
+          gitHubBaseUrl,
+          process.env.NOT_FOUND_ENV,
+        );
       }).toThrow();
     });
     it('is returns exception because null value', () => {
       const withParams = newWith();
       expect(() => {
-        new Client(withParams, gitHubToken, null);
+        new Client(withParams, gitHubToken, gitHubBaseUrl, null);
       }).toThrow();
     });
     it('is returns exception because undefined value', () => {
       const withParams = newWith();
       expect(() => {
-        new Client(withParams, gitHubToken, undefined);
+        new Client(withParams, gitHubToken, gitHubBaseUrl, undefined);
       }).toThrow();
     });
     it('is returns exception because empty string value', () => {
       const withParams = newWith();
       expect(() => {
-        new Client(withParams, gitHubToken, '');
+        new Client(withParams, gitHubToken, gitHubBaseUrl, '');
       }).toThrow();
     });
   });
@@ -74,7 +80,12 @@ describe('8398a7/action-slack', () => {
         fields:
           'repo,message,commit,author,job,action,eventName,ref,workflow,took',
       };
-      const client = new Client(withParams, gitHubToken, webhookUrl);
+      const client = new Client(
+        withParams,
+        gitHubToken,
+        gitHubBaseUrl,
+        webhookUrl,
+      );
       const payload = getTemplate(withParams.fields, successMsg);
       payload.attachments[0].color = 'good';
       expect(await client.prepare('')).toStrictEqual(payload);
@@ -87,7 +98,12 @@ describe('8398a7/action-slack', () => {
         ...newWith(),
         status: Success,
       };
-      const client = new Client(withParams, gitHubToken, webhookUrl);
+      const client = new Client(
+        withParams,
+        gitHubToken,
+        gitHubBaseUrl,
+        webhookUrl,
+      );
       const payload = getTemplate(withParams.fields, successMsg);
       payload.attachments[0].color = 'good';
       expect(await client.prepare('')).toStrictEqual(payload);
@@ -97,7 +113,12 @@ describe('8398a7/action-slack', () => {
         ...newWith(),
         status: Failure,
       };
-      const client = new Client(withParams, gitHubToken, webhookUrl);
+      const client = new Client(
+        withParams,
+        gitHubToken,
+        gitHubBaseUrl,
+        webhookUrl,
+      );
       const payload = getTemplate(withParams.fields, failMsg);
       payload.attachments[0].color = 'danger';
       expect(await client.prepare('')).toStrictEqual(payload);
@@ -107,7 +128,12 @@ describe('8398a7/action-slack', () => {
         ...newWith(),
         status: Cancelled,
       };
-      const client = new Client(withParams, gitHubToken, webhookUrl);
+      const client = new Client(
+        withParams,
+        gitHubToken,
+        gitHubBaseUrl,
+        webhookUrl,
+      );
       const payload = getTemplate(withParams.fields, cancelMsg);
       payload.attachments[0].color = 'warning';
       expect(await client.prepare('')).toStrictEqual(payload);
@@ -119,7 +145,12 @@ describe('8398a7/action-slack', () => {
       ...newWith(),
       status: Success,
     };
-    const client = new Client(withParams, gitHubToken, webhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      webhookUrl,
+    );
     const msg = 'mention test';
     const payload = getTemplate(withParams.fields, msg);
     payload.attachments[0].color = 'good';
@@ -133,7 +164,7 @@ describe('8398a7/action-slack', () => {
       mention: 'here',
       if_mention: Failure,
     };
-    let client = new Client(withParams, gitHubToken, webhookUrl);
+    let client = new Client(withParams, gitHubToken, gitHubBaseUrl, webhookUrl);
     const msg = 'mention test';
     let payload = getTemplate(withParams.fields, msg);
     payload.attachments[0].color = 'good';
@@ -141,7 +172,7 @@ describe('8398a7/action-slack', () => {
 
     withParams.mention = '';
     withParams.status = Failure;
-    client = new Client(withParams, gitHubToken, webhookUrl);
+    client = new Client(withParams, gitHubToken, gitHubBaseUrl, webhookUrl);
     payload = getTemplate(withParams.fields, msg);
     payload.attachments[0].color = 'danger';
     expect(await client.prepare(msg)).toStrictEqual(payload);
@@ -154,7 +185,12 @@ describe('8398a7/action-slack', () => {
       mention: 'here',
       if_mention: `${Failure},${Success}`,
     };
-    const client = new Client(withParams, gitHubToken, webhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      webhookUrl,
+    );
     const msg = 'mention test';
     const payload = getTemplate(withParams.fields, `<!here> ${msg}`);
     payload.attachments[0].color = 'good';
@@ -168,7 +204,12 @@ describe('8398a7/action-slack', () => {
       mention: 'here',
       if_mention: Success,
     };
-    const client = new Client(withParams, gitHubToken, webhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      webhookUrl,
+    );
     const msg = 'mention test';
     const payload = getTemplate(withParams.fields, `<!here> ${msg}`);
     payload.attachments[0].color = 'good';
@@ -182,7 +223,12 @@ describe('8398a7/action-slack', () => {
       mention: 'here',
       if_mention: Failure,
     };
-    const client = new Client(withParams, gitHubToken, webhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      webhookUrl,
+    );
     const msg = 'mention test';
     const payload = getTemplate(withParams.fields, `<!here> ${msg}`);
     payload.attachments[0].color = 'danger';
@@ -196,7 +242,12 @@ describe('8398a7/action-slack', () => {
       mention: 'here',
       if_mention: Cancelled,
     };
-    const client = new Client(withParams, gitHubToken, webhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      webhookUrl,
+    );
     const msg = 'mention test';
     const payload = getTemplate(withParams.fields, `<!here> ${msg}`);
     payload.attachments[0].color = 'warning';
@@ -210,7 +261,7 @@ describe('8398a7/action-slack', () => {
       mention: 'here',
       if_mention: Always,
     };
-    let client = new Client(withParams, gitHubToken, webhookUrl);
+    let client = new Client(withParams, gitHubToken, gitHubBaseUrl, webhookUrl);
     const msg = 'mention test';
     let payload = getTemplate(withParams.fields, `<!here> ${msg}`);
     payload.attachments[0].color = 'good';
@@ -219,13 +270,13 @@ describe('8398a7/action-slack', () => {
     payload = getTemplate(withParams.fields, `<!here> ${msg}`);
     payload.attachments[0].color = 'danger';
     withParams.status = Failure;
-    client = new Client(withParams, gitHubToken, webhookUrl);
+    client = new Client(withParams, gitHubToken, gitHubBaseUrl, webhookUrl);
     expect(await client.prepare(msg)).toStrictEqual(payload);
 
     payload = getTemplate(withParams.fields, `<!here> ${msg}`);
     payload.attachments[0].color = 'warning';
     withParams.status = Cancelled;
-    client = new Client(withParams, gitHubToken, webhookUrl);
+    client = new Client(withParams, gitHubToken, gitHubBaseUrl, webhookUrl);
     expect(await client.prepare(msg)).toStrictEqual(payload);
   });
 
@@ -236,7 +287,12 @@ describe('8398a7/action-slack', () => {
       mention: 'user_id',
       if_mention: Success,
     };
-    const client = new Client(withParams, gitHubToken, webhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      webhookUrl,
+    );
     const msg = 'mention test';
     const payload = getTemplate(withParams.fields, `<@user_id> ${msg}`);
     payload.attachments[0].color = 'good';
@@ -250,7 +306,12 @@ describe('8398a7/action-slack', () => {
       mention: 'here',
       if_mention: Success,
     };
-    const client = new Client(withParams, gitHubToken, webhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      webhookUrl,
+    );
     const msg = 'mention test';
     const payload = getTemplate(withParams.fields, `<!here> ${msg}`);
     payload.attachments[0].color = 'good';
@@ -264,7 +325,12 @@ describe('8398a7/action-slack', () => {
       mention: 'channel',
       if_mention: Success,
     };
-    const client = new Client(withParams, gitHubToken, webhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      webhookUrl,
+    );
     const msg = 'mention test';
     const payload = getTemplate(withParams.fields, `<!channel> ${msg}`);
     payload.attachments[0].color = 'good';
@@ -278,7 +344,12 @@ describe('8398a7/action-slack', () => {
       mention: 'subteam^user_group_id',
       if_mention: Success,
     };
-    const client = new Client(withParams, gitHubToken, webhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      webhookUrl,
+    );
     const msg = 'mention test';
     const payload = getTemplate(
       withParams.fields,
@@ -295,7 +366,12 @@ describe('8398a7/action-slack', () => {
       mention: 'subteam^user_group_id,subteam^user_group_id2',
       if_mention: Success,
     };
-    const client = new Client(withParams, gitHubToken, webhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      webhookUrl,
+    );
     const msg = 'mention test';
     const payload = getTemplate(
       withParams.fields,
@@ -312,7 +388,12 @@ describe('8398a7/action-slack', () => {
       mention: 'user_id,user_id2',
       if_mention: Success,
     };
-    const client = new Client(withParams, gitHubToken, webhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      webhookUrl,
+    );
     const msg = 'mention test';
     const payload = getTemplate(
       withParams.fields,
@@ -329,7 +410,12 @@ describe('8398a7/action-slack', () => {
       mention: 'user_id,subteam^user_group_id',
       if_mention: Success,
     };
-    const client = new Client(withParams, gitHubToken, webhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      webhookUrl,
+    );
     const msg = 'mention test';
     const payload = getTemplate(
       withParams.fields,
@@ -346,7 +432,7 @@ describe('8398a7/action-slack', () => {
       mention: 'user_id, user_id2',
       if_mention: Success,
     };
-    let client = new Client(withParams, gitHubToken, webhookUrl);
+    let client = new Client(withParams, gitHubToken, gitHubBaseUrl, webhookUrl);
     const msg = 'hello';
 
     let payload = getTemplate(
@@ -362,7 +448,7 @@ describe('8398a7/action-slack', () => {
       ...newWith(),
       status: Success,
     };
-    let client = new Client(withParams, gitHubToken, webhookUrl);
+    let client = new Client(withParams, gitHubToken, gitHubBaseUrl, webhookUrl);
     const msg = 'hello';
 
     // for success
@@ -372,14 +458,14 @@ describe('8398a7/action-slack', () => {
 
     // for cancel
     withParams.status = Cancelled;
-    client = new Client(withParams, gitHubToken, webhookUrl);
+    client = new Client(withParams, gitHubToken, gitHubBaseUrl, webhookUrl);
     payload = getTemplate(withParams.fields, msg);
     payload.attachments[0].color = 'warning';
     expect(await client.prepare(msg)).toStrictEqual(payload);
 
     // for fail
     withParams.status = Failure;
-    client = new Client(withParams, gitHubToken, webhookUrl);
+    client = new Client(withParams, gitHubToken, gitHubBaseUrl, webhookUrl);
     payload = getTemplate(withParams.fields, msg);
     payload.attachments[0].color = 'danger';
     expect(await client.prepare(msg)).toStrictEqual(payload);
@@ -387,7 +473,7 @@ describe('8398a7/action-slack', () => {
 
   it('throws error', () => {
     const withParams = newWith();
-    expect(() => new Client(withParams, gitHubToken)).toThrow(
+    expect(() => new Client(withParams, gitHubToken, gitHubBaseUrl)).toThrow(
       'Specify secrets.SLACK_WEBHOOK_URL',
     );
   });
@@ -406,7 +492,12 @@ describe('8398a7/action-slack', () => {
       .reply(200, () => getApiFixture('repos.commits.get'));
 
     const withParams = newWith();
-    const client = new Client(withParams, gitHubToken, mockSlackWebhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      mockSlackWebhookUrl,
+    );
 
     await client.send('payload');
 
@@ -419,7 +510,12 @@ describe('8398a7/action-slack', () => {
         status: 'custom',
         fields: 'all',
       };
-      const client = new Client(withParams, gitHubToken, webhookUrl);
+      const client = new Client(
+        withParams,
+        gitHubToken,
+        gitHubBaseUrl,
+        webhookUrl,
+      );
       expect(
         await client.custom(`{
           text: \`\${process.env.AS_WORKFLOW}
@@ -437,7 +533,12 @@ describe('8398a7/action-slack', () => {
         ...newWith(),
         status: 'custom',
       };
-      const client = new Client(withParams, gitHubToken, webhookUrl);
+      const client = new Client(
+        withParams,
+        gitHubToken,
+        gitHubBaseUrl,
+        webhookUrl,
+      );
       expect(() => client.injectColor()).toThrow();
     });
   });
@@ -447,7 +548,12 @@ describe('8398a7/action-slack', () => {
         ...newWith(),
         status: 'custom',
       };
-      const client = new Client(withParams, gitHubToken, webhookUrl);
+      const client = new Client(
+        withParams,
+        gitHubToken,
+        gitHubBaseUrl,
+        webhookUrl,
+      );
       expect(() => client.injectText('')).toThrow();
     });
   });
@@ -459,10 +565,34 @@ describe('8398a7/action-slack', () => {
         mention: 'test1,test2, here',
         if_mention: Success,
       };
-      const client = new Client(withParams, gitHubToken, webhookUrl);
+      const client = new Client(
+        withParams,
+        gitHubToken,
+        gitHubBaseUrl,
+        webhookUrl,
+      );
       expect(client.mentionText(Success)).toStrictEqual(
         '<@test1> <@test2> <!here> ',
       );
     });
   });
+
+  describe('GitHub Enterprise', () => {
+    it('is full fields', () => {
+      const withParams = {
+        ...newWith(),
+        status: Success,
+        fields:
+          'repo,message,commit,author,job,action,eventName,ref,workflow,took',
+      };
+      const client = new Client(
+        withParams,
+        gitHubToken,
+        'https://your.ghe.com.',
+        webhookUrl,
+      );
+      const payload = getTemplate(withParams.fields, successMsg);
+      payload.attachments[0].color = 'good';
+    });
+  });
 });
diff --git a/__tests__/customJobName.test.ts b/__tests__/customJobName.test.ts
index c09b03b..d0a30b3 100644
--- a/__tests__/customJobName.test.ts
+++ b/__tests__/customJobName.test.ts
@@ -5,6 +5,7 @@ process.env.MATRIX_CONTEXT = '{"os": "ubuntu-18.04"}';
 
 import {
   gitHubToken,
+  gitHubBaseUrl,
   newWith,
   setupNockCommit,
   setupNockJobs,
@@ -41,7 +42,12 @@ describe('job_name', () => {
       fields: 'job,took',
       job_name: 'Custom Job',
     };
-    const client = new Client(withParams, gitHubToken, webhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      webhookUrl,
+    );
     expect(await client.prepare('')).toStrictEqual({
       text: successMsg,
       attachments: [
diff --git a/__tests__/helper.ts b/__tests__/helper.ts
index 153ec6f..05263ab 100644
--- a/__tests__/helper.ts
+++ b/__tests__/helper.ts
@@ -6,6 +6,7 @@ import { FieldFactory } from '../src/fields';
 import { getOctokit } from '@actions/github';
 
 export const gitHubToken = 'github-token';
+export const gitHubBaseUrl = '';
 export const webhookUrl = 'https://hooks.slack.com/services/xxx';
 
 export const getTemplate: any = (
@@ -76,6 +77,7 @@ export const fixedFields = (fields: string, sha?: string) => {
   const ff = new FieldFactory(
     fields,
     process.env.GITHUB_JOB as string,
+    '',
     getOctokit(gitHubToken),
   );
   return ff.filterField(
diff --git a/__tests__/incorrectMatrix.test.ts b/__tests__/incorrectMatrix.test.ts
index 9dec1e1..d06f699 100644
--- a/__tests__/incorrectMatrix.test.ts
+++ b/__tests__/incorrectMatrix.test.ts
@@ -5,6 +5,7 @@ process.env.MATRIX_CONTEXT = '{}';
 
 import {
   gitHubToken,
+  gitHubBaseUrl,
   newWith,
   setupNockCommit,
   setupNockJobs,
@@ -40,7 +41,12 @@ describe('MATRIX_CONTEXT', () => {
       status: Success,
       fields: 'job,took',
     };
-    const client = new Client(withParams, gitHubToken, webhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      webhookUrl,
+    );
     expect(await client.prepare('')).toStrictEqual({
       text: successMsg,
       attachments: [
diff --git a/__tests__/matrix.test.ts b/__tests__/matrix.test.ts
index 71efa60..f592886 100644
--- a/__tests__/matrix.test.ts
+++ b/__tests__/matrix.test.ts
@@ -5,6 +5,7 @@ process.env.MATRIX_CONTEXT = '{"os": "ubuntu-18.04"}';
 
 import {
   gitHubToken,
+  gitHubBaseUrl,
   newWith,
   setupNockCommit,
   setupNockJobs,
@@ -40,7 +41,12 @@ describe('MATRIX_CONTEXT', () => {
       status: Success,
       fields: 'job,took',
     };
-    const client = new Client(withParams, gitHubToken, webhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      webhookUrl,
+    );
     expect(await client.prepare('')).toStrictEqual({
       text: successMsg,
       attachments: [
diff --git a/__tests__/pull_request.test.ts b/__tests__/pull_request.test.ts
index 6f22a2a..9bbd839 100644
--- a/__tests__/pull_request.test.ts
+++ b/__tests__/pull_request.test.ts
@@ -7,6 +7,7 @@ import {
   getTemplate,
   newWith,
   gitHubToken,
+  gitHubBaseUrl,
   webhookUrl,
 } from './helper';
 import { Client, With, Success } from '../src/client';
@@ -39,7 +40,12 @@ describe('pull request event', () => {
       if_mention: Success,
       fields: 'action',
     };
-    const client = new Client(withParams, gitHubToken, webhookUrl);
+    const client = new Client(
+      withParams,
+      gitHubToken,
+      gitHubBaseUrl,
+      webhookUrl,
+    );
     const msg = 'mention test';
     const payload = getTemplate(withParams.fields, `<@user_id> ${msg}`, sha);
     payload.attachments[0].color = 'good';