@insignia-education/api-sdk-js 0.15.71 → 0.15.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -2
- package/src/api/v1/Courses.js +4 -4
- package/src/api/v1/Employee.js +2 -0
- package/src/api/v1/Users.js +7 -0
- package/.ai/guidelines/research-order.md +0 -29
- package/.claude/agents/product-spec-architect.md +0 -163
- package/.claude/agents/senior-code-reviewer.md +0 -109
- package/.claude/agents/senior-software-developer.md +0 -90
- package/.claude/agents/senior-software-maintainer.md +0 -121
- package/.claude/skills/general/documentation/SKILL.md +0 -49
- package/.claude/skills/general/handoff/SKILL.md +0 -15
- package/.claude/skills/general/investigation/SKILL.md +0 -53
- package/.claude/skills/general/performance/SKILL.md +0 -31
- package/.claude/skills/git/pull-request/SKILL.md +0 -47
- package/.claude/skills/how-to-create-skills/SKILL.md +0 -82
- package/.github/hooks/pre-commit +0 -22
- package/.github/workflows/npm-publish-github-packages.yml +0 -29
- package/.nvmrc +0 -1
- package/AGENTS.md +0 -140
- package/CLAUDE.md +0 -51
- package/babel.config.cjs +0 -1
- package/eslint.config.mjs +0 -29
- package/jest.config.mjs +0 -47
- package/scss/Services/_notification.scss +0 -0
- package/scss/index.scss +0 -2
- package/tests/client.test.js +0 -265
- package/tests/helpers.js +0 -21
- package/tests/integration/api/v1/accounts.test.js +0 -31
- package/tests/integration/api/v1/auth/login.test.js +0 -44
- package/tests/integration/api/v1/changelogs.test.js +0 -21
- package/tests/integration/api/v1/contact-forms.test.js +0 -24
- package/tests/integration/api/v1/conversational-topics.test.js +0 -17
- package/tests/integration/api/v1/countries.test.js +0 -20
- package/tests/integration/api/v1/coupons.test.js +0 -19
- package/tests/integration/api/v1/courses/by-cod.test.js +0 -19
- package/tests/integration/api/v1/courses/index.test.js +0 -46
- package/tests/integration/api/v1/currencies/history.test.js +0 -23
- package/tests/integration/api/v1/currencies/index.test.js +0 -24
- package/tests/integration/api/v1/currencies/values.test.js +0 -24
- package/tests/integration/api/v1/files.test.js +0 -42
- package/tests/integration/api/v1/forums/index.test.js +0 -23
- package/tests/integration/api/v1/hashes.test.js +0 -18
- package/tests/integration/api/v1/insignias.test.js +0 -19
- package/tests/integration/api/v1/languages.test.js +0 -28
- package/tests/integration/api/v1/mail-blacklist.test.js +0 -19
- package/tests/integration/api/v1/offers.test.js +0 -20
- package/tests/integration/api/v1/organizations.test.js +0 -89
- package/tests/integration/api/v1/payment-methods/by-currencies.test.js +0 -51
- package/tests/integration/api/v1/quizzes/index.test.js +0 -37
- package/tests/integration/api/v1/short-links.test.js +0 -20
- package/tests/integration/api/v1/surveys/index.test.js +0 -40
- package/tests/integration/api/v1/taxes.test.js +0 -19
- package/tests/integration/api/v1/teacher/index.test.js +0 -53
- package/tests/integration/api/v1/telegram.test.js +0 -33
- package/tests/integration/api/v1/user-types.test.js +0 -17
- package/tests/integration/api/v1/users/cash-receivers.test.js +0 -19
- package/tests/integration/api/v1/users/index.test.js +0 -32
- package/tests/integration/api/v1/users/telegram.test.js +0 -36
- package/tests/integration/api/v1/zoom.test.js +0 -17
- package/tests/integration/loadEnv.js +0 -16
package/tests/client.test.js
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import InsigniaClient from '../src/Client.js';
|
|
2
|
-
import Users from '../src/api/v1/Users.js';
|
|
3
|
-
|
|
4
|
-
const BASE = 'http://localhost:8000';
|
|
5
|
-
|
|
6
|
-
function mockFetch(json = {}) {
|
|
7
|
-
return jest.fn().mockResolvedValue({ ok: true, status: 200, json: () => Promise.resolve(json) });
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
delete process.env.INSIGNIA_EDUCATION_API_BASE_URL;
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
afterEach(() => {
|
|
15
|
-
delete global.fetch;
|
|
16
|
-
delete process.env.INSIGNIA_EDUCATION_API_BASE_URL;
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
// ─── baseUrl resolution ───────────────────────────────────────────────────────
|
|
20
|
-
|
|
21
|
-
describe('baseUrl resolution', () => {
|
|
22
|
-
test('uses explicit baseUrl when provided', async () => {
|
|
23
|
-
global.fetch = mockFetch();
|
|
24
|
-
const client = new InsigniaClient('https://custom.example.com');
|
|
25
|
-
await client.get('/test');
|
|
26
|
-
expect(global.fetch).toHaveBeenCalledWith(
|
|
27
|
-
'https://custom.example.com/test',
|
|
28
|
-
expect.any(Object)
|
|
29
|
-
);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('strips trailing slash from explicit baseUrl', async () => {
|
|
33
|
-
global.fetch = mockFetch();
|
|
34
|
-
const client = new InsigniaClient('https://custom.example.com/');
|
|
35
|
-
await client.get('/test');
|
|
36
|
-
expect(global.fetch).toHaveBeenCalledWith(
|
|
37
|
-
'https://custom.example.com/test',
|
|
38
|
-
expect.any(Object)
|
|
39
|
-
);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('uses INSIGNIA_EDUCATION_API_BASE_URL env var when baseUrl is null', async () => {
|
|
43
|
-
process.env.INSIGNIA_EDUCATION_API_BASE_URL = 'https://env.example.com';
|
|
44
|
-
global.fetch = mockFetch();
|
|
45
|
-
const client = new InsigniaClient(null);
|
|
46
|
-
await client.get('/test');
|
|
47
|
-
expect(global.fetch).toHaveBeenCalledWith(
|
|
48
|
-
'https://env.example.com/test',
|
|
49
|
-
expect.any(Object)
|
|
50
|
-
);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test('baseUrl getter exposes the resolved base URL', () => {
|
|
54
|
-
const client = new InsigniaClient('https://custom.example.com/');
|
|
55
|
-
expect(client.baseUrl).toBe('https://custom.example.com');
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test('falls back to https://insigniaeducation.com when baseUrl is null and env var is not set', async () => {
|
|
59
|
-
global.fetch = mockFetch();
|
|
60
|
-
const client = new InsigniaClient(null);
|
|
61
|
-
await client.get('/test');
|
|
62
|
-
expect(global.fetch).toHaveBeenCalledWith(
|
|
63
|
-
'https://insigniaeducation.com/test',
|
|
64
|
-
expect.any(Object)
|
|
65
|
-
);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test('falls back to default when constructed with no arguments', async () => {
|
|
69
|
-
global.fetch = mockFetch();
|
|
70
|
-
const client = new InsigniaClient();
|
|
71
|
-
await client.get('/test');
|
|
72
|
-
expect(global.fetch).toHaveBeenCalledWith(
|
|
73
|
-
'https://insigniaeducation.com/test',
|
|
74
|
-
expect.any(Object)
|
|
75
|
-
);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
test('explicit baseUrl takes precedence over env var', async () => {
|
|
79
|
-
process.env.INSIGNIA_EDUCATION_API_BASE_URL = 'https://env.example.com';
|
|
80
|
-
global.fetch = mockFetch();
|
|
81
|
-
const client = new InsigniaClient('https://explicit.example.com');
|
|
82
|
-
await client.get('/test');
|
|
83
|
-
expect(global.fetch).toHaveBeenCalledWith(
|
|
84
|
-
'https://explicit.example.com/test',
|
|
85
|
-
expect.any(Object)
|
|
86
|
-
);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test('falls back to default when process is undefined', async () => {
|
|
90
|
-
const saved = global.process;
|
|
91
|
-
global.process = undefined;
|
|
92
|
-
global.fetch = mockFetch();
|
|
93
|
-
const client = new InsigniaClient(null);
|
|
94
|
-
await client.get('/test');
|
|
95
|
-
expect(global.fetch).toHaveBeenCalledWith(
|
|
96
|
-
'https://insigniaeducation.com/test',
|
|
97
|
-
expect.any(Object)
|
|
98
|
-
);
|
|
99
|
-
global.process = saved;
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
// ─── HTTP methods ─────────────────────────────────────────────────────────────
|
|
104
|
-
|
|
105
|
-
describe('HTTP methods', () => {
|
|
106
|
-
let client;
|
|
107
|
-
|
|
108
|
-
beforeEach(() => {
|
|
109
|
-
global.fetch = mockFetch();
|
|
110
|
-
client = new InsigniaClient(BASE);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
test('get() sends GET with no body', async () => {
|
|
114
|
-
await client.get('/path');
|
|
115
|
-
const [url, options] = global.fetch.mock.calls[0];
|
|
116
|
-
expect(url).toBe(`${BASE}/path`);
|
|
117
|
-
expect(options.method).toBe('GET');
|
|
118
|
-
expect(options.body).toBeUndefined();
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
test('post() sends POST with body', async () => {
|
|
122
|
-
await client.post('/path', { key: 'val' });
|
|
123
|
-
const [url, options] = global.fetch.mock.calls[0];
|
|
124
|
-
expect(url).toBe(`${BASE}/path`);
|
|
125
|
-
expect(options.method).toBe('POST');
|
|
126
|
-
expect(options.body).toBe(JSON.stringify({ key: 'val' }));
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
test('post() sends POST with no body when not provided', async () => {
|
|
130
|
-
await client.post('/path');
|
|
131
|
-
const [, options] = global.fetch.mock.calls[0];
|
|
132
|
-
expect(options.method).toBe('POST');
|
|
133
|
-
expect(options.body).toBeUndefined();
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
test('put() sends PUT with body', async () => {
|
|
137
|
-
await client.put('/path', { key: 'val' });
|
|
138
|
-
const [url, options] = global.fetch.mock.calls[0];
|
|
139
|
-
expect(url).toBe(`${BASE}/path`);
|
|
140
|
-
expect(options.method).toBe('PUT');
|
|
141
|
-
expect(options.body).toBe(JSON.stringify({ key: 'val' }));
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
test('put() sends PUT with no body when not provided', async () => {
|
|
145
|
-
await client.put('/path');
|
|
146
|
-
const [, options] = global.fetch.mock.calls[0];
|
|
147
|
-
expect(options.method).toBe('PUT');
|
|
148
|
-
expect(options.body).toBeUndefined();
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
test('patch() sends PATCH with body', async () => {
|
|
152
|
-
await client.patch('/path', { key: 'val' });
|
|
153
|
-
const [url, options] = global.fetch.mock.calls[0];
|
|
154
|
-
expect(url).toBe(`${BASE}/path`);
|
|
155
|
-
expect(options.method).toBe('PATCH');
|
|
156
|
-
expect(options.body).toBe(JSON.stringify({ key: 'val' }));
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
test('patch() sends PATCH with no body when not provided', async () => {
|
|
160
|
-
await client.patch('/path');
|
|
161
|
-
const [, options] = global.fetch.mock.calls[0];
|
|
162
|
-
expect(options.method).toBe('PATCH');
|
|
163
|
-
expect(options.body).toBeUndefined();
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
test('del() sends DELETE with no body', async () => {
|
|
167
|
-
await client.del('/path');
|
|
168
|
-
const [url, options] = global.fetch.mock.calls[0];
|
|
169
|
-
expect(url).toBe(`${BASE}/path`);
|
|
170
|
-
expect(options.method).toBe('DELETE');
|
|
171
|
-
expect(options.body).toBeUndefined();
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
test('JSON headers are always sent', async () => {
|
|
175
|
-
await client.get('/path');
|
|
176
|
-
const [, options] = global.fetch.mock.calls[0];
|
|
177
|
-
expect(options.headers.Accept).toBe('application/json');
|
|
178
|
-
expect(options.headers['Content-Type']).toBe('application/json');
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
test('credentials is always include', async () => {
|
|
182
|
-
await client.get('/path');
|
|
183
|
-
const [, options] = global.fetch.mock.calls[0];
|
|
184
|
-
expect(options.credentials).toBe('include');
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
test('stores response cookies and sends them on later requests in Node', async () => {
|
|
188
|
-
global.fetch = jest.fn()
|
|
189
|
-
.mockResolvedValueOnce({
|
|
190
|
-
ok: true,
|
|
191
|
-
status: 200,
|
|
192
|
-
headers: {
|
|
193
|
-
getSetCookie: () => ['token=abc123; Path=/; HttpOnly; Secure; SameSite=Lax'],
|
|
194
|
-
},
|
|
195
|
-
json: () => Promise.resolve({ success: 'ok' }),
|
|
196
|
-
})
|
|
197
|
-
.mockResolvedValueOnce({
|
|
198
|
-
ok: true,
|
|
199
|
-
status: 200,
|
|
200
|
-
json: () => Promise.resolve({ id: 1, title: 'test' }),
|
|
201
|
-
});
|
|
202
|
-
client = new InsigniaClient(BASE);
|
|
203
|
-
|
|
204
|
-
await client.post('/auth/login', { email: 'admin@example.com', password: 'secret' });
|
|
205
|
-
await client.get('/accounts');
|
|
206
|
-
|
|
207
|
-
const [, options] = global.fetch.mock.calls[1];
|
|
208
|
-
expect(options.headers.Cookie).toBe('token=abc123');
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
test('returns parsed JSON from response', async () => {
|
|
212
|
-
global.fetch = jest.fn().mockResolvedValue({
|
|
213
|
-
ok: true,
|
|
214
|
-
status: 200,
|
|
215
|
-
json: () => Promise.resolve({ id: 1, name: 'test' }),
|
|
216
|
-
});
|
|
217
|
-
client = new InsigniaClient(BASE);
|
|
218
|
-
const result = await client.get('/path');
|
|
219
|
-
expect(result).toEqual({ id: 1, name: 'test' });
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
test('returns null for empty response text', async () => {
|
|
223
|
-
global.fetch = jest.fn().mockResolvedValue({
|
|
224
|
-
ok: true,
|
|
225
|
-
status: 200,
|
|
226
|
-
text: () => Promise.resolve(''),
|
|
227
|
-
});
|
|
228
|
-
client = new InsigniaClient(BASE);
|
|
229
|
-
const result = await client.get('/path');
|
|
230
|
-
expect(result).toBeNull();
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
test('returns null for no-content responses', async () => {
|
|
234
|
-
global.fetch = jest.fn().mockResolvedValue({
|
|
235
|
-
ok: true,
|
|
236
|
-
status: 204,
|
|
237
|
-
json: jest.fn(),
|
|
238
|
-
});
|
|
239
|
-
client = new InsigniaClient(BASE);
|
|
240
|
-
const result = await client.del('/path');
|
|
241
|
-
expect(result).toBeNull();
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
test('returns null when json parsing fails because the response is empty', async () => {
|
|
245
|
-
global.fetch = jest.fn().mockResolvedValue({
|
|
246
|
-
ok: true,
|
|
247
|
-
status: 200,
|
|
248
|
-
json: () => Promise.reject(new SyntaxError('Unexpected end of JSON input')),
|
|
249
|
-
});
|
|
250
|
-
client = new InsigniaClient(BASE);
|
|
251
|
-
const result = await client.get('/path');
|
|
252
|
-
expect(result).toBeNull();
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
// ─── payments(userId).invoiceUrl ──────────────────────────────────────────────
|
|
257
|
-
// A direct link, not a fetch — no HTTP call to mock/assert on, just the URL shape.
|
|
258
|
-
|
|
259
|
-
describe('Users.payments(userId).invoiceUrl', () => {
|
|
260
|
-
test('builds a direct link to the invoice endpoint', () => {
|
|
261
|
-
const client = new InsigniaClient(BASE);
|
|
262
|
-
const users = new Users(client);
|
|
263
|
-
expect(users.payments(42).invoiceUrl(7)).toBe(`${BASE}/users/42/payments/7/invoice`);
|
|
264
|
-
});
|
|
265
|
-
});
|
package/tests/helpers.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import InsigniaApiV1 from '../src/api/v1/index.js';
|
|
2
|
-
|
|
3
|
-
export const api = new InsigniaApiV1(process.env.INSIGNIA_EDUCATION_API_BASE_URL);
|
|
4
|
-
|
|
5
|
-
// captcha_token is required by LoginRequest; relies on the local API's TURNSTILE_SECRET_KEY
|
|
6
|
-
// being set to Cloudflare's documented "always passes" testing secret
|
|
7
|
-
// (1x0000000000000000000000000000000AA), which accepts any token value.
|
|
8
|
-
export const loginCustomer = () => api.auth.login({
|
|
9
|
-
email: process.env.TEST_EMAIL,
|
|
10
|
-
password: process.env.TEST_PASSWORD,
|
|
11
|
-
captcha_token: 'test',
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
export const loginAdmin = () => api.auth.login({
|
|
15
|
-
email: process.env.TEST_EMAIL_ADMIN,
|
|
16
|
-
password: process.env.TEST_PASSWORD_ADMIN,
|
|
17
|
-
captcha_token: 'test',
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const logout = () => api.auth.logout();
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
api,
|
|
3
|
-
loginCustomer,
|
|
4
|
-
loginAdmin
|
|
5
|
-
} from '../../../helpers.js';
|
|
6
|
-
|
|
7
|
-
describe('api/v1/accounts', () => {
|
|
8
|
-
// Client#request() throws on non-2xx (err.status, err.data) rather than
|
|
9
|
-
// resolving — assert against a rejected promise, not a resolved
|
|
10
|
-
// {success, status}.
|
|
11
|
-
test('get | unauthenticated', async () => {
|
|
12
|
-
await expect(api.accounts.get()).rejects.toMatchObject({ status: 401 });
|
|
13
|
-
});
|
|
14
|
-
test('get | authenticated but other type', async () => {
|
|
15
|
-
await loginCustomer();
|
|
16
|
-
await expect(api.accounts.get()).rejects.toMatchObject({ status: 403 });
|
|
17
|
-
});
|
|
18
|
-
test('get | authenticated', async () => {
|
|
19
|
-
await loginAdmin();
|
|
20
|
-
await api.accounts.get()
|
|
21
|
-
.then(response => {
|
|
22
|
-
response = Object.values(response);
|
|
23
|
-
expect(response.length > 0).toBe(true);
|
|
24
|
-
response.forEach(account => {
|
|
25
|
-
expect(account["id"]).toBeDefined();
|
|
26
|
-
expect(account["cod"]).toBeDefined();
|
|
27
|
-
expect(account["title"]).toBeDefined();
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
api,
|
|
3
|
-
loginAdmin,
|
|
4
|
-
} from '../../../../helpers.js';
|
|
5
|
-
|
|
6
|
-
describe('api/v1/auth/login', () => {
|
|
7
|
-
// Client#request() throws on non-2xx (err.status, err.data) rather than
|
|
8
|
-
// resolving — assert against a rejected promise, not a resolved
|
|
9
|
-
// {success, status, errors}. Also no logout() before these — a fresh
|
|
10
|
-
// `api` client (one per test file) starts out unauthenticated, and
|
|
11
|
-
// logout() itself throws 401 when there's no session to clear.
|
|
12
|
-
test('POST | failure | no email validation', async () => {
|
|
13
|
-
const password = process.env.TEST_PASSWORD;
|
|
14
|
-
await expect(api.auth.login({ password })).rejects.toMatchObject({
|
|
15
|
-
status: 422,
|
|
16
|
-
data: { errors: expect.objectContaining({ email: expect.anything() }) },
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('POST | failure | no password validation', async () => {
|
|
21
|
-
const email = process.env.TEST_EMAIL;
|
|
22
|
-
await expect(api.auth.login({ email })).rejects.toMatchObject({
|
|
23
|
-
status: 422,
|
|
24
|
-
data: { errors: expect.objectContaining({ password: expect.anything() }) },
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('POST | success', async () => {
|
|
29
|
-
await loginAdmin()
|
|
30
|
-
.then(response => {
|
|
31
|
-
expect(response["success"]).toBeDefined();
|
|
32
|
-
expect(response["success"]).toBe("ok");
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('POST | double login', async () => {
|
|
37
|
-
await loginAdmin()
|
|
38
|
-
.then(() => loginAdmin()
|
|
39
|
-
.then(response => {
|
|
40
|
-
expect(response["success"]).toBeDefined();
|
|
41
|
-
expect(response["success"]).toBe("ok");
|
|
42
|
-
}));
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
api,
|
|
3
|
-
loginCustomer,
|
|
4
|
-
loginAdmin
|
|
5
|
-
} from '../../../helpers.js';
|
|
6
|
-
|
|
7
|
-
describe('api/v1/changelogs', () => {
|
|
8
|
-
test('get | authenticated', async () => {
|
|
9
|
-
await loginAdmin();
|
|
10
|
-
await api.changelogs.get()
|
|
11
|
-
.then(response => {
|
|
12
|
-
response = Object.values(response);
|
|
13
|
-
expect(Array.isArray(response)).toBe(true);
|
|
14
|
-
response.forEach(changelog => {
|
|
15
|
-
expect(changelog["id"]).toBeDefined();
|
|
16
|
-
expect(changelog["created_at"]).toBeDefined();
|
|
17
|
-
expect(changelog["updated_at"]).toBeDefined();
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
api,
|
|
3
|
-
loginCustomer,
|
|
4
|
-
loginAdmin
|
|
5
|
-
} from '../../../helpers.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
describe('api/v1/contact-forms', () => {
|
|
9
|
-
test('get | authenticated', async () => {
|
|
10
|
-
await loginAdmin();
|
|
11
|
-
await api.contactForms.get()
|
|
12
|
-
.then(response => {
|
|
13
|
-
response = Object.values(response);
|
|
14
|
-
expect(Array.isArray(response)).toBe(true);
|
|
15
|
-
response.forEach(form => {
|
|
16
|
-
expect(form["id"]).toBeDefined();
|
|
17
|
-
expect(form["name"]).toBeDefined();
|
|
18
|
-
expect(form["email"]).toBeDefined();
|
|
19
|
-
expect(form["message"]).toBeDefined();
|
|
20
|
-
expect(form["created_at"]).toBeDefined();
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { api, loginAdmin } from '../../../helpers.js';
|
|
2
|
-
|
|
3
|
-
describe('api/v1/conversational-topics', () => {
|
|
4
|
-
test('get', async () => {
|
|
5
|
-
await loginAdmin();
|
|
6
|
-
await api.conversationalTopics.get()
|
|
7
|
-
.then(response => {
|
|
8
|
-
response = Object.values(response);
|
|
9
|
-
expect(response.length > 0).toBe(true);
|
|
10
|
-
response.forEach(topic => {
|
|
11
|
-
expect(topic["id"]).toBeDefined();
|
|
12
|
-
expect(topic["title"]).toBeDefined();
|
|
13
|
-
expect(topic["date"]).toBeDefined();
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import InsigniaApiV1 from '../../../../src/api/v1/index.js';
|
|
3
|
-
|
|
4
|
-
const api = new InsigniaApiV1(process.env.INSIGNIA_EDUCATION_API_BASE_URL);
|
|
5
|
-
|
|
6
|
-
describe('api/v1/countries', () => {
|
|
7
|
-
test('get', async () => {
|
|
8
|
-
await api.countries.get()
|
|
9
|
-
.then(response => {
|
|
10
|
-
response = Object.values(response);
|
|
11
|
-
expect(response.length > 0).toBe(true);
|
|
12
|
-
response.forEach(country => {
|
|
13
|
-
expect(country["id"]).toBeDefined();
|
|
14
|
-
expect(country["cod"]).toBeDefined();
|
|
15
|
-
expect(country["domain"]).toBeDefined();
|
|
16
|
-
expect(country["phone_prefix"]).toBeDefined();
|
|
17
|
-
})
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { api, loginAdmin } from '../../../helpers.js';
|
|
2
|
-
|
|
3
|
-
describe('api/v1/coupons', () => {
|
|
4
|
-
test('get | authenticated', async () => {
|
|
5
|
-
await loginAdmin();
|
|
6
|
-
await api.coupons.get()
|
|
7
|
-
.then(response => {
|
|
8
|
-
response = Object.values(response);
|
|
9
|
-
expect(Array.isArray(response)).toBe(true);
|
|
10
|
-
response.forEach(coupon => {
|
|
11
|
-
expect(coupon["id"]).toBeDefined();
|
|
12
|
-
expect(coupon["cod"]).toBeDefined();
|
|
13
|
-
expect(coupon["enabled"]).toBeDefined();
|
|
14
|
-
expect(coupon["created_at"]).toBeDefined();
|
|
15
|
-
expect(coupon["updated_at"]).toBeDefined();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
api,
|
|
3
|
-
loginCustomer,
|
|
4
|
-
loginAdmin
|
|
5
|
-
} from '../../../../helpers.js';
|
|
6
|
-
|
|
7
|
-
describe('api/v1/courses/cod/:cod', () => {
|
|
8
|
-
test('get by cod | returns matching course', async () => {
|
|
9
|
-
const firstPage = await api.courses.get();
|
|
10
|
-
const cod = firstPage["data"][0]["cod"];
|
|
11
|
-
await api.courses.getByCod(cod)
|
|
12
|
-
.then(response => {
|
|
13
|
-
expect(response["id"]).toBeDefined();
|
|
14
|
-
expect(response["cod"]).toBe(cod);
|
|
15
|
-
expect(response["title"]).toBeDefined();
|
|
16
|
-
expect(response["enabled"]).toBeDefined();
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
api,
|
|
3
|
-
loginCustomer,
|
|
4
|
-
loginAdmin
|
|
5
|
-
} from '../../../../helpers.js';
|
|
6
|
-
|
|
7
|
-
describe('api/v1/courses', () => {
|
|
8
|
-
test('get | returns paginated list', async () => {
|
|
9
|
-
await api.courses.get()
|
|
10
|
-
.then(response => {
|
|
11
|
-
console.log(response);
|
|
12
|
-
expect(response["data"]).toBeDefined();
|
|
13
|
-
expect(response["current_page"]).toBeDefined();
|
|
14
|
-
expect(response["last_page"]).toBeDefined();
|
|
15
|
-
expect(response["per_page"]).toBeDefined();
|
|
16
|
-
expect(response["total"]).toBeDefined();
|
|
17
|
-
expect(Array.isArray(response["data"])).toBe(true);
|
|
18
|
-
expect(response["data"].length > 0).toBe(true);
|
|
19
|
-
response["data"].forEach(course => {
|
|
20
|
-
expect(course["id"]).toBeDefined();
|
|
21
|
-
expect(course["cod"]).toBeDefined();
|
|
22
|
-
expect(course["title"]).toBeDefined();
|
|
23
|
-
expect(course["enabled"]).toBeDefined();
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('get | page 2', async () => {
|
|
29
|
-
await api.courses.get(null, { page: 2 })
|
|
30
|
-
.then(response => {
|
|
31
|
-
expect(response["data"]).toBeDefined();
|
|
32
|
-
expect(response["current_page"]).toBe(2);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('get by id | returns single course', async () => {
|
|
37
|
-
const firstPage = await api.courses.get();
|
|
38
|
-
const id = firstPage["data"][0]["id"];
|
|
39
|
-
await api.courses.get(id)
|
|
40
|
-
.then(response => {
|
|
41
|
-
expect(response["id"]).toBe(id);
|
|
42
|
-
expect(response["cod"]).toBeDefined();
|
|
43
|
-
expect(response["title"]).toBeDefined();
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
api,
|
|
3
|
-
loginCustomer,
|
|
4
|
-
loginAdmin
|
|
5
|
-
} from '../../../../helpers.js';
|
|
6
|
-
|
|
7
|
-
describe('api/v1/currencies/{id}/history', () => {
|
|
8
|
-
|
|
9
|
-
test('get', async () => {
|
|
10
|
-
await loginAdmin();
|
|
11
|
-
await api.currencies.getHistory(1)
|
|
12
|
-
.then(response => {
|
|
13
|
-
response = Object.values(response);
|
|
14
|
-
response.forEach(value => {
|
|
15
|
-
expect(value["id"]).toBeDefined();
|
|
16
|
-
expect(value["currency_id"]).toBeDefined();
|
|
17
|
-
expect(value["value"]).toBeDefined();
|
|
18
|
-
expect(value["created_at"]).toBeDefined();
|
|
19
|
-
expect(value["updated_at"]).toBeDefined();
|
|
20
|
-
})
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
api,
|
|
3
|
-
loginCustomer,
|
|
4
|
-
loginAdmin
|
|
5
|
-
} from '../../../../helpers.js';
|
|
6
|
-
|
|
7
|
-
describe('api/v1/currencies', () => {
|
|
8
|
-
test('get', async () => {
|
|
9
|
-
await api.currencies.get()
|
|
10
|
-
.then(response => {
|
|
11
|
-
expect(response["1"]).toBeDefined();
|
|
12
|
-
expect(response["1"]["id"]).toBeDefined();
|
|
13
|
-
expect(response["1"]["country_id"]).toBeDefined();
|
|
14
|
-
expect(response["1"]["cod"]).toBeDefined();
|
|
15
|
-
expect(response["1"]["title"]).toBeDefined();
|
|
16
|
-
expect(response["1"]["enabled"]).toBeDefined();
|
|
17
|
-
expect(response["1"]["has_double_expression"]).toBeDefined();
|
|
18
|
-
expect(response["1"]["double_expression_by"]).toBeDefined();
|
|
19
|
-
expect(response["1"]["created_at"]).toBeDefined();
|
|
20
|
-
expect(response["1"]["updated_at"]).toBeDefined();
|
|
21
|
-
expect(response["1"]["deleted_at"]).toBeDefined();
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
api,
|
|
3
|
-
loginCustomer,
|
|
4
|
-
loginAdmin
|
|
5
|
-
} from '../../../../helpers.js';
|
|
6
|
-
|
|
7
|
-
describe('api/v1/currencies/values', () => {
|
|
8
|
-
|
|
9
|
-
test('get', async () => {
|
|
10
|
-
await api.currencies.getValues()
|
|
11
|
-
.then(response => {
|
|
12
|
-
response = Object.values(response);
|
|
13
|
-
expect(response.length > 0).toBe(true);
|
|
14
|
-
response.forEach(value => {
|
|
15
|
-
expect(value["id"]).toBeDefined();
|
|
16
|
-
expect(value["currency_id"]).toBeDefined();
|
|
17
|
-
expect(value["value"]).toBeDefined();
|
|
18
|
-
expect(value["created_at"]).toBeDefined();
|
|
19
|
-
expect(value["updated_at"]).toBeDefined();
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Blob } from 'buffer';
|
|
2
|
-
import { api, loginAdmin } from '../../../helpers.js';
|
|
3
|
-
|
|
4
|
-
// A real 1x1 transparent PNG (67 bytes) — the upload endpoint sniffs actual
|
|
5
|
-
// file content, not just the claimed Content-Type, so arbitrary text with an
|
|
6
|
-
// 'image/png' MIME hint gets rejected with "Unsupported file type".
|
|
7
|
-
const PNG_1X1 = Buffer.from(
|
|
8
|
-
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=',
|
|
9
|
-
'base64'
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
describe('api/v1/files', () => {
|
|
13
|
-
// list() (paginated), not get() — get(id) requires an id and hits
|
|
14
|
-
// /files/{id}, unlike most other resources' get(id = null).
|
|
15
|
-
test('list | authenticated', async () => {
|
|
16
|
-
await loginAdmin();
|
|
17
|
-
await api.files.list()
|
|
18
|
-
.then(response => {
|
|
19
|
-
const files = response["data"];
|
|
20
|
-
expect(Array.isArray(files)).toBe(true);
|
|
21
|
-
files.forEach(file => {
|
|
22
|
-
expect(file["id"]).toBeDefined();
|
|
23
|
-
expect(file["created_at"]).toBeDefined();
|
|
24
|
-
expect(file["updated_at"]).toBeDefined();
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('upload | authenticated', async () => {
|
|
30
|
-
await loginAdmin();
|
|
31
|
-
const blob = new Blob([PNG_1X1], { type: 'image/png' });
|
|
32
|
-
const fd = new FormData();
|
|
33
|
-
fd.append('file', blob, 'test.png');
|
|
34
|
-
fd.append('type', 'uploads');
|
|
35
|
-
await api.files.upload(fd)
|
|
36
|
-
.then(response => {
|
|
37
|
-
expect(response).toBeDefined();
|
|
38
|
-
expect(response['url']).toBeDefined();
|
|
39
|
-
expect(response['id']).toBeDefined();
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|