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