Skip to content

Commit 13e0073

Browse files
committed
[FIX] mail: fix non-deterministic im status tests
This commit fixes the im_status test suite which fails in a non-deterministic fashion. Initially, those tests wait for the first update of the presence (the one sent when the first connection to the websocket is established). Presence is updated when: - Self persona status is offline. - Bus notification is received for self with different value than the one of this device (e.g. offline while away/online, away while online). - The websocket connection is first established. In those test, another subscription could happen according to the timing of the `/mail/data` RPC which returns the initial status of the user as offline. This commit fixes this issue by setting an initial status on the current user. fixes runbot-229757 closes odoo#218454 X-original-commit: 9e0a2b3 Signed-off-by: Matthieu Stockbauer (tsm) <[email protected]>
1 parent 80f171f commit 13e0073

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

addons/mail/static/tests/discuss/im_status.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ describe.current.tags("headless");
1212
test("update presence if IM status changes to offline while this device is online", async () => {
1313
mockService("bus_service", { send: (type) => asyncStep(type) });
1414
const pyEnv = await startServer();
15+
pyEnv["res.partner"].write(serverState.partnerId, { im_status: "online" });
1516
await start();
1617
await waitForSteps(["update_presence"]);
1718
pyEnv["bus.bus"]._sendone(serverState.partnerId, "bus.bus/im_status_updated", {
@@ -26,6 +27,7 @@ test("update presence if IM status changes to away while this device is online",
2627
mockService("bus_service", { send: (type) => asyncStep(type) });
2728
localStorage.setItem("presence.lastPresence", Date.now());
2829
const pyEnv = await startServer();
30+
pyEnv["res.partner"].write(serverState.partnerId, { im_status: "online" });
2931
await start();
3032
await waitForSteps(["update_presence"]);
3133
pyEnv["bus.bus"]._sendone(serverState.partnerId, "bus.bus/im_status_updated", {
@@ -40,6 +42,7 @@ test("do not update presence if IM status changes to away while this device is a
4042
mockService("bus_service", { send: (type) => asyncStep(type) });
4143
localStorage.setItem("presence.lastPresence", Date.now() - AWAY_DELAY);
4244
const pyEnv = await startServer();
45+
pyEnv["res.partner"].write(serverState.partnerId, { im_status: "away" });
4346
await start();
4447
await waitForSteps(["update_presence"]);
4548
pyEnv["bus.bus"]._sendone(serverState.partnerId, "bus.bus/im_status_updated", {
@@ -54,6 +57,7 @@ test("do not update presence if other user's IM status changes to away", async (
5457
mockService("bus_service", { send: (type) => asyncStep(type) });
5558
localStorage.setItem("presence.lastPresence", Date.now());
5659
const pyEnv = await startServer();
60+
pyEnv["res.partner"].write(serverState.partnerId, { im_status: "online" });
5761
await start();
5862
await waitForSteps(["update_presence"]);
5963
pyEnv["bus.bus"]._sendone(serverState.partnerId, "bus.bus/im_status_updated", {
@@ -73,6 +77,8 @@ test("update presence when user comes back from away", async () => {
7377
},
7478
});
7579
localStorage.setItem("presence.lastPresence", Date.now() - AWAY_DELAY);
80+
const pyEnv = await startServer();
81+
pyEnv["res.partner"].write(serverState.partnerId, { im_status: "away" });
7682
await start();
7783
await waitForSteps([AWAY_DELAY]);
7884
localStorage.setItem("presence.lastPresence", Date.now());
@@ -88,6 +94,8 @@ test("update presence when user status changes to away", async () => {
8894
},
8995
});
9096
localStorage.setItem("presence.lastPresence", Date.now());
97+
const pyEnv = await startServer();
98+
pyEnv["res.partner"].write(serverState.partnerId, { im_status: "online" });
9199
await start();
92100
await waitForSteps([0]);
93101
await advanceTime(AWAY_DELAY);

0 commit comments

Comments
 (0)