Skip to content

Commit 29c4dda

Browse files
VoloVolo
authored andcommitted
Make QA config workspace independent
1 parent b628c9c commit 29c4dda

File tree

12 files changed

+152
-51
lines changed

12 files changed

+152
-51
lines changed

test/integration/admins.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
import { adminId, token } from './utils/config';
1+
import { token } from './utils/config';
22
import { Client } from '../../dist';
33
import assert from 'assert';
44

55
describe('Admins', () => {
6+
let adminId: string;
67
const client = new Client({ tokenAuth: { token } });
78

8-
it('find', async () => {
9-
const response = await client.admins.find({ id: adminId });
9+
it('list', async () => {
10+
const response = await client.admins.list();
11+
12+
adminId = response.admins[0].id;
1013

1114
assert.notEqual(response, undefined);
1215
});
13-
it('list', async () => {
14-
const response = await client.admins.list();
16+
it('find', async () => {
17+
const response = await client.admins.find({ id: adminId });
1518

1619
assert.notEqual(response, undefined);
1720
});

test/integration/articles.test.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import { Client } from '../../dist';
22
import assert from 'assert';
3-
import {
4-
adminId as adminIdString,
5-
token,
6-
parentId as parentIdString,
7-
} from './utils/config';
3+
import { token } from './utils/config';
84
import { randomString } from './utils/random';
95

106
describe('Articles', () => {
11-
let newArticleId = '0';
12-
const adminId = parseInt(adminIdString, 10);
13-
const parentId = parseInt(parentIdString, 10);
7+
let newArticleId: string;
8+
let parentId: number;
9+
let adminId: number;
10+
11+
before(async () => {
12+
const randomCollections = await client.helpCenter.collections.list({
13+
perPage: 1,
14+
});
15+
const randomAdmins = await client.admins.list();
16+
17+
parentId = parseInt(randomCollections.data[0].id, 10);
18+
adminId = parseInt(randomAdmins.admins[0].id, 10);
19+
});
1420

1521
const client = new Client({ tokenAuth: { token } });
1622

test/integration/companies.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
import { Client, CompanyObject, Order } from '../../dist';
22
import assert from 'assert';
3-
import { contactId, token } from './utils/config';
3+
import { token } from './utils/config';
44
import { dateToUnixTimestamp } from '../../lib/util/time';
55

66
describe('Companies', () => {
77
let createdCompany: CompanyObject;
8+
let contactId: string;
9+
10+
before(async () => {
11+
const randomContacts = await client.contacts.list({
12+
perPage: 1,
13+
});
14+
15+
contactId = randomContacts.data[0].id;
16+
});
17+
818
const client = new Client({ tokenAuth: { token } });
919

1020
it('create', async () => {

test/integration/conversations.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
MessageObject,
1010
} from '../../dist';
1111
import assert from 'assert';
12-
import { token, adminId } from './utils/config';
12+
import { token } from './utils/config';
1313
import { randomString } from './utils/random';
1414

1515
describe('Conversations', () => {
@@ -18,11 +18,17 @@ describe('Conversations', () => {
1818
let createdConversation: MessageObject;
1919
let foundConversation: ConversationObject;
2020

21-
const anotherAdminId = '4868';
21+
let adminId: string;
22+
let anotherAdminId: string;
2223

2324
const client = new Client({ tokenAuth: { token } });
2425

2526
before(async () => {
27+
const admins = await client.admins.list();
28+
29+
adminId = admins.admins[0].id;
30+
anotherAdminId = admins.admins[1].id;
31+
2632
user = await client.contacts.createUser({
2733
externalId: randomString(),
2834
name: 'Baba Booey',

test/integration/events.test.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,38 @@
1-
import { Client } from '../../dist';
1+
import { Client, Operators, Role } from '../../dist';
22
import { dateToUnixTimestamp } from '../../dist/util/time';
33
import assert from 'assert';
4-
import { token, userId } from './utils/config';
4+
import { token } from './utils/config';
55

66
describe('Events', () => {
7+
let userId: string;
8+
9+
before(async () => {
10+
const randomUsers = await client.contacts.search({
11+
data: {
12+
query: {
13+
operator: Operators.AND,
14+
value: [
15+
{
16+
field: 'role',
17+
operator: Operators.EQUALS,
18+
value: Role.USER,
19+
},
20+
{
21+
field: 'external_id',
22+
operator: Operators.NOT_EQUALS,
23+
value: null,
24+
},
25+
],
26+
},
27+
pagination: {
28+
per_page: 1,
29+
},
30+
},
31+
});
32+
33+
userId = randomUsers.data[0].external_id;
34+
});
35+
736
const client = new Client({ tokenAuth: { token } });
837

938
it('create', async () => {

test/integration/helpCenter/sections.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import { Client, SectionObject } from '../../../dist';
22
import assert from 'assert';
3-
import { parentId, token } from '../utils/config';
3+
import { token } from '../utils/config';
44
import { randomString } from '../utils/random';
55

6-
describe('Collections', () => {
6+
describe('Sections', () => {
77
let section: SectionObject;
8+
let parentId: string;
9+
10+
before(async () => {
11+
const randomCollections = await client.helpCenter.collections.list({
12+
perPage: 1,
13+
});
14+
15+
parentId = randomCollections.data[0].id;
16+
});
817

918
const client = new Client({ tokenAuth: { token } });
1019

test/integration/integration.test.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
import { Client, ContactObject, MessageObject } from '../../dist';
22
import assert from 'assert';
3-
import { adminId, companyId, token } from './utils/config';
3+
import { token } from './utils/config';
44
import { randomInt } from 'crypto';
55

66
describe('Integration between Contact, Conversation, Company and Tag APIs', () => {
7-
let user: ContactObject;
8-
let lead: ContactObject;
7+
let adminId: string;
98
let contact: ContactObject;
109
let conversation: MessageObject;
10+
let companyId: string;
11+
let lead: ContactObject;
12+
let user: ContactObject;
13+
14+
before(async () => {
15+
const randomCompanies = await client.companies.list({
16+
perPage: 1,
17+
});
18+
const admins = await client.admins.list();
19+
20+
adminId = admins.admins[0].id;
21+
companyId = randomCompanies.data[0].id;
22+
});
1123

1224
const client = new Client({ tokenAuth: { token } });
1325

test/integration/notes.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
import { Client, NoteObject } from '../../dist';
22
import assert from 'assert';
3-
import { adminId, contactId, token } from './utils/config';
3+
import { token } from './utils/config';
44
import { randomString } from './utils/random';
55

66
describe('Notes', () => {
7+
let adminId: string;
8+
let contactId: string;
79
let note: NoteObject;
810

11+
before(async () => {
12+
const randomContacts = await client.contacts.list({
13+
perPage: 1,
14+
});
15+
const admins = await client.admins.list();
16+
17+
adminId = admins.admins[0].id;
18+
contactId = randomContacts.data[0].id;
19+
});
20+
921
const client = new Client({ tokenAuth: { token } });
1022

1123
it('create', async () => {

test/integration/segments.test.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import { Client } from '../../dist';
22
import assert from 'assert';
3-
import { segmentId, token } from './utils/config';
3+
import { token } from './utils/config';
44

55
describe('Segments', () => {
6+
let segmentId: string;
7+
68
const client = new Client({ tokenAuth: { token } });
79

8-
it('find', async () => {
9-
const response = await client.segments.find({ id: segmentId });
10+
it('list', async () => {
11+
const response = await client.segments.list({ includeCount: true });
12+
13+
segmentId = response.segments[0].id;
1014

1115
assert.notEqual(response, undefined);
1216
});
13-
it('list', async () => {
14-
const response = await client.segments.list({ includeCount: true });
17+
it('find', async () => {
18+
const response = await client.segments.find({ id: segmentId });
1519

1620
assert.notEqual(response, undefined);
1721
});

test/integration/tags.test.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
import { Client, TagObject } from '../../dist';
22
import assert from 'assert';
3-
import {
4-
token,
5-
adminId,
6-
contactId,
7-
conversationId,
8-
companyId,
9-
} from './utils/config';
3+
import { token } from './utils/config';
104

115
describe('Tags', () => {
6+
let adminId: string;
7+
let conversationId: string;
8+
let companyId: string;
9+
let contactId: string;
1210
let tag: TagObject;
1311

12+
before(async () => {
13+
const randomAdmins = await client.admins.list();
14+
const randomConversations = await client.conversations.list({
15+
perPage: 1,
16+
});
17+
const randomCompanies = await client.companies.list({
18+
perPage: 1,
19+
});
20+
const randomContacts = await client.contacts.list({
21+
perPage: 1,
22+
});
23+
24+
adminId = randomAdmins.admins[0].id;
25+
conversationId = randomConversations.conversations[0].id;
26+
companyId = randomCompanies.data[0].id;
27+
contactId = randomContacts.data[0].id;
28+
});
29+
1430
const client = new Client({ tokenAuth: { token } });
1531

1632
it('create', async () => {

0 commit comments

Comments
 (0)