@abyss-project/reflex 5.11.0 → 5.12.0
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/.eslintrc.js +32 -32
- package/.prettierrc +5 -5
- package/README.md +15 -15
- package/dist/types/interface/api/responses/service-version.response.d.ts +1 -0
- package/jest.config.ts +11 -11
- package/package.json +15 -10
- package/src/api/alert-rule.api.test.ts +72 -72
- package/src/api/alert-rule.api.ts +57 -57
- package/src/api/application-insights.api.test.ts +42 -42
- package/src/api/application-insights.api.ts +38 -38
- package/src/api/application-run-settings.api.test.ts +51 -51
- package/src/api/application-run-settings.api.ts +30 -30
- package/src/api/function-insights.api.test.ts +27 -27
- package/src/api/function-insights.api.ts +18 -18
- package/src/api/function-run.api.ts +38 -38
- package/src/api/function-settings.api.ts +74 -74
- package/src/api/function-test.api.ts +34 -34
- package/src/api/function.api.ts +62 -62
- package/src/api/health.api.ts +10 -10
- package/src/api/route-stats.api.test.ts +45 -45
- package/src/api/route-stats.api.ts +36 -36
- package/src/api/service-configuration.api.ts +16 -16
- package/src/api/service-deployment.api.ts +79 -79
- package/src/api/service-discord-event.api.test.ts +106 -106
- package/src/api/service-discord-event.api.ts +78 -78
- package/src/api/service-discord.api.test.ts +197 -197
- package/src/api/service-discord.api.ts +241 -241
- package/src/api/service-insights.api.test.ts +36 -36
- package/src/api/service-insights.api.ts +42 -42
- package/src/api/service-route.api.ts +72 -72
- package/src/api/service-task.api.test.ts +140 -140
- package/src/api/service-task.api.ts +141 -141
- package/src/api/service-version.api.ts +54 -54
- package/src/api/service.api.test.ts +215 -215
- package/src/api/service.api.ts +55 -55
- package/src/discord/discord-event-filter-cases.ts +261 -261
- package/src/discord/discord-event-filters.test.ts +91 -91
- package/src/discord/discord-event-filters.ts +95 -95
- package/src/discord/discord-event-intents.test.ts +112 -112
- package/src/discord/discord-event-intents.ts +55 -55
- package/src/discord/index.ts +3 -3
- package/src/index.test.ts +87 -87
- package/src/insights/index.ts +1 -1
- package/src/insights/percentiles.test.ts +75 -75
- package/src/insights/percentiles.ts +37 -37
- package/src/types/enum/access-grant-status.enum.ts +12 -12
- package/src/types/enum/access-kind.enum.ts +7 -7
- package/src/types/enum/bot-event-block-reason.enum.ts +7 -7
- package/src/types/enum/configuration-read-as.enum.ts +5 -5
- package/src/types/enum/discord-activity-type.enum.ts +9 -9
- package/src/types/enum/discord-channel-type.enum.ts +11 -11
- package/src/types/enum/discord-component-kind.enum.ts +7 -7
- package/src/types/enum/discord-event-drop-reason.enum.ts +13 -13
- package/src/types/enum/discord-event-filter-name.enum.ts +11 -11
- package/src/types/enum/discord-event-status.enum.ts +13 -13
- package/src/types/enum/discord-event-type.enum.ts +7 -7
- package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -11
- package/src/types/enum/discord-gateway-state.enum.ts +11 -11
- package/src/types/enum/discord-host-action.enum.ts +35 -35
- package/src/types/enum/discord-locale.enum.ts +35 -35
- package/src/types/enum/discord-option-type.enum.ts +12 -12
- package/src/types/enum/discord-presence-status.enum.ts +8 -8
- package/src/types/enum/discord-sync-status.enum.ts +6 -6
- package/src/types/enum/discord-token-state.enum.ts +11 -11
- package/src/types/enum/execution-mode.enum.ts +9 -9
- package/src/types/enum/execution-profile.enum.ts +20 -20
- package/src/types/enum/execution-settings-source.enum.ts +9 -9
- package/src/types/enum/health-status.enum.ts +4 -4
- package/src/types/enum/insights-period.enum.ts +8 -8
- package/src/types/enum/log-cap-mode.enum.ts +6 -6
- package/src/types/enum/log-drop-cause.enum.ts +8 -8
- package/src/types/enum/reflex-alert-metric.enum.ts +5 -5
- package/src/types/enum/reflex-alert-notification-state.enum.ts +6 -6
- package/src/types/enum/reflex-alert-scope.enum.ts +6 -6
- package/src/types/enum/reflex-error-code.enum.ts +43 -43
- package/src/types/enum/route-method.enum.ts +9 -9
- package/src/types/enum/run-log-level.enum.ts +6 -6
- package/src/types/enum/run-mode.enum.ts +11 -11
- package/src/types/enum/run-status.enum.ts +11 -11
- package/src/types/enum/run-step-status.enum.ts +7 -7
- package/src/types/enum/schedule-sync-status.enum.ts +6 -6
- package/src/types/enum/scheduled-run-failure-code.enum.ts +12 -12
- package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
- package/src/types/enum/scheduled-run-status.enum.ts +17 -17
- package/src/types/enum/service-deployment-action.enum.ts +11 -11
- package/src/types/enum/service-deployment-status.enum.ts +5 -5
- package/src/types/enum/service-type.enum.ts +9 -9
- package/src/types/enum/service-version-change-kind.enum.ts +6 -6
- package/src/types/enum/trace-effect-type.enum.ts +12 -12
- package/src/types/enum/trigger-access-mode.enum.ts +12 -12
- package/src/types/enum/trigger-kind.enum.ts +8 -8
- package/src/types/enum/vault-value-source.enum.ts +12 -12
- package/src/types/enum/vault-visibility.enum.ts +5 -5
- package/src/types/index.ts +2 -2
- package/src/types/interface/api/index.ts +3 -3
- package/src/types/interface/api/response.ts +4 -4
- package/src/types/interface/api/responses/service-version.response.ts +6 -0
- package/src/types/interface/health.response.ts +7 -7
- package/src/types/interface/index.ts +3 -3
- package/tsconfig.check.json +15 -15
- package/tsconfig.json +35 -35
|
@@ -1,197 +1,197 @@
|
|
|
1
|
-
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
-
import { AbyssReflexCore, DiscordComponentKind, DiscordOptionType } from '..';
|
|
3
|
-
|
|
4
|
-
const APP = 'app-1';
|
|
5
|
-
const SVC = 'svc-1';
|
|
6
|
-
const BASE = `api/service/${APP}/${SVC}`;
|
|
7
|
-
const SERVICE = { applicationId: APP, serviceId: SVC };
|
|
8
|
-
|
|
9
|
-
interface Call {
|
|
10
|
-
label: string;
|
|
11
|
-
method: string;
|
|
12
|
-
url: string;
|
|
13
|
-
body?: unknown;
|
|
14
|
-
run: () => Promise<unknown>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const discord = () => AbyssReflexCore.sdk.service.discord;
|
|
18
|
-
|
|
19
|
-
const command = {
|
|
20
|
-
name: 'ping',
|
|
21
|
-
description: 'Answers pong',
|
|
22
|
-
options: [
|
|
23
|
-
{
|
|
24
|
-
type: DiscordOptionType.STRING,
|
|
25
|
-
name: 'word',
|
|
26
|
-
description: 'A word',
|
|
27
|
-
required: true,
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
functionId: 'fn-1',
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const calls: Call[] = [
|
|
34
|
-
{
|
|
35
|
-
label: 'command.list',
|
|
36
|
-
method: 'get',
|
|
37
|
-
url: `${BASE}/discord/command`,
|
|
38
|
-
run: () => discord().command.list(SERVICE),
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
label: 'command.create',
|
|
42
|
-
method: 'post',
|
|
43
|
-
url: `${BASE}/discord/command`,
|
|
44
|
-
body: command,
|
|
45
|
-
run: () => discord().command.create(SERVICE, command),
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
label: 'command.update',
|
|
49
|
-
method: 'patch',
|
|
50
|
-
url: `${BASE}/discord/command/c-1`,
|
|
51
|
-
body: { description: 'Answers pong again' },
|
|
52
|
-
run: () =>
|
|
53
|
-
discord().command.update(
|
|
54
|
-
{ ...SERVICE, commandId: 'c-1' },
|
|
55
|
-
{ description: 'Answers pong again' },
|
|
56
|
-
),
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
label: 'command.delete',
|
|
60
|
-
method: 'delete',
|
|
61
|
-
url: `${BASE}/discord/command/c-1`,
|
|
62
|
-
run: () => discord().command.delete({ ...SERVICE, commandId: 'c-1' }),
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
label: 'component.list',
|
|
66
|
-
method: 'get',
|
|
67
|
-
url: `${BASE}/discord/component`,
|
|
68
|
-
run: () => discord().component.list(SERVICE),
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
label: 'component.create',
|
|
72
|
-
method: 'post',
|
|
73
|
-
url: `${BASE}/discord/component`,
|
|
74
|
-
body: {
|
|
75
|
-
customIdPrefix: 'confirm',
|
|
76
|
-
kind: DiscordComponentKind.BUTTON_OR_SELECT,
|
|
77
|
-
functionId: 'fn-1',
|
|
78
|
-
},
|
|
79
|
-
run: () =>
|
|
80
|
-
discord().component.create(SERVICE, {
|
|
81
|
-
customIdPrefix: 'confirm',
|
|
82
|
-
kind: DiscordComponentKind.BUTTON_OR_SELECT,
|
|
83
|
-
functionId: 'fn-1',
|
|
84
|
-
}),
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
label: 'component.update',
|
|
88
|
-
method: 'patch',
|
|
89
|
-
url: `${BASE}/discord/component/k-1`,
|
|
90
|
-
body: { kind: DiscordComponentKind.MODAL },
|
|
91
|
-
run: () =>
|
|
92
|
-
discord().component.update(
|
|
93
|
-
{ ...SERVICE, componentId: 'k-1' },
|
|
94
|
-
{ kind: DiscordComponentKind.MODAL },
|
|
95
|
-
),
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
label: 'component.delete',
|
|
99
|
-
method: 'delete',
|
|
100
|
-
url: `${BASE}/discord/component/k-1`,
|
|
101
|
-
run: () => discord().component.delete({ ...SERVICE, componentId: 'k-1' }),
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
label: 'connection.get',
|
|
105
|
-
method: 'get',
|
|
106
|
-
url: `${BASE}/discord/connection`,
|
|
107
|
-
run: () => discord().connection.get(SERVICE),
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
label: 'connection.setTokenSecret',
|
|
111
|
-
method: 'put',
|
|
112
|
-
url: `${BASE}/discord/connection`,
|
|
113
|
-
body: { discordTokenSecretId: 'secret-1' },
|
|
114
|
-
run: () => discord().connection.setTokenSecret(SERVICE, { discordTokenSecretId: 'secret-1' }),
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
label: 'connection.setEnvironment',
|
|
118
|
-
method: 'put',
|
|
119
|
-
url: `${BASE}/discord/connection/e-1`,
|
|
120
|
-
body: { testGuildId: '123456789012345678', invitePermissions: '2048' },
|
|
121
|
-
run: () =>
|
|
122
|
-
discord().connection.setEnvironment(
|
|
123
|
-
{ ...SERVICE, environmentId: 'e-1' },
|
|
124
|
-
{ testGuildId: '123456789012345678', invitePermissions: '2048' },
|
|
125
|
-
),
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
label: 'connection.setAllocation',
|
|
129
|
-
method: 'put',
|
|
130
|
-
url: `${BASE}/discord/connection/e-1/allocation`,
|
|
131
|
-
body: { lots: 3 },
|
|
132
|
-
run: () =>
|
|
133
|
-
discord().connection.setAllocation({ ...SERVICE, environmentId: 'e-1' }, { lots: 3 }),
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
label: 'connection.setBotSettings',
|
|
137
|
-
method: 'put',
|
|
138
|
-
url: `${BASE}/discord/connection/e-1/bot-settings`,
|
|
139
|
-
body: {
|
|
140
|
-
creditOverageEnabled: true,
|
|
141
|
-
monthlySpendCapCents: 2000,
|
|
142
|
-
alerts: { rate: { thresholds: [80], email: false } },
|
|
143
|
-
},
|
|
144
|
-
run: () =>
|
|
145
|
-
discord().connection.setBotSettings(
|
|
146
|
-
{ ...SERVICE, environmentId: 'e-1' },
|
|
147
|
-
{
|
|
148
|
-
creditOverageEnabled: true,
|
|
149
|
-
monthlySpendCapCents: 2000,
|
|
150
|
-
alerts: { rate: { thresholds: [80], email: false } },
|
|
151
|
-
},
|
|
152
|
-
),
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
label: 'connection.check',
|
|
156
|
-
method: 'post',
|
|
157
|
-
url: `${BASE}/discord/connection/e-1/check`,
|
|
158
|
-
body: {},
|
|
159
|
-
run: () => discord().connection.check({ ...SERVICE, environmentId: 'e-1' }),
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
label: 'sync',
|
|
163
|
-
method: 'post',
|
|
164
|
-
url: `${BASE}/deployment/e-1/discord-sync`,
|
|
165
|
-
body: {},
|
|
166
|
-
run: () => discord().sync({ ...SERVICE, environmentId: 'e-1' }),
|
|
167
|
-
},
|
|
168
|
-
];
|
|
169
|
-
|
|
170
|
-
describe('AbyssReflexCore Discord bot routes', () => {
|
|
171
|
-
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
172
|
-
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
beforeAll(() => {
|
|
176
|
-
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
177
|
-
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
beforeEach(() => adapter.mockClear());
|
|
181
|
-
|
|
182
|
-
it.each(calls)('$label calls $method $url', async (call) => {
|
|
183
|
-
await call.run();
|
|
184
|
-
|
|
185
|
-
const config = adapter.mock.calls[0][0];
|
|
186
|
-
expect(config.method).toBe(call.method);
|
|
187
|
-
expect(config.url).toBe(call.url);
|
|
188
|
-
expect(config.baseURL).toBe('http://reflex.test/');
|
|
189
|
-
if (call.body !== undefined) {
|
|
190
|
-
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it('exposes no route twice', () => {
|
|
195
|
-
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
196
|
-
});
|
|
197
|
-
});
|
|
1
|
+
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
+
import { AbyssReflexCore, DiscordComponentKind, DiscordOptionType } from '..';
|
|
3
|
+
|
|
4
|
+
const APP = 'app-1';
|
|
5
|
+
const SVC = 'svc-1';
|
|
6
|
+
const BASE = `api/service/${APP}/${SVC}`;
|
|
7
|
+
const SERVICE = { applicationId: APP, serviceId: SVC };
|
|
8
|
+
|
|
9
|
+
interface Call {
|
|
10
|
+
label: string;
|
|
11
|
+
method: string;
|
|
12
|
+
url: string;
|
|
13
|
+
body?: unknown;
|
|
14
|
+
run: () => Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const discord = () => AbyssReflexCore.sdk.service.discord;
|
|
18
|
+
|
|
19
|
+
const command = {
|
|
20
|
+
name: 'ping',
|
|
21
|
+
description: 'Answers pong',
|
|
22
|
+
options: [
|
|
23
|
+
{
|
|
24
|
+
type: DiscordOptionType.STRING,
|
|
25
|
+
name: 'word',
|
|
26
|
+
description: 'A word',
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
functionId: 'fn-1',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const calls: Call[] = [
|
|
34
|
+
{
|
|
35
|
+
label: 'command.list',
|
|
36
|
+
method: 'get',
|
|
37
|
+
url: `${BASE}/discord/command`,
|
|
38
|
+
run: () => discord().command.list(SERVICE),
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: 'command.create',
|
|
42
|
+
method: 'post',
|
|
43
|
+
url: `${BASE}/discord/command`,
|
|
44
|
+
body: command,
|
|
45
|
+
run: () => discord().command.create(SERVICE, command),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: 'command.update',
|
|
49
|
+
method: 'patch',
|
|
50
|
+
url: `${BASE}/discord/command/c-1`,
|
|
51
|
+
body: { description: 'Answers pong again' },
|
|
52
|
+
run: () =>
|
|
53
|
+
discord().command.update(
|
|
54
|
+
{ ...SERVICE, commandId: 'c-1' },
|
|
55
|
+
{ description: 'Answers pong again' },
|
|
56
|
+
),
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
label: 'command.delete',
|
|
60
|
+
method: 'delete',
|
|
61
|
+
url: `${BASE}/discord/command/c-1`,
|
|
62
|
+
run: () => discord().command.delete({ ...SERVICE, commandId: 'c-1' }),
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: 'component.list',
|
|
66
|
+
method: 'get',
|
|
67
|
+
url: `${BASE}/discord/component`,
|
|
68
|
+
run: () => discord().component.list(SERVICE),
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
label: 'component.create',
|
|
72
|
+
method: 'post',
|
|
73
|
+
url: `${BASE}/discord/component`,
|
|
74
|
+
body: {
|
|
75
|
+
customIdPrefix: 'confirm',
|
|
76
|
+
kind: DiscordComponentKind.BUTTON_OR_SELECT,
|
|
77
|
+
functionId: 'fn-1',
|
|
78
|
+
},
|
|
79
|
+
run: () =>
|
|
80
|
+
discord().component.create(SERVICE, {
|
|
81
|
+
customIdPrefix: 'confirm',
|
|
82
|
+
kind: DiscordComponentKind.BUTTON_OR_SELECT,
|
|
83
|
+
functionId: 'fn-1',
|
|
84
|
+
}),
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
label: 'component.update',
|
|
88
|
+
method: 'patch',
|
|
89
|
+
url: `${BASE}/discord/component/k-1`,
|
|
90
|
+
body: { kind: DiscordComponentKind.MODAL },
|
|
91
|
+
run: () =>
|
|
92
|
+
discord().component.update(
|
|
93
|
+
{ ...SERVICE, componentId: 'k-1' },
|
|
94
|
+
{ kind: DiscordComponentKind.MODAL },
|
|
95
|
+
),
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
label: 'component.delete',
|
|
99
|
+
method: 'delete',
|
|
100
|
+
url: `${BASE}/discord/component/k-1`,
|
|
101
|
+
run: () => discord().component.delete({ ...SERVICE, componentId: 'k-1' }),
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
label: 'connection.get',
|
|
105
|
+
method: 'get',
|
|
106
|
+
url: `${BASE}/discord/connection`,
|
|
107
|
+
run: () => discord().connection.get(SERVICE),
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
label: 'connection.setTokenSecret',
|
|
111
|
+
method: 'put',
|
|
112
|
+
url: `${BASE}/discord/connection`,
|
|
113
|
+
body: { discordTokenSecretId: 'secret-1' },
|
|
114
|
+
run: () => discord().connection.setTokenSecret(SERVICE, { discordTokenSecretId: 'secret-1' }),
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
label: 'connection.setEnvironment',
|
|
118
|
+
method: 'put',
|
|
119
|
+
url: `${BASE}/discord/connection/e-1`,
|
|
120
|
+
body: { testGuildId: '123456789012345678', invitePermissions: '2048' },
|
|
121
|
+
run: () =>
|
|
122
|
+
discord().connection.setEnvironment(
|
|
123
|
+
{ ...SERVICE, environmentId: 'e-1' },
|
|
124
|
+
{ testGuildId: '123456789012345678', invitePermissions: '2048' },
|
|
125
|
+
),
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
label: 'connection.setAllocation',
|
|
129
|
+
method: 'put',
|
|
130
|
+
url: `${BASE}/discord/connection/e-1/allocation`,
|
|
131
|
+
body: { lots: 3 },
|
|
132
|
+
run: () =>
|
|
133
|
+
discord().connection.setAllocation({ ...SERVICE, environmentId: 'e-1' }, { lots: 3 }),
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
label: 'connection.setBotSettings',
|
|
137
|
+
method: 'put',
|
|
138
|
+
url: `${BASE}/discord/connection/e-1/bot-settings`,
|
|
139
|
+
body: {
|
|
140
|
+
creditOverageEnabled: true,
|
|
141
|
+
monthlySpendCapCents: 2000,
|
|
142
|
+
alerts: { rate: { thresholds: [80], email: false } },
|
|
143
|
+
},
|
|
144
|
+
run: () =>
|
|
145
|
+
discord().connection.setBotSettings(
|
|
146
|
+
{ ...SERVICE, environmentId: 'e-1' },
|
|
147
|
+
{
|
|
148
|
+
creditOverageEnabled: true,
|
|
149
|
+
monthlySpendCapCents: 2000,
|
|
150
|
+
alerts: { rate: { thresholds: [80], email: false } },
|
|
151
|
+
},
|
|
152
|
+
),
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
label: 'connection.check',
|
|
156
|
+
method: 'post',
|
|
157
|
+
url: `${BASE}/discord/connection/e-1/check`,
|
|
158
|
+
body: {},
|
|
159
|
+
run: () => discord().connection.check({ ...SERVICE, environmentId: 'e-1' }),
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
label: 'sync',
|
|
163
|
+
method: 'post',
|
|
164
|
+
url: `${BASE}/deployment/e-1/discord-sync`,
|
|
165
|
+
body: {},
|
|
166
|
+
run: () => discord().sync({ ...SERVICE, environmentId: 'e-1' }),
|
|
167
|
+
},
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
describe('AbyssReflexCore Discord bot routes', () => {
|
|
171
|
+
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
172
|
+
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
beforeAll(() => {
|
|
176
|
+
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
177
|
+
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
beforeEach(() => adapter.mockClear());
|
|
181
|
+
|
|
182
|
+
it.each(calls)('$label calls $method $url', async (call) => {
|
|
183
|
+
await call.run();
|
|
184
|
+
|
|
185
|
+
const config = adapter.mock.calls[0][0];
|
|
186
|
+
expect(config.method).toBe(call.method);
|
|
187
|
+
expect(config.url).toBe(call.url);
|
|
188
|
+
expect(config.baseURL).toBe('http://reflex.test/');
|
|
189
|
+
if (call.body !== undefined) {
|
|
190
|
+
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('exposes no route twice', () => {
|
|
195
|
+
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
196
|
+
});
|
|
197
|
+
});
|