Skip to content

Commit 9476a30

Browse files
Copilotsonnyp
andcommitted
Apply PR #1100 changes: Remove flaky test and reorganize test setup
Co-authored-by: sonnyp <[email protected]>
1 parent c4e4a83 commit 9476a30

File tree

1 file changed

+9
-48
lines changed

1 file changed

+9
-48
lines changed

test/stream-management.test.js

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@ const domain = "localhost";
1111

1212
let xmpp;
1313

14-
afterEach(async () => {
14+
beforeAll(async () => {
15+
await server.enableModules(["smacks"]);
16+
});
17+
18+
beforeEach(async () => {
19+
await server.restart();
20+
});
21+
22+
afterAll(async () => {
1523
await xmpp?.stop();
1624
await server.reset();
1725
});
1826

1927
test("client ack stanzas", async () => {
20-
await server.enableModules(["smacks"]);
21-
await server.restart();
2228

2329
xmpp = client({ credentials, service: domain });
2430
debug(xmpp);
@@ -36,9 +42,6 @@ test("client ack stanzas", async () => {
3642
});
3743

3844
test("client fail stanzas", async () => {
39-
await server.enableModules(["smacks"]);
40-
await server.restart();
41-
4245
xmpp = client({ credentials, service: domain });
4346
debug(xmpp);
4447

@@ -60,9 +63,6 @@ test("client fail stanzas", async () => {
6063
});
6164

6265
test("client retry stanzas", async () => {
63-
await server.enableModules(["smacks"]);
64-
await server.restart();
65-
6666
xmpp = client({ credentials, service: domain });
6767
debug(xmpp);
6868

@@ -86,9 +86,6 @@ test("client retry stanzas", async () => {
8686
});
8787

8888
test("client reconnects when server fails to ack stanza", async () => {
89-
await server.enableModules(["smacks"]);
90-
await server.restart();
91-
9289
xmpp = client({ credentials, service: domain });
9390
xmpp.streamManagement.timeout = 10;
9491
xmpp.streamManagement.requestAckInterval = 5;
@@ -110,39 +107,3 @@ test("client reconnects when server fails to ack stanza", async () => {
110107
await promise_resumed;
111108
expect().pass();
112109
});
113-
114-
test("pings do not prevent timeout", async () => {
115-
await server.enableModules(["smacks"]);
116-
await server.restart();
117-
118-
xmpp = client({ credentials, service: domain });
119-
xmpp.streamManagement.timeout = 10;
120-
xmpp.streamManagement.requestAckInterval = 5;
121-
122-
// Make sure an ack request is sent right away after a stanza
123-
xmpp.streamManagement.debounceAckRequest = 1;
124-
debug(xmpp);
125-
126-
let promise_disconnect = new Promise((resolve) => {
127-
xmpp.disconnect = () => {
128-
resolve();
129-
return Promise.resolve(null);
130-
};
131-
});
132-
await xmpp.start();
133-
134-
// Send just any stanza to trigger the act request send
135-
xmpp.send(
136-
<iq to={domain} id="ping" type="get">
137-
<ping xmlns="urn:xmppp:ping" />
138-
</iq>,
139-
);
140-
141-
// Pretend we don't receive the ack by removing event listeners
142-
// on the socket, so that the timeout can fire
143-
xmpp._detachSocket();
144-
145-
// Timeout fires, and disconnect happens
146-
await promise_disconnect;
147-
expect().pass();
148-
});

0 commit comments

Comments
 (0)