@takaro/modules 0.0.4 → 0.0.5
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/dist/modules/geoBlock/hooks/IPDetected.js +10 -10
- package/dist/modules/geoBlock/hooks/IPDetected.js.map +1 -1
- package/dist/modules/gimme/commands/gimme.js +1 -0
- package/dist/modules/gimme/commands/gimme.js.map +1 -1
- package/dist/modules.json +2 -2
- package/package.json +1 -1
- package/src/__tests__/aliases.integration.test.ts +5 -5
- package/src/__tests__/bugRepros.integration.test.ts +3 -3
- package/src/__tests__/commandArgs.integration.test.ts +23 -23
- package/src/__tests__/economyUtils.integration.test.ts +29 -22
- package/src/__tests__/geoblock.integration.test.ts +13 -55
- package/src/__tests__/gimme.integration.test.ts +33 -33
- package/src/__tests__/help.integration.test.ts +36 -23
- package/src/__tests__/lottery.integration.test.ts +27 -22
- package/src/__tests__/modulePermission.integration.test.ts +20 -13
- package/src/__tests__/onboarding.integration.test.ts +9 -9
- package/src/__tests__/ping.integration.test.ts +4 -4
- package/src/__tests__/roleExpiry.integration.test.ts +7 -7
- package/src/__tests__/serverMessages.integration.test.ts +10 -7
- package/src/__tests__/systemConfigCost.integration.test.ts +9 -9
- package/src/__tests__/teleports/listtp.integration.test.ts +30 -28
- package/src/__tests__/teleports/publicteleports.integration.test.ts +45 -37
- package/src/__tests__/teleports/teleport.integration.test.ts +14 -12
- package/src/__tests__/teleports/tpManagement.integration.test.ts +17 -17
- package/src/__tests__/teleports/waypoints.integration.test.ts +109 -77
- package/src/modules/geoBlock/hooks/IPDetected.js +9 -9
- package/src/modules/gimme/commands/gimme.js +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
|
|
2
2
|
import { GameEvents } from '../dto/index.js';
|
|
3
3
|
|
|
4
4
|
const group = 'gimme suite';
|
|
@@ -20,7 +20,7 @@ const tests = [
|
|
|
20
20
|
}),
|
|
21
21
|
},
|
|
22
22
|
);
|
|
23
|
-
const events = this.
|
|
23
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
24
24
|
|
|
25
25
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
26
26
|
msg: '/gimme',
|
|
@@ -28,37 +28,37 @@ const tests = [
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
expect((await events).length).to.be.eq(1);
|
|
31
|
-
expect((await events)[0].data.msg).to.match(/You received (apple|banana|orange)/);
|
|
32
|
-
},
|
|
33
|
-
}),
|
|
34
|
-
new IntegrationTest<IModuleTestsSetupData>({
|
|
35
|
-
group,
|
|
36
|
-
snapshot: false,
|
|
37
|
-
setup: modulesTestSetup,
|
|
38
|
-
name: 'Can execute command',
|
|
39
|
-
test: async function () {
|
|
40
|
-
await this.client.gameserver.gameServerControllerInstallModule(
|
|
41
|
-
this.setupData.gameserver.id,
|
|
42
|
-
this.setupData.gimmeModule.id,
|
|
43
|
-
{
|
|
44
|
-
userConfig: JSON.stringify({
|
|
45
|
-
items: [],
|
|
46
|
-
commands: ['say hello from test'],
|
|
47
|
-
}),
|
|
48
|
-
},
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
52
|
-
|
|
53
|
-
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
54
|
-
msg: '/gimme',
|
|
55
|
-
playerId: this.setupData.players[0].id,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
expect((await events).length).to.be.eq(1);
|
|
59
|
-
expect((await events)[0].data.msg).to.eq('hello from test');
|
|
31
|
+
expect((await events)[0].data.meta.msg).to.match(/You received (apple|banana|orange)/);
|
|
60
32
|
},
|
|
61
33
|
}),
|
|
34
|
+
/* new IntegrationTest<IModuleTestsSetupData>({
|
|
35
|
+
group,
|
|
36
|
+
snapshot: false,
|
|
37
|
+
setup: modulesTestSetup,
|
|
38
|
+
name: 'Can execute command',
|
|
39
|
+
test: async function () {
|
|
40
|
+
await this.client.gameserver.gameServerControllerInstallModule(
|
|
41
|
+
this.setupData.gameserver.id,
|
|
42
|
+
this.setupData.gimmeModule.id,
|
|
43
|
+
{
|
|
44
|
+
userConfig: JSON.stringify({
|
|
45
|
+
items: [],
|
|
46
|
+
commands: ['say hello from test'],
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
52
|
+
|
|
53
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
54
|
+
msg: '/gimme',
|
|
55
|
+
playerId: this.setupData.players[0].id,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
expect((await events).length).to.be.eq(1);
|
|
59
|
+
expect((await events)[0].data.meta.msg).to.eq('hello from test');
|
|
60
|
+
},
|
|
61
|
+
}), */
|
|
62
62
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
63
63
|
group,
|
|
64
64
|
snapshot: false,
|
|
@@ -76,7 +76,7 @@ const tests = [
|
|
|
76
76
|
},
|
|
77
77
|
);
|
|
78
78
|
|
|
79
|
-
const events = this.
|
|
79
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
80
80
|
|
|
81
81
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
82
82
|
msg: '/gimme',
|
|
@@ -84,7 +84,7 @@ const tests = [
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
expect((await events).length).to.be.eq(1);
|
|
87
|
-
expect((await events)[0].data.msg).to.match(/No items or commands configured/);
|
|
87
|
+
expect((await events)[0].data.meta.msg).to.match(/No items or commands configured/);
|
|
88
88
|
},
|
|
89
89
|
}),
|
|
90
90
|
];
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
IntegrationTest,
|
|
3
|
+
expect,
|
|
4
|
+
IModuleTestsSetupData,
|
|
5
|
+
modulesTestSetup,
|
|
6
|
+
chatMessageSorter,
|
|
7
|
+
EventsAwaiter,
|
|
8
|
+
} from '@takaro/test';
|
|
2
9
|
import { GameEvents } from '../dto/gameEvents.js';
|
|
3
10
|
|
|
4
11
|
const group = 'Help command';
|
|
@@ -14,7 +21,7 @@ const tests = [
|
|
|
14
21
|
this.setupData.gameserver.id,
|
|
15
22
|
this.setupData.utilsModule.id,
|
|
16
23
|
);
|
|
17
|
-
const events = this.
|
|
24
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 3);
|
|
18
25
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
19
26
|
msg: '/help',
|
|
20
27
|
playerId: this.setupData.players[0].id,
|
|
@@ -23,11 +30,13 @@ const tests = [
|
|
|
23
30
|
expect((await events).length).to.be.eq(3);
|
|
24
31
|
const sortedEvents = (await events).sort(chatMessageSorter);
|
|
25
32
|
|
|
26
|
-
expect(sortedEvents[0].data.msg).to.be.eq('Available commands:');
|
|
27
|
-
expect(sortedEvents[1].data.msg).to.be.eq(
|
|
33
|
+
expect(sortedEvents[0].data.meta.msg).to.be.eq('Available commands:');
|
|
34
|
+
expect(sortedEvents[1].data.meta.msg).to.be.eq(
|
|
28
35
|
'help: The text you are reading right now, displays information about commands.',
|
|
29
36
|
);
|
|
30
|
-
expect(sortedEvents[2].data.msg).to.be.eq(
|
|
37
|
+
expect(sortedEvents[2].data.meta.msg).to.be.eq(
|
|
38
|
+
'ping: Replies with pong, useful for testing if the connection works.',
|
|
39
|
+
);
|
|
31
40
|
},
|
|
32
41
|
}),
|
|
33
42
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -44,7 +53,7 @@ const tests = [
|
|
|
44
53
|
this.setupData.gameserver.id,
|
|
45
54
|
this.setupData.teleportsModule.id,
|
|
46
55
|
);
|
|
47
|
-
const events = this.
|
|
56
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 13);
|
|
48
57
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
49
58
|
msg: '/help',
|
|
50
59
|
playerId: this.setupData.players[0].id,
|
|
@@ -52,27 +61,29 @@ const tests = [
|
|
|
52
61
|
|
|
53
62
|
const sortedEvents = (await events).sort(chatMessageSorter);
|
|
54
63
|
|
|
55
|
-
expect(sortedEvents[0].data.msg).to.be.eq('Available commands:');
|
|
56
|
-
expect(sortedEvents[1].data.msg).to.be.eq('deletetp: Deletes a location.');
|
|
57
|
-
expect(sortedEvents[2].data.msg).to.be.eq('deletewaypoint: Deletes a waypoint.');
|
|
58
|
-
expect(sortedEvents[3].data.msg).to.be.eq(
|
|
64
|
+
expect(sortedEvents[0].data.meta.msg).to.be.eq('Available commands:');
|
|
65
|
+
expect(sortedEvents[1].data.meta.msg).to.be.eq('deletetp: Deletes a location.');
|
|
66
|
+
expect(sortedEvents[2].data.meta.msg).to.be.eq('deletewaypoint: Deletes a waypoint.');
|
|
67
|
+
expect(sortedEvents[3].data.meta.msg).to.be.eq(
|
|
59
68
|
'help: The text you are reading right now, displays information about commands.',
|
|
60
69
|
);
|
|
61
|
-
expect(sortedEvents[4].data.msg).to.be.eq('listwaypoints: Lists all waypoints.');
|
|
62
|
-
expect(sortedEvents[5].data.msg).to.be.eq(
|
|
63
|
-
|
|
70
|
+
expect(sortedEvents[4].data.meta.msg).to.be.eq('listwaypoints: Lists all waypoints.');
|
|
71
|
+
expect(sortedEvents[5].data.meta.msg).to.be.eq(
|
|
72
|
+
'ping: Replies with pong, useful for testing if the connection works.',
|
|
73
|
+
);
|
|
74
|
+
expect(sortedEvents[6].data.meta.msg).to.be.eq(
|
|
64
75
|
'setprivate: Sets a teleport to be private, only the teleport owner can teleport to it.',
|
|
65
76
|
);
|
|
66
|
-
expect(sortedEvents[7].data.msg).to.be.eq(
|
|
77
|
+
expect(sortedEvents[7].data.meta.msg).to.be.eq(
|
|
67
78
|
'setpublic: Sets a teleport to be public, allowing other players to teleport to it.',
|
|
68
79
|
);
|
|
69
|
-
expect(sortedEvents[8].data.msg).to.be.eq('settp: Sets a location to teleport to.');
|
|
70
|
-
expect(sortedEvents[9].data.msg).to.be.eq('setwaypoint: Creates a new waypoint.');
|
|
71
|
-
expect(sortedEvents[10].data.msg).to.be.eq('teleport: Teleports to one of your set locations.');
|
|
72
|
-
expect(sortedEvents[11].data.msg).to.be.eq(
|
|
80
|
+
expect(sortedEvents[8].data.meta.msg).to.be.eq('settp: Sets a location to teleport to.');
|
|
81
|
+
expect(sortedEvents[9].data.meta.msg).to.be.eq('setwaypoint: Creates a new waypoint.');
|
|
82
|
+
expect(sortedEvents[10].data.meta.msg).to.be.eq('teleport: Teleports to one of your set locations.');
|
|
83
|
+
expect(sortedEvents[11].data.meta.msg).to.be.eq(
|
|
73
84
|
'teleportwaypoint: Placeholder command, this will not be used directly. The module will install aliases for this command corresponding to the waypoint names.',
|
|
74
85
|
);
|
|
75
|
-
expect(sortedEvents[12].data.msg).to.be.eq('tplist: Lists all your set locations.');
|
|
86
|
+
expect(sortedEvents[12].data.meta.msg).to.be.eq('tplist: Lists all your set locations.');
|
|
76
87
|
},
|
|
77
88
|
}),
|
|
78
89
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -86,7 +97,7 @@ const tests = [
|
|
|
86
97
|
this.setupData.utilsModule.id,
|
|
87
98
|
);
|
|
88
99
|
|
|
89
|
-
const events = this.
|
|
100
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
90
101
|
|
|
91
102
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
92
103
|
msg: '/help ping',
|
|
@@ -96,7 +107,9 @@ const tests = [
|
|
|
96
107
|
expect((await events).length).to.be.eq(1);
|
|
97
108
|
const sortedEvents = (await events).sort(chatMessageSorter);
|
|
98
109
|
|
|
99
|
-
expect(sortedEvents[0].data.msg).to.be.eq(
|
|
110
|
+
expect(sortedEvents[0].data.meta.msg).to.be.eq(
|
|
111
|
+
'ping: Replies with pong, useful for testing if the connection works.',
|
|
112
|
+
);
|
|
100
113
|
},
|
|
101
114
|
}),
|
|
102
115
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -110,7 +123,7 @@ const tests = [
|
|
|
110
123
|
this.setupData.utilsModule.id,
|
|
111
124
|
);
|
|
112
125
|
|
|
113
|
-
const events = this.
|
|
126
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
114
127
|
|
|
115
128
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
116
129
|
msg: '/help foobar',
|
|
@@ -118,7 +131,7 @@ const tests = [
|
|
|
118
131
|
});
|
|
119
132
|
|
|
120
133
|
expect((await events).length).to.be.eq(1);
|
|
121
|
-
expect((await events)[0].data.msg).to.be.eq(
|
|
134
|
+
expect((await events)[0].data.meta.msg).to.be.eq(
|
|
122
135
|
'Unknown command "foobar", use this command without arguments to see all available commands.',
|
|
123
136
|
);
|
|
124
137
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
|
|
2
2
|
import { GameEvents } from '../dto/index.js';
|
|
3
3
|
import { Client } from '@takaro/apiclient';
|
|
4
4
|
|
|
@@ -85,7 +85,7 @@ const tests = [
|
|
|
85
85
|
setup,
|
|
86
86
|
name: 'Cannot buy 0 lottery tickets',
|
|
87
87
|
test: async function () {
|
|
88
|
-
const events = this.
|
|
88
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
89
89
|
const player = this.setupData.players[0];
|
|
90
90
|
|
|
91
91
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
@@ -94,7 +94,7 @@ const tests = [
|
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
expect((await events).length).to.be.eq(1);
|
|
97
|
-
expect((await events)[0].data.msg).to.be.eq('You must buy at least 1 ticket.');
|
|
97
|
+
expect((await events)[0].data.meta.msg).to.be.eq('You must buy at least 1 ticket.');
|
|
98
98
|
},
|
|
99
99
|
}),
|
|
100
100
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -103,7 +103,7 @@ const tests = [
|
|
|
103
103
|
setup,
|
|
104
104
|
name: 'Can buy lottery ticket',
|
|
105
105
|
test: async function () {
|
|
106
|
-
let events = this.
|
|
106
|
+
let events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
107
107
|
|
|
108
108
|
const ticketAmount = 1;
|
|
109
109
|
const ticketPrice = ticketAmount * ticketCost;
|
|
@@ -120,7 +120,7 @@ const tests = [
|
|
|
120
120
|
).data.data.value;
|
|
121
121
|
|
|
122
122
|
expect((await events).length).to.be.eq(1);
|
|
123
|
-
expect((await events)[0].data.msg).to.be.eq(
|
|
123
|
+
expect((await events)[0].data.meta.msg).to.be.eq(
|
|
124
124
|
`You have successfully bought ${ticketAmount} tickets for ${ticketPrice} ${currencyName}. Good luck!`,
|
|
125
125
|
);
|
|
126
126
|
|
|
@@ -131,7 +131,7 @@ const tests = [
|
|
|
131
131
|
expect(pog.currency).to.be.eq(playerStartBalance - ticketPrice);
|
|
132
132
|
await expectTicketAmountLengthToBe(this.client, this.setupData.gameserver.id, this.setupData.lotteryModule.id, 1);
|
|
133
133
|
|
|
134
|
-
events = this.
|
|
134
|
+
events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
135
135
|
|
|
136
136
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
137
137
|
msg: `/buyTicket ${ticketAmount}`,
|
|
@@ -139,7 +139,7 @@ const tests = [
|
|
|
139
139
|
});
|
|
140
140
|
|
|
141
141
|
expect((await events).length).to.be.eq(1);
|
|
142
|
-
expect((await events)[0].data.msg).to.be.eq(
|
|
142
|
+
expect((await events)[0].data.meta.msg).to.be.eq(
|
|
143
143
|
`You have successfully bought ${ticketAmount} tickets for ${ticketPrice} ${currencyName}. Good luck!`,
|
|
144
144
|
);
|
|
145
145
|
|
|
@@ -158,7 +158,7 @@ const tests = [
|
|
|
158
158
|
test: async function () {
|
|
159
159
|
const wantAmount = 10;
|
|
160
160
|
|
|
161
|
-
const waitForBuyEvents = this.
|
|
161
|
+
const waitForBuyEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
162
162
|
|
|
163
163
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
164
164
|
msg: `/buyTicket ${wantAmount}}`,
|
|
@@ -167,7 +167,7 @@ const tests = [
|
|
|
167
167
|
|
|
168
168
|
await waitForBuyEvents;
|
|
169
169
|
|
|
170
|
-
const waitForViewEvent = this.
|
|
170
|
+
const waitForViewEvent = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
171
171
|
|
|
172
172
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
173
173
|
msg: '/viewTickets',
|
|
@@ -177,7 +177,7 @@ const tests = [
|
|
|
177
177
|
const events = await waitForViewEvent;
|
|
178
178
|
|
|
179
179
|
expect(events.length).to.be.eq(1);
|
|
180
|
-
expect(events[0].data.msg).to.be.eq(`You have bought ${wantAmount} tickets.`);
|
|
180
|
+
expect(events[0].data.meta.msg).to.be.eq(`You have bought ${wantAmount} tickets.`);
|
|
181
181
|
},
|
|
182
182
|
}),
|
|
183
183
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -191,7 +191,10 @@ const tests = [
|
|
|
191
191
|
).data.data.value;
|
|
192
192
|
|
|
193
193
|
const playerAmount = this.setupData.players.length;
|
|
194
|
-
const ticketEvents = this.
|
|
194
|
+
const ticketEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(
|
|
195
|
+
GameEvents.CHAT_MESSAGE,
|
|
196
|
+
playerAmount,
|
|
197
|
+
);
|
|
195
198
|
|
|
196
199
|
// let some players buy tickets
|
|
197
200
|
const asyncTasks = this.setupData.players.map(async (player) => {
|
|
@@ -204,7 +207,7 @@ const tests = [
|
|
|
204
207
|
await Promise.allSettled(asyncTasks);
|
|
205
208
|
await ticketEvents;
|
|
206
209
|
|
|
207
|
-
const lotteryEvents = this.
|
|
210
|
+
const lotteryEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 4);
|
|
208
211
|
|
|
209
212
|
await this.client.cronjob.cronJobControllerTrigger({
|
|
210
213
|
moduleId: this.setupData.lotteryModule.id,
|
|
@@ -225,9 +228,9 @@ const tests = [
|
|
|
225
228
|
const events = await lotteryEvents;
|
|
226
229
|
|
|
227
230
|
expect(events.length).to.be.eq(4);
|
|
228
|
-
expect(events[3].data.msg).to.contain(`${prize} ${currencyName}`);
|
|
231
|
+
expect(events[3].data.meta.msg).to.contain(`${prize} ${currencyName}`);
|
|
229
232
|
|
|
230
|
-
const winnerName = events[3].data.msg.split('!')[0];
|
|
233
|
+
const winnerName = events[3].data.meta.msg.split('!')[0];
|
|
231
234
|
const winner = this.setupData.players.find((player) => player.name === winnerName);
|
|
232
235
|
if (!winner) {
|
|
233
236
|
throw new Error('winner name not found in the list of setup players');
|
|
@@ -245,7 +248,7 @@ const tests = [
|
|
|
245
248
|
setup,
|
|
246
249
|
name: 'If no players joined, the lottery is cancelled',
|
|
247
250
|
test: async function () {
|
|
248
|
-
const waitForEvents = this.
|
|
251
|
+
const waitForEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
249
252
|
|
|
250
253
|
await this.client.cronjob.cronJobControllerTrigger({
|
|
251
254
|
moduleId: this.setupData.lotteryModule.id,
|
|
@@ -256,7 +259,7 @@ const tests = [
|
|
|
256
259
|
const events = await waitForEvents;
|
|
257
260
|
|
|
258
261
|
expect(events.length).to.be.eq(1);
|
|
259
|
-
expect(events[0].data.msg).to.eq('No one has bought any tickets. The lottery has been cancelled.');
|
|
262
|
+
expect(events[0].data.meta.msg).to.eq('No one has bought any tickets. The lottery has been cancelled.');
|
|
260
263
|
},
|
|
261
264
|
}),
|
|
262
265
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -265,7 +268,9 @@ const tests = [
|
|
|
265
268
|
setup,
|
|
266
269
|
name: 'If one player joined, the lottery is cancelled and the player gets his money back',
|
|
267
270
|
test: async function () {
|
|
268
|
-
const waitForTicketEvents = this.
|
|
271
|
+
const waitForTicketEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(
|
|
272
|
+
GameEvents.CHAT_MESSAGE,
|
|
273
|
+
);
|
|
269
274
|
|
|
270
275
|
const player = this.setupData.players[0];
|
|
271
276
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
@@ -279,7 +284,7 @@ const tests = [
|
|
|
279
284
|
await this.client.settings.settingsControllerGetOne('currencyName', this.setupData.gameserver.id)
|
|
280
285
|
).data.data.value;
|
|
281
286
|
|
|
282
|
-
const waitForEvents = this.
|
|
287
|
+
const waitForEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
283
288
|
|
|
284
289
|
await this.client.cronjob.cronJobControllerTrigger({
|
|
285
290
|
moduleId: this.setupData.lotteryModule.id,
|
|
@@ -290,8 +295,8 @@ const tests = [
|
|
|
290
295
|
const events = await waitForEvents;
|
|
291
296
|
|
|
292
297
|
expect(events.length).to.be.eq(2);
|
|
293
|
-
expect(events[0].data.msg).to.eq('Only one person has bought a ticket. The lottery has been cancelled.');
|
|
294
|
-
expect(events[1].data.msg).to.eq(
|
|
298
|
+
expect(events[0].data.meta.msg).to.eq('Only one person has bought a ticket. The lottery has been cancelled.');
|
|
299
|
+
expect(events[1].data.meta.msg).to.eq(
|
|
295
300
|
`You have been refunded ${ticketCost} ${currencyName} because the lottery has been cancelled.`,
|
|
296
301
|
);
|
|
297
302
|
|
|
@@ -309,7 +314,7 @@ const tests = [
|
|
|
309
314
|
setup,
|
|
310
315
|
name: 'Can view next lottery draw',
|
|
311
316
|
test: async function () {
|
|
312
|
-
const waitForEvents = this.
|
|
317
|
+
const waitForEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
313
318
|
|
|
314
319
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
315
320
|
msg: '/nextDraw',
|
|
@@ -319,7 +324,7 @@ const tests = [
|
|
|
319
324
|
const events = await waitForEvents;
|
|
320
325
|
|
|
321
326
|
expect(events.length).to.be.eq(1);
|
|
322
|
-
expect(events[0].data.msg).to.contain('The next lottery draw is in');
|
|
327
|
+
expect(events[0].data.meta.msg).to.contain('The next lottery draw is in');
|
|
323
328
|
},
|
|
324
329
|
}),
|
|
325
330
|
];
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
IntegrationTest,
|
|
3
|
+
expect,
|
|
4
|
+
integrationConfig,
|
|
5
|
+
IModuleTestsSetupData,
|
|
6
|
+
modulesTestSetup,
|
|
7
|
+
EventsAwaiter,
|
|
8
|
+
} from '@takaro/test';
|
|
2
9
|
import { GameEvents } from '../dto/index.js';
|
|
3
10
|
|
|
4
11
|
const group = 'Module permissions role assignments';
|
|
@@ -47,14 +54,14 @@ const tests = [
|
|
|
47
54
|
});
|
|
48
55
|
await this.client.player.playerControllerAssignRole(this.setupData.players[0].id, this.setupData.role.id);
|
|
49
56
|
|
|
50
|
-
const setEvents = this.
|
|
57
|
+
const setEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
51
58
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
52
59
|
msg: '/settp test',
|
|
53
60
|
playerId: this.setupData.players[0].id,
|
|
54
61
|
});
|
|
55
62
|
|
|
56
63
|
expect((await setEvents).length).to.be.eq(1);
|
|
57
|
-
expect((await setEvents)[0].data.msg).to.be.eq('Teleport test set.');
|
|
64
|
+
expect((await setEvents)[0].data.meta.msg).to.be.eq('Teleport test set.');
|
|
58
65
|
},
|
|
59
66
|
}),
|
|
60
67
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -75,14 +82,14 @@ const tests = [
|
|
|
75
82
|
gameServerId: newGameServer.data.data.id,
|
|
76
83
|
});
|
|
77
84
|
|
|
78
|
-
const setEvents = this.
|
|
85
|
+
const setEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
79
86
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
80
87
|
msg: '/settp test',
|
|
81
88
|
playerId: this.setupData.players[0].id,
|
|
82
89
|
});
|
|
83
90
|
|
|
84
91
|
expect((await setEvents).length).to.be.eq(1);
|
|
85
|
-
expect((await setEvents)[0].data.msg).to.be.eq('You do not have permission to use teleports.');
|
|
92
|
+
expect((await setEvents)[0].data.meta.msg).to.be.eq('You do not have permission to use teleports.');
|
|
86
93
|
},
|
|
87
94
|
}),
|
|
88
95
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -105,14 +112,14 @@ const tests = [
|
|
|
105
112
|
gameServerId: this.setupData.gameserver.id,
|
|
106
113
|
});
|
|
107
114
|
|
|
108
|
-
const setEvents = this.
|
|
115
|
+
const setEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
109
116
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
110
117
|
msg: '/settp test',
|
|
111
118
|
playerId: this.setupData.players[0].id,
|
|
112
119
|
});
|
|
113
120
|
|
|
114
121
|
expect((await setEvents).length).to.be.eq(1);
|
|
115
|
-
expect((await setEvents)[0].data.msg).to.be.eq('Teleport test set.');
|
|
122
|
+
expect((await setEvents)[0].data.meta.msg).to.be.eq('Teleport test set.');
|
|
116
123
|
},
|
|
117
124
|
}),
|
|
118
125
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -148,7 +155,7 @@ const tests = [
|
|
|
148
155
|
],
|
|
149
156
|
});
|
|
150
157
|
|
|
151
|
-
const setTpEvent = this.
|
|
158
|
+
const setTpEvent = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
152
159
|
|
|
153
160
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
154
161
|
msg: '/settp test',
|
|
@@ -156,30 +163,30 @@ const tests = [
|
|
|
156
163
|
});
|
|
157
164
|
|
|
158
165
|
expect((await setTpEvent).length).to.be.eq(1);
|
|
159
|
-
expect((await setTpEvent)[0].data.msg).to.be.eq('Teleport test set.');
|
|
166
|
+
expect((await setTpEvent)[0].data.meta.msg).to.be.eq('Teleport test set.');
|
|
160
167
|
|
|
161
|
-
const tpEvent = this.
|
|
168
|
+
const tpEvent = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
162
169
|
|
|
163
170
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
164
171
|
msg: '/tp test',
|
|
165
172
|
playerId: this.setupData.players[0].id,
|
|
166
173
|
});
|
|
167
174
|
|
|
168
|
-
expect((await tpEvent)[0].data.msg).to.be.eq('Teleported to test.');
|
|
175
|
+
expect((await tpEvent)[0].data.meta.msg).to.be.eq('Teleported to test.');
|
|
169
176
|
|
|
170
177
|
await this.client.role.roleControllerUpdate(playerRoleRes.data.data[0].id, {
|
|
171
178
|
name: 'Player',
|
|
172
179
|
permissions: [],
|
|
173
180
|
});
|
|
174
181
|
|
|
175
|
-
const tpEventNoPerm = this.
|
|
182
|
+
const tpEventNoPerm = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
176
183
|
|
|
177
184
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
178
185
|
msg: '/tp test',
|
|
179
186
|
playerId: this.setupData.players[0].id,
|
|
180
187
|
});
|
|
181
188
|
|
|
182
|
-
expect((await tpEventNoPerm)[0].data.msg).to.be.eq('You do not have permission to use teleports.');
|
|
189
|
+
expect((await tpEventNoPerm)[0].data.meta.msg).to.be.eq('You do not have permission to use teleports.');
|
|
183
190
|
},
|
|
184
191
|
}),
|
|
185
192
|
];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
|
|
2
2
|
import { EventPlayerConnected, GameEvents } from '../dto/gameEvents.js';
|
|
3
3
|
import { HookEvents } from '../main.js';
|
|
4
4
|
|
|
@@ -16,7 +16,7 @@ const _tests = [
|
|
|
16
16
|
this.setupData.gameserver.id,
|
|
17
17
|
this.setupData.onboardingModule.id,
|
|
18
18
|
);
|
|
19
|
-
const events = this.
|
|
19
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
20
20
|
await this.client.hook.hookControllerTrigger({
|
|
21
21
|
gameServerId: this.setupData.gameserver.id,
|
|
22
22
|
playerId: this.setupData.players[0].id,
|
|
@@ -30,7 +30,7 @@ const _tests = [
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
expect((await events).length).to.be.eq(1);
|
|
33
|
-
expect((await events)[0].data.msg).to.match(/Welcome .+ to the server!/);
|
|
33
|
+
expect((await events)[0].data.meta.msg).to.match(/Welcome .+ to the server!/);
|
|
34
34
|
},
|
|
35
35
|
}),
|
|
36
36
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -48,7 +48,7 @@ const _tests = [
|
|
|
48
48
|
}),
|
|
49
49
|
},
|
|
50
50
|
);
|
|
51
|
-
const events = this.
|
|
51
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.COMMAND_EXECUTED);
|
|
52
52
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
53
53
|
msg: '/starterkit',
|
|
54
54
|
playerId: this.setupData.players[0].id,
|
|
@@ -73,7 +73,7 @@ const _tests = [
|
|
|
73
73
|
}),
|
|
74
74
|
},
|
|
75
75
|
);
|
|
76
|
-
const firstEvents = this.
|
|
76
|
+
const firstEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.COMMAND_EXECUTED);
|
|
77
77
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
78
78
|
msg: '/starterkit',
|
|
79
79
|
playerId: this.setupData.players[0].id,
|
|
@@ -82,14 +82,14 @@ const _tests = [
|
|
|
82
82
|
const resultLogs = (await firstEvents)[0].data.meta.result.logs;
|
|
83
83
|
expect(resultLogs.some((log: any) => log.msg.match(/giveItem 200 OK/))).to.be.true;
|
|
84
84
|
|
|
85
|
-
const secondEvents = this.
|
|
85
|
+
const secondEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
86
86
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
87
87
|
msg: '/starterkit',
|
|
88
88
|
playerId: this.setupData.players[0].id,
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
expect((await secondEvents).length).to.be.eq(1);
|
|
92
|
-
expect((await secondEvents)[0].data.msg).to.match(/ou already used starterkit on this server/);
|
|
92
|
+
expect((await secondEvents)[0].data.meta.msg).to.match(/ou already used starterkit on this server/);
|
|
93
93
|
},
|
|
94
94
|
}),
|
|
95
95
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -102,14 +102,14 @@ const _tests = [
|
|
|
102
102
|
this.setupData.gameserver.id,
|
|
103
103
|
this.setupData.onboardingModule.id,
|
|
104
104
|
);
|
|
105
|
-
const events = this.
|
|
105
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
106
106
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
107
107
|
msg: '/starterkit',
|
|
108
108
|
playerId: this.setupData.players[0].id,
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
expect((await events).length).to.be.eq(1);
|
|
112
|
-
expect((await events)[0].data.msg).to.match(/No starter kit items configured/);
|
|
112
|
+
expect((await events)[0].data.meta.msg).to.match(/No starter kit items configured/);
|
|
113
113
|
},
|
|
114
114
|
}),
|
|
115
115
|
];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
2
|
-
import {
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
|
|
2
|
+
import { HookEvents } from '../dto/index.js';
|
|
3
3
|
|
|
4
4
|
const group = 'Ping command';
|
|
5
5
|
|
|
@@ -15,7 +15,7 @@ const tests = [
|
|
|
15
15
|
this.setupData.utilsModule.id,
|
|
16
16
|
);
|
|
17
17
|
|
|
18
|
-
const events = this.
|
|
18
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.CHAT_MESSAGE);
|
|
19
19
|
|
|
20
20
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
21
21
|
msg: '/ping',
|
|
@@ -23,7 +23,7 @@ const tests = [
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
expect((await events).length).to.be.eq(1);
|
|
26
|
-
expect((await events)[0].data.msg).to.be.eq('Pong!');
|
|
26
|
+
expect((await events)[0].data.meta.msg).to.be.eq('Pong!');
|
|
27
27
|
},
|
|
28
28
|
}),
|
|
29
29
|
];
|