-
Notifications
You must be signed in to change notification settings - Fork 119
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
4a42ac8
commit 9983109
Showing
25 changed files
with
1,999 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
.github/PULL_REQUEST_TEMPLATE.md | ||
.gitattributes | ||
LICENSE | ||
REPO_OWNER | ||
REPO_OWNER | ||
tests/integration |
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,61 @@ | ||
import { createClient } from "./utils/createClient"; | ||
|
||
describe("Admins", () => { | ||
let adminId: string; | ||
const client = createClient(); | ||
|
||
beforeAll(async () => { | ||
// arrange | ||
const adminList = await client.admins.list(); | ||
adminId = adminList.admins[0].id; | ||
}); | ||
|
||
it("list", async () => { | ||
// act | ||
const response = await client.admins.list(); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
}); | ||
it("find", async () => { | ||
// act | ||
const response = await client.admins.find({ admin_id: adminId }); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
}); | ||
|
||
it("listAllActivityLogs", async () => { | ||
// act | ||
const response = await client.admins.listAllActivityLogs({ | ||
created_at_after: new Date("2021-12-12").toISOString(), | ||
created_at_before: new Date("2022-01-01").toISOString(), | ||
}); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
}); | ||
|
||
it("away - ON", async () => { | ||
// act | ||
const response = await client.admins.away({ | ||
admin_id: adminId, | ||
away_mode_enabled: true, | ||
away_mode_reassign: true, | ||
}); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
}); | ||
it("away - OFF", async () => { | ||
// act | ||
const response = await client.admins.away({ | ||
admin_id: adminId, | ||
away_mode_enabled: false, | ||
away_mode_reassign: false, | ||
}); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
}); | ||
}); |
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,116 @@ | ||
import { IntercomClient as Client } from "../../src"; | ||
import { randomString } from "./utils/random"; | ||
import { createClient } from "./utils/createClient"; | ||
|
||
async function createArticle(client: Client, parentId: number, adminId: number) { | ||
return await client.articles.create({ | ||
title: randomString(), | ||
description: randomString(), | ||
body: "<b>Eins Zwei</b>", | ||
author_id: adminId, | ||
state: "draft", | ||
parent_id: parentId, | ||
parent_type: "collection", | ||
translated_content: { | ||
fr: { | ||
type: "article_content", | ||
title: "Allez les verts", | ||
description: "French description", | ||
body: "<p>French body in html</p>", | ||
author_id: adminId, | ||
state: "draft", | ||
}, | ||
}, | ||
}); | ||
} | ||
|
||
async function tryDeleteArticle(client: Client, articleId: string) { | ||
try { | ||
await client.articles.delete({ article_id: articleId }); | ||
} catch (error) { | ||
console.error("Failed to delete article:", error); | ||
} | ||
} | ||
|
||
describe("Articles", () => { | ||
let articleId: string; | ||
let parentId: number; | ||
let adminId: number; | ||
const client = createClient(); | ||
|
||
beforeAll(async () => { | ||
// arrange | ||
const randomCollections = await client.helpCenters.collections.list({ | ||
per_page: 1, | ||
}); | ||
const randomAdmins = await client.admins.list(); | ||
|
||
parentId = parseInt(randomCollections.data[0].id, 10); | ||
adminId = parseInt(randomAdmins.admins[0].id, 10); | ||
|
||
const article = await createArticle(client, parentId, adminId); | ||
articleId = article.id; | ||
}); | ||
|
||
afterAll(async () => { | ||
// cleanup | ||
await tryDeleteArticle(client, articleId); | ||
}); | ||
|
||
it("create", async () => { | ||
// act | ||
const article = await createArticle(client, parentId, adminId); | ||
|
||
// assert | ||
expect(article).toBeDefined(); | ||
|
||
// cleanup | ||
await tryDeleteArticle(client, article.id); | ||
}); | ||
|
||
it("find", async () => { | ||
// act | ||
const response = await client.articles.find({ article_id: articleId }); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
}); | ||
|
||
it("update", async () => { | ||
// arrange | ||
const article = await createArticle(client, parentId, adminId); | ||
|
||
// act | ||
const response = await client.articles.update({ | ||
article_id: article.id, | ||
body: { | ||
title: "Biba & Boba", | ||
}, | ||
}); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
|
||
// cleanup | ||
await tryDeleteArticle(client, article.id); | ||
}); | ||
|
||
it("list", async () => { | ||
// act | ||
const response = await client.articles.list({ page: 1, per_page: 12 }); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
}); | ||
|
||
it("delete", async () => { | ||
// arrange | ||
const article = await createArticle(client, parentId, adminId); | ||
|
||
// act | ||
const response = await client.articles.delete({ article_id: article.id }); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
}); | ||
}); |
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,148 @@ | ||
import { Intercom } from "../../src"; | ||
import { dateToUnixTimestamp } from "./utils/date"; | ||
import { createCompany, tryDeleteCompany } from "./helpers"; | ||
import { createClient } from "./utils/createClient"; | ||
|
||
describe("Companies", () => { | ||
let contactId: string; | ||
let company: Intercom.Company; | ||
|
||
const client = createClient(); | ||
|
||
beforeAll(async () => { | ||
// arrange | ||
const randomContacts = await client.contacts.list({ | ||
per_page: 1, | ||
}); | ||
|
||
contactId = randomContacts.data[0].id; | ||
company = await createCompany(client); | ||
}); | ||
|
||
afterAll(async () => { | ||
// cleanup | ||
await tryDeleteCompany(client, company.id); | ||
}); | ||
|
||
it("create", async () => { | ||
// act | ||
const company = await createCompany(client); | ||
|
||
// assert | ||
expect(company).toBeDefined(); | ||
|
||
// cleanup | ||
await tryDeleteCompany(client, company.id); | ||
}); | ||
|
||
it("update", async () => { | ||
// arrange | ||
const company = await createCompany(client); | ||
|
||
// act | ||
const response = await client.companies.createOrUpdate({ | ||
company_id: company.company_id, | ||
remote_created_at: dateToUnixTimestamp(new Date()), | ||
name: "BestCompanyInc", | ||
monthly_spend: 9001, | ||
plan: "1. Get pizzaid", | ||
size: 62049, | ||
website: "http://the-best.one", | ||
industry: "The Best One", | ||
custom_attributes: {}, | ||
}); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
|
||
// cleanup | ||
await tryDeleteCompany(client, company.id); | ||
}); | ||
|
||
it("find - by id", async () => { | ||
// act | ||
const response = await client.companies.find({ | ||
company_id: company.id, | ||
}); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
}); | ||
|
||
it("list", async () => { | ||
// act | ||
const response = await client.companies.list({ | ||
page: 1, | ||
per_page: 35, | ||
order: "desc", | ||
}); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
}); | ||
|
||
it("delete", async () => { | ||
// arrange | ||
const company = await createCompany(client); | ||
|
||
// act | ||
const response = await client.companies.delete({ | ||
company_id: company.id, | ||
}); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
}); | ||
|
||
it.skip("scroll - infinite one", async () => { | ||
// act | ||
const response = await client.companies.scroll(); | ||
|
||
// assert | ||
expect(response.data).toBeDefined(); | ||
}); | ||
|
||
it("attachContact", async () => { | ||
// act | ||
const response = await client.companies.attachContact({ | ||
contact_id: contactId, | ||
id: company.id, | ||
}); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
}); | ||
|
||
it("detachContact", async () => { | ||
// act | ||
const response = await client.companies.detachContact({ | ||
contact_id: contactId, | ||
company_id: company.id, | ||
}); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
}); | ||
|
||
it("listAttachedContacts", async () => { | ||
// act | ||
const response = await client.companies.listAttachedContacts({ | ||
company_id: company.id, | ||
page: 1, | ||
per_page: 25, | ||
}); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
}); | ||
|
||
it("listAttachedSegments", async () => { | ||
// act | ||
const response = await client.companies.listAttachedSegments({ | ||
company_id: company.id, | ||
}); | ||
|
||
// assert | ||
expect(response).toBeDefined(); | ||
}); | ||
}); |
Oops, something went wrong.