Skip to content

Commit 3eb1c8b

Browse files
committed
Fix integration tests
1 parent 17af7a6 commit 3eb1c8b

15 files changed

+107
-109
lines changed

tests/integration/admins.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe("Admins", () => {
77
beforeAll(async () => {
88
// arrange
99
const adminList = await client.admins.list();
10-
adminId = adminList.admins[0].id;
10+
adminId = adminList.admins?.[0]?.id ?? "0";
1111
});
1212

1313
it("list", async () => {
@@ -19,7 +19,7 @@ describe("Admins", () => {
1919
});
2020
it("find", async () => {
2121
// act
22-
const response = await client.admins.find({ admin_id: adminId });
22+
const response = await client.admins.find({ admin_id: parseInt(adminId, 10) });
2323

2424
// assert
2525
expect(response).toBeDefined();
@@ -39,7 +39,7 @@ describe("Admins", () => {
3939
it("away - ON", async () => {
4040
// act
4141
const response = await client.admins.away({
42-
admin_id: adminId,
42+
admin_id: parseInt(adminId, 10),
4343
away_mode_enabled: true,
4444
away_mode_reassign: true,
4545
});
@@ -50,7 +50,7 @@ describe("Admins", () => {
5050
it("away - OFF", async () => {
5151
// act
5252
const response = await client.admins.away({
53-
admin_id: adminId,
53+
admin_id: parseInt(adminId, 10),
5454
away_mode_enabled: false,
5555
away_mode_reassign: false,
5656
});

tests/integration/articles.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async function createArticle(client: Client, parentId: number, adminId: number)
2626

2727
async function tryDeleteArticle(client: Client, articleId: string) {
2828
try {
29-
await client.articles.delete({ article_id: articleId });
29+
await client.articles.delete({ article_id: parseInt(articleId, 10) });
3030
} catch (error) {
3131
console.error("Failed to delete article:", error);
3232
}
@@ -46,7 +46,7 @@ describe("Articles", () => {
4646
const randomAdmins = await client.admins.list();
4747

4848
parentId = parseInt(randomCollections.data[0].id, 10);
49-
adminId = parseInt(randomAdmins.admins[0].id, 10);
49+
adminId = parseInt(randomAdmins.admins?.[0]?.id ?? "0", 10);
5050

5151
const article = await createArticle(client, parentId, adminId);
5252
articleId = article.id;
@@ -70,7 +70,7 @@ describe("Articles", () => {
7070

7171
it("find", async () => {
7272
// act
73-
const response = await client.articles.find({ article_id: articleId });
73+
const response = await client.articles.find({ article_id: parseInt(articleId, 10) });
7474

7575
// assert
7676
expect(response).toBeDefined();
@@ -82,7 +82,7 @@ describe("Articles", () => {
8282

8383
// act
8484
const response = await client.articles.update({
85-
article_id: article.id,
85+
article_id: parseInt(article.id, 10),
8686
title: "Biba & Boba",
8787
});
8888

@@ -106,7 +106,7 @@ describe("Articles", () => {
106106
const article = await createArticle(client, parentId, adminId);
107107

108108
// act
109-
const response = await client.articles.delete({ article_id: article.id });
109+
const response = await client.articles.delete({ article_id: parseInt(article.id, 10) });
110110

111111
// assert
112112
expect(response).toBeDefined();

tests/integration/companies.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("Companies", () => {
1515
per_page: 1,
1616
});
1717

18-
contactId = randomContacts.data[0].id;
18+
contactId = randomContacts.data?.[0]?.id ?? "0";
1919
company = await createCompany(client);
2020
});
2121

@@ -105,7 +105,7 @@ describe("Companies", () => {
105105
it("attachContact", async () => {
106106
// act
107107
const response = await client.companies.attachContact({
108-
contact_id: contactId,
108+
contact_id: parseInt(contactId, 10),
109109
id: company.id,
110110
});
111111

@@ -128,7 +128,6 @@ describe("Companies", () => {
128128
// act
129129
const response = await client.companies.listAttachedContacts({
130130
company_id: company.id,
131-
page: 1,
132131
per_page: 25,
133132
});
134133

tests/integration/contacts.test.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ describe("Contacts", () => {
3030

3131
await client.companies.attachContact({
3232
id: company.id,
33-
contact_id: contact.id,
33+
contact_id: parseInt(contact.id!, 10),
3434
});
3535

3636
const subscriptionTypes = await client.subscriptionTypes.list();
37-
subscriptionId = subscriptionTypes.data[0].id;
37+
subscriptionId = subscriptionTypes.data?.[0]?.id ?? "0";
3838
await client.contacts.attachSubscription({
39-
contact_id: contact.id,
39+
contact_id: contact.id!,
4040
id: subscriptionId,
4141
consent_type: "opt_in",
4242
});
@@ -45,7 +45,7 @@ describe("Contacts", () => {
4545
name: randomString(),
4646
});
4747
await client.tags.tagContact({
48-
contact_id: contact.id,
48+
contact_id: contact.id!,
4949
id: tag.id,
5050
});
5151
});
@@ -54,15 +54,15 @@ describe("Contacts", () => {
5454
// cleanup
5555
try {
5656
await client.contacts.detachSubscription({
57-
contact_id: contact.id,
57+
contact_id: contact.id!,
5858
subscription_id: subscriptionId,
5959
});
6060
} catch (error) {
6161
console.error("Failed to detach subscription:", error);
6262
}
63-
await tryUntagContact(client, contact.id, tag.id);
64-
await tryDeleteCompany(client, company.id);
65-
await tryDeleteContact(client, contact.id);
63+
await tryUntagContact(client, contact.id!, tag.id!);
64+
await tryDeleteCompany(client, company.id!);
65+
await tryDeleteContact(client, contact.id!);
6666
});
6767

6868
it("list", async () => {
@@ -86,7 +86,7 @@ describe("Contacts", () => {
8686
expect(response).toBeDefined();
8787

8888
// cleanup
89-
await tryDeleteContact(client, response.id);
89+
await tryDeleteContact(client, response.id!);
9090
});
9191

9292
it("createLead", async () => {
@@ -100,13 +100,13 @@ describe("Contacts", () => {
100100
expect(response).toBeDefined();
101101

102102
// cleanup
103-
await tryDeleteContact(client, response.id);
103+
await tryDeleteContact(client, response.id!);
104104
});
105105

106106
it("find - by id", async () => {
107107
// act
108108
const response = await client.contacts.find({
109-
contact_id: contact.id,
109+
contact_id: contact.id!,
110110
});
111111

112112
// assert
@@ -119,15 +119,15 @@ describe("Contacts", () => {
119119

120120
// act
121121
const response = await client.contacts.update({
122-
contact_id: contact.id,
122+
contact_id: contact.id!,
123123
name: "Nico Bellic",
124124
});
125125

126126
// assert
127127
expect(response).toBeDefined();
128128

129129
// cleanup
130-
await tryDeleteContact(client, contact.id);
130+
await tryDeleteContact(client, contact.id!);
131131
});
132132

133133
it("archive", async () => {
@@ -136,14 +136,14 @@ describe("Contacts", () => {
136136

137137
// act
138138
const response = await client.contacts.archive({
139-
contact_id: contact.id,
139+
contact_id: contact.id!,
140140
});
141141

142142
// assert
143143
expect(response).toBeDefined();
144144

145145
// cleanup
146-
await tryDeleteContact(client, contact.id);
146+
await tryDeleteContact(client, contact.id!);
147147
});
148148

149149
it("unarchive", async () => {
@@ -152,14 +152,14 @@ describe("Contacts", () => {
152152

153153
// act
154154
const response = await client.contacts.unarchive({
155-
contact_id: contact.id,
155+
contact_id: contact.id!,
156156
});
157157

158158
// assert
159159
expect(response).toBeDefined();
160160

161161
// cleanup
162-
await tryDeleteContact(client, contact.id);
162+
await tryDeleteContact(client, contact.id!);
163163
});
164164

165165
it("delete", async () => {
@@ -171,7 +171,7 @@ describe("Contacts", () => {
171171

172172
// act
173173
const response = await client.contacts.delete({
174-
contact_id: contact.id,
174+
contact_id: contact.id!,
175175
});
176176

177177
// assert
@@ -189,22 +189,22 @@ describe("Contacts", () => {
189189
role: "lead",
190190
});
191191
const response = await client.contacts.mergeLeadInUser({
192-
from: createdLead.id,
193-
into: createdUser.id,
192+
from: createdLead.id!,
193+
into: createdUser.id!,
194194
});
195195

196196
// assert
197197
expect(response).toBeDefined();
198198

199199
// cleanup
200-
await tryDeleteContact(client, createdUser.id);
201-
await tryDeleteContact(client, createdLead.id);
200+
await tryDeleteContact(client, createdUser.id!);
201+
await tryDeleteContact(client, createdLead.id!);
202202
});
203203

204204
it("listAttachedCompanies", async () => {
205205
// act
206206
const response = await client.contacts.listAttachedCompanies({
207-
contact_id: contact.id,
207+
contact_id: contact.id!,
208208
});
209209

210210
// assert
@@ -214,7 +214,7 @@ describe("Contacts", () => {
214214
it("listAttachedEmailSubscriptions", async () => {
215215
// act
216216
const response = await client.contacts.listAttachedSubscriptions({
217-
contact_id: contact.id,
217+
contact_id: contact.id!,
218218
});
219219

220220
// assert
@@ -224,7 +224,7 @@ describe("Contacts", () => {
224224
it("listAttachedSegments", async () => {
225225
// act
226226
const response = await client.contacts.listAttachedSegments({
227-
contact_id: contact.id,
227+
contact_id: contact.id!,
228228
});
229229

230230
// assert
@@ -234,7 +234,7 @@ describe("Contacts", () => {
234234
it("listAttachedTags", async () => {
235235
// act
236236
const response = await client.contacts.listAttachedTags({
237-
contact_id: contact.id,
237+
contact_id: contact.id!,
238238
});
239239

240240
// assert

0 commit comments

Comments
 (0)