mirror of https://github.com/zulip/zulip.git
puppeteer: Fix flaky wait for narrow change after sending a message.
This flake was happening since `wait_for_fully_processed_message` only checks if the `star` icon is displayed on the message but doesn't check for current narrow or waits for the narrow to change. Since narrow is changed to the message narrow after sending a message. If we don't wait for narrow to change, this narrow change can make the `get_current_msg_list_id` call return true for the wrong narrow change. Which causes message list id of the wrong message list to be returned and hence we cannot locate this message list id. To fix it, we check if sending this message will cause a narrow change and if true, we wait for the narrow to change before checking if the message is visible.
This commit is contained in:
parent
882e4f56c1
commit
dae2a68ad9
|
@ -134,11 +134,15 @@ async function test_narrow_to_private_messages_with_cordelia(page: Page): Promis
|
|||
async function test_send_multirecipient_pm_from_cordelia_pm_narrow(page: Page): Promise<void> {
|
||||
const recipients = ["cordelia@zulip.com", "othello@zulip.com"];
|
||||
const multiple_recipients_pm = "A direct message group to check spaces";
|
||||
await common.send_message(page, "private", {
|
||||
recipient: recipients.join(", "),
|
||||
outside_view: true,
|
||||
content: multiple_recipients_pm,
|
||||
});
|
||||
await common.send_message(
|
||||
page,
|
||||
"private",
|
||||
{
|
||||
recipient: recipients.join(", "),
|
||||
content: multiple_recipients_pm,
|
||||
},
|
||||
false,
|
||||
);
|
||||
|
||||
// Go back to the combined feed view and make sure all messages are loaded.
|
||||
await page.click("#left-sidebar-navigation-list .top_left_all_messages");
|
||||
|
|
|
@ -306,7 +306,6 @@ async function drafts_test(page: Page): Promise<void> {
|
|||
await common.send_message(page, "private", {
|
||||
recipient: "cordelia@zulip.com, hamlet@zulip.com",
|
||||
content: "howdy doo",
|
||||
outside_view: true,
|
||||
});
|
||||
await create_private_message_draft(page);
|
||||
// Close and try restoring it by opening the composebox again.
|
||||
|
|
|
@ -38,7 +38,7 @@ async function test_stream_message_edit(page: Page): Promise<void> {
|
|||
|
||||
await edit_stream_message(page, "test edited");
|
||||
|
||||
const message_list_id = await common.get_current_msg_list_id(page, true);
|
||||
const message_list_id = await common.get_current_msg_list_id(page, false);
|
||||
await common.check_messages_sent(page, message_list_id, [["Verona > edits", ["test edited"]]]);
|
||||
}
|
||||
|
||||
|
@ -47,11 +47,16 @@ async function test_edit_message_with_slash_me(page: Page): Promise<void> {
|
|||
"messagebox",
|
||||
)}])[last()]`;
|
||||
|
||||
await common.send_message(page, "stream", {
|
||||
stream_name: "Verona",
|
||||
topic: "edits",
|
||||
content: "/me test editing a message with me",
|
||||
});
|
||||
await common.send_message(
|
||||
page,
|
||||
"stream",
|
||||
{
|
||||
stream_name: "Verona",
|
||||
topic: "edits",
|
||||
content: "/me test editing a message with me",
|
||||
},
|
||||
false,
|
||||
);
|
||||
await page.waitForSelector(
|
||||
`xpath/${last_message_xpath}//*[${common.has_class_x(
|
||||
"status-message",
|
||||
|
@ -88,7 +93,7 @@ async function test_edit_private_message(page: Page): Promise<void> {
|
|||
await page.click(".message_edit_save");
|
||||
await common.wait_for_fully_processed_message(page, "test edited pm");
|
||||
|
||||
const message_list_id = await common.get_current_msg_list_id(page, true);
|
||||
const message_list_id = await common.get_current_msg_list_id(page, false);
|
||||
await common.check_messages_sent(page, message_list_id, [
|
||||
["You and Cordelia, Lear's daughter", ["test edited pm"]],
|
||||
]);
|
||||
|
|
|
@ -411,12 +411,8 @@ export async function send_message(
|
|||
page: Page,
|
||||
type: "stream" | "private",
|
||||
params: Message,
|
||||
wait_for_narrow_change = true,
|
||||
): Promise<void> {
|
||||
// If a message is outside the view, we do not need
|
||||
// to wait for it to be processed later.
|
||||
const outside_view = params.outside_view;
|
||||
delete params.outside_view;
|
||||
|
||||
// Compose box content should be empty before sending the message.
|
||||
await assert_compose_box_content(page, "");
|
||||
|
||||
|
@ -449,12 +445,15 @@ export async function send_message(
|
|||
await page.waitForSelector("#compose-send-button", {visible: true});
|
||||
await page.click("#compose-send-button");
|
||||
|
||||
if (wait_for_narrow_change) {
|
||||
// After the message is sent, wait for the narrow
|
||||
// to change to the message recipient.
|
||||
await get_current_msg_list_id(page, true);
|
||||
}
|
||||
|
||||
// Sending should clear compose box content.
|
||||
await assert_compose_box_content(page, "");
|
||||
|
||||
if (!outside_view) {
|
||||
await wait_for_fully_processed_message(page, params.content);
|
||||
}
|
||||
await wait_for_fully_processed_message(page, params.content);
|
||||
|
||||
// Close the compose box after sending the message.
|
||||
await page.evaluate(() => {
|
||||
|
@ -465,8 +464,24 @@ export async function send_message(
|
|||
}
|
||||
|
||||
export async function send_multiple_messages(page: Page, msgs: Message[]): Promise<void> {
|
||||
let last_msg_stream;
|
||||
let last_msg_topic;
|
||||
let last_msg_recipient;
|
||||
for (const msg of msgs) {
|
||||
await send_message(page, msg.stream_name !== undefined ? "stream" : "private", msg);
|
||||
const msg_type = msg.stream_name !== undefined ? "stream" : "private";
|
||||
// Check if `msg` and `last_msg` are in the same narrow.
|
||||
let wait_for_narrow_change = true;
|
||||
if (
|
||||
msg.stream_name === last_msg_stream &&
|
||||
msg.topic === last_msg_topic &&
|
||||
msg.recipient === last_msg_recipient
|
||||
) {
|
||||
wait_for_narrow_change = false;
|
||||
}
|
||||
last_msg_stream = msg.stream_name;
|
||||
last_msg_topic = msg.topic;
|
||||
last_msg_recipient = msg.recipient;
|
||||
await send_message(page, msg_type, msg, wait_for_narrow_change);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -517,27 +517,23 @@ async function message_basic_tests(page: Page): Promise<void> {
|
|||
stream_name: "Verona",
|
||||
topic: "other topic",
|
||||
content: "verona other topic c",
|
||||
outside_view: true,
|
||||
},
|
||||
{stream_name: "Denmark", topic: "test", content: "denmark message", outside_view: true},
|
||||
{stream_name: "Denmark", topic: "test", content: "denmark message"},
|
||||
{
|
||||
recipient: "cordelia@zulip.com, hamlet@zulip.com",
|
||||
content: "group direct message a",
|
||||
outside_view: true,
|
||||
},
|
||||
{
|
||||
recipient: "cordelia@zulip.com, hamlet@zulip.com",
|
||||
content: "group direct message b",
|
||||
outside_view: true,
|
||||
},
|
||||
{recipient: "cordelia@zulip.com", content: "direct message c", outside_view: true},
|
||||
{recipient: "cordelia@zulip.com", content: "direct message c"},
|
||||
{stream_name: "Verona", topic: "test", content: "verona test d"},
|
||||
{
|
||||
recipient: "cordelia@zulip.com, hamlet@zulip.com",
|
||||
content: "group direct message d",
|
||||
outside_view: true,
|
||||
},
|
||||
{recipient: "cordelia@zulip.com", content: "direct message e", outside_view: true},
|
||||
{recipient: "cordelia@zulip.com", content: "direct message e"},
|
||||
]);
|
||||
|
||||
await page.click("#left-sidebar-navigation-list .top_left_all_messages");
|
||||
|
|
|
@ -61,7 +61,7 @@ async function stars_test(page: Page): Promise<void> {
|
|||
|
||||
await toggle_test_star_message(page);
|
||||
await page.click("#left-sidebar-navigation-list .top_left_all_messages");
|
||||
message_list_id = await common.get_current_msg_list_id(page, true);
|
||||
message_list_id = await common.get_current_msg_list_id(page, false);
|
||||
await page.waitForSelector(
|
||||
`.message-list[data-message-list-id='${message_list_id}'] .zulip-icon-star-filled`,
|
||||
{visible: true},
|
||||
|
|
Loading…
Reference in New Issue