2021-07-01 17:25:18 +02:00
|
|
|
import type {Page} from "puppeteer";
|
|
|
|
|
2023-02-22 23:04:11 +01:00
|
|
|
import * as common from "./lib/common";
|
2021-07-01 17:25:18 +02:00
|
|
|
|
|
|
|
async function open_set_user_status_modal(page: Page): Promise<void> {
|
2021-07-30 06:54:08 +02:00
|
|
|
const menu_icon_selector = ".user_sidebar_entry:first-child .user-list-sidebar-menu-icon";
|
|
|
|
// We are clicking on the menu icon with the help of `waitForFunction` because the list
|
|
|
|
// re-renders many times and can cause the element to become stale.
|
|
|
|
await page.waitForFunction(
|
|
|
|
(selector: string): boolean => {
|
|
|
|
const menu_icon = document.querySelector(selector);
|
|
|
|
if (menu_icon) {
|
|
|
|
(menu_icon as HTMLSpanElement).click();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
menu_icon_selector,
|
|
|
|
);
|
2021-07-01 17:25:18 +02:00
|
|
|
await page.waitForSelector(".user_popover", {visible: true});
|
|
|
|
// We are using evaluate to click because it is very hard to detect if the user info popover has opened.
|
|
|
|
await page.evaluate(() =>
|
2023-04-19 23:48:44 +02:00
|
|
|
document.querySelector<HTMLAnchorElement>(".update_status_text")!.click(),
|
2021-07-01 17:25:18 +02:00
|
|
|
);
|
2021-07-30 06:54:08 +02:00
|
|
|
|
|
|
|
// Wait for the modal to completely open.
|
2021-07-07 09:16:19 +02:00
|
|
|
await common.wait_for_micromodal_to_open(page);
|
2021-07-01 17:25:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async function test_user_status(page: Page): Promise<void> {
|
|
|
|
await open_set_user_status_modal(page);
|
|
|
|
// Check by clicking on common statues.
|
2022-02-18 15:38:34 +01:00
|
|
|
await page.click(".user-status-value:nth-child(2)");
|
2021-07-01 17:25:18 +02:00
|
|
|
await page.waitForFunction(
|
2023-04-19 23:48:44 +02:00
|
|
|
() => document.querySelector<HTMLInputElement>(".user-status")!.value === "In a meeting",
|
2021-07-01 17:25:18 +02:00
|
|
|
);
|
|
|
|
// It should select calendar emoji.
|
2023-03-15 19:53:35 +01:00
|
|
|
await page.waitForSelector(".selected-emoji.emoji-1f4c5");
|
2021-07-01 17:25:18 +02:00
|
|
|
|
|
|
|
// Clear everything.
|
|
|
|
await page.click("#clear_status_message_button");
|
|
|
|
await page.waitForFunction(
|
2023-04-19 23:48:44 +02:00
|
|
|
() => document.querySelector<HTMLInputElement>(".user-status")!.value === "",
|
2021-07-01 17:25:18 +02:00
|
|
|
);
|
2023-03-15 20:36:05 +01:00
|
|
|
await page.waitForSelector(".status-emoji-wrapper .smiley-icon", {visible: true});
|
2021-07-01 17:25:18 +02:00
|
|
|
|
2021-10-18 16:30:46 +02:00
|
|
|
// Manually adding everything.
|
2023-03-15 19:45:26 +01:00
|
|
|
await page.type(".user-status", "Busy");
|
2021-07-01 17:25:18 +02:00
|
|
|
const tada_emoji_selector = ".emoji-1f389";
|
2023-03-15 20:36:05 +01:00
|
|
|
await page.click(".status-emoji-wrapper .smiley-icon");
|
2021-07-01 17:25:18 +02:00
|
|
|
// Wait until emoji popover is opened.
|
|
|
|
await page.waitForSelector(`.emoji-popover ${tada_emoji_selector}`, {visible: true});
|
|
|
|
await page.click(`.emoji-popover ${tada_emoji_selector}`);
|
2023-08-25 15:26:28 +02:00
|
|
|
await page.waitForSelector(".emoji-picker-popover", {hidden: true});
|
2023-03-15 19:53:35 +01:00
|
|
|
await page.waitForSelector(`.selected-emoji${tada_emoji_selector}`);
|
2021-07-01 17:25:18 +02:00
|
|
|
|
2023-03-15 19:39:06 +01:00
|
|
|
await page.click("#set-user-status-modal .dialog_submit_button");
|
2021-07-01 17:25:18 +02:00
|
|
|
// It should close the modal after saving.
|
2023-03-15 19:39:06 +01:00
|
|
|
await page.waitForSelector("#set-user-status-modal", {hidden: true});
|
2021-07-01 17:25:18 +02:00
|
|
|
|
2021-10-18 16:30:46 +02:00
|
|
|
// Check if the emoji is added in user presence list.
|
2023-03-15 21:56:35 +01:00
|
|
|
await page.waitForSelector(`.user-presence-link .status-emoji${tada_emoji_selector}`);
|
2021-07-01 17:25:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async function user_status_test(page: Page): Promise<void> {
|
|
|
|
await common.log_in(page);
|
|
|
|
await test_user_status(page);
|
|
|
|
}
|
|
|
|
|
|
|
|
common.run_test(user_status_test);
|