mirror of https://github.com/zulip/zulip.git
e2e-tests: Consistently move fullname lookups to callers.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
067a342b4e
commit
ed5f1455f2
|
@ -78,7 +78,7 @@ async function test_reply_by_click_prepopulates_private_message_recipient(
|
|||
assert.ok(private_message !== null);
|
||||
await private_message.click();
|
||||
await page.waitForSelector("#private_message_recipient", {visible: true});
|
||||
const email = await common.get_internal_email_from_name(page, "cordelia");
|
||||
const email = await common.get_internal_email_from_name(page, common.fullname.cordelia);
|
||||
assert(email !== undefined);
|
||||
await common.pm_recipient.expect(page, email);
|
||||
await close_compose_box(page);
|
||||
|
@ -151,8 +151,8 @@ async function test_send_multirecipient_pm_from_cordelia_pm_narrow(page: Page):
|
|||
await pm.click();
|
||||
await page.waitForSelector("#compose-textarea", {visible: true});
|
||||
const recipient_internal_emails = [
|
||||
await common.get_internal_email_from_name(page, "othello"),
|
||||
await common.get_internal_email_from_name(page, "cordelia"),
|
||||
await common.get_internal_email_from_name(page, common.fullname.othello),
|
||||
await common.get_internal_email_from_name(page, common.fullname.cordelia),
|
||||
].join(",");
|
||||
await common.pm_recipient.expect(page, recipient_internal_emails);
|
||||
}
|
||||
|
|
|
@ -203,8 +203,14 @@ async function test_restore_private_message_draft_via_draft_overlay(page: Page):
|
|||
await common.check_compose_state(page, {
|
||||
content: "Test direct message.",
|
||||
});
|
||||
const cordelia_internal_email = await common.get_internal_email_from_name(page, "cordelia");
|
||||
const hamlet_internal_email = await common.get_internal_email_from_name(page, "hamlet");
|
||||
const cordelia_internal_email = await common.get_internal_email_from_name(
|
||||
page,
|
||||
common.fullname.cordelia,
|
||||
);
|
||||
const hamlet_internal_email = await common.get_internal_email_from_name(
|
||||
page,
|
||||
common.fullname.hamlet,
|
||||
);
|
||||
await common.pm_recipient.expect(page, `${hamlet_internal_email},${cordelia_internal_email}`);
|
||||
assert.strictEqual(
|
||||
await common.get_text_from_selector(page, "title"),
|
||||
|
|
|
@ -49,7 +49,7 @@ export const pm_recipient = {
|
|||
},
|
||||
};
|
||||
|
||||
export const fullname: Record<string, string> = {
|
||||
export const fullname = {
|
||||
cordelia: "Cordelia, Lear's daughter",
|
||||
othello: "Othello, the Moor of Venice",
|
||||
hamlet: "King Hamlet",
|
||||
|
@ -237,9 +237,6 @@ export async function get_stream_id(page: Page, stream_name: string): Promise<nu
|
|||
}
|
||||
|
||||
export async function get_user_id_from_name(page: Page, name: string): Promise<number | undefined> {
|
||||
if (fullname[name] !== undefined) {
|
||||
name = fullname[name];
|
||||
}
|
||||
return await page.evaluate((name: string) => zulip_test.get_user_id_from_name(name), name);
|
||||
}
|
||||
|
||||
|
@ -247,9 +244,6 @@ export async function get_internal_email_from_name(
|
|||
page: Page,
|
||||
name: string,
|
||||
): Promise<string | undefined> {
|
||||
if (fullname[name] !== undefined) {
|
||||
name = fullname[name];
|
||||
}
|
||||
return await page.evaluate((fullname: string) => {
|
||||
const user_id = zulip_test.get_user_id_from_name(fullname);
|
||||
return user_id === undefined ? undefined : zulip_test.get_person_by_user_id(user_id).email;
|
||||
|
|
|
@ -52,8 +52,8 @@ async function test_user_filter_ui(page: Page): Promise<void> {
|
|||
// Desdemona should be there by default
|
||||
await await_user_visible(page, "desdemona");
|
||||
|
||||
await add_user_to_stream(page, "cordelia");
|
||||
await add_user_to_stream(page, "othello");
|
||||
await add_user_to_stream(page, common.fullname.cordelia);
|
||||
await add_user_to_stream(page, common.fullname.othello);
|
||||
|
||||
await page.type(`form#stream_creation_form [name="user_list_filter"]`, "ot", {delay: 100});
|
||||
await page.waitForSelector("#create_stream_subscribers", {visible: true});
|
||||
|
@ -64,16 +64,16 @@ async function test_user_filter_ui(page: Page): Promise<void> {
|
|||
.length === 1,
|
||||
);
|
||||
|
||||
await await_user_hidden(page, "cordelia");
|
||||
await await_user_hidden(page, common.fullname.cordelia);
|
||||
await await_user_hidden(page, "desdemona");
|
||||
await await_user_visible(page, "othello");
|
||||
await await_user_visible(page, common.fullname.othello);
|
||||
|
||||
// Clear the filter.
|
||||
await clear_ot_filter_with_backspace(page);
|
||||
|
||||
await await_user_visible(page, "cordelia");
|
||||
await await_user_visible(page, common.fullname.cordelia);
|
||||
await await_user_visible(page, "desdemona");
|
||||
await await_user_visible(page, "othello");
|
||||
await await_user_visible(page, common.fullname.othello);
|
||||
}
|
||||
|
||||
async function create_stream(page: Page): Promise<void> {
|
||||
|
|
|
@ -41,7 +41,7 @@ async function test_reactivation_confirmation_modal(page: Page, fullname: string
|
|||
}
|
||||
|
||||
async function test_deactivate_user(page: Page): Promise<void> {
|
||||
const cordelia_user_row = await user_row(page, "cordelia");
|
||||
const cordelia_user_row = await user_row(page, common.fullname.cordelia);
|
||||
await page.waitForSelector(cordelia_user_row, {visible: true});
|
||||
await page.waitForSelector(cordelia_user_row + " .fa-user-times");
|
||||
await page.click(cordelia_user_row + " .deactivate");
|
||||
|
@ -62,7 +62,7 @@ async function test_deactivate_user(page: Page): Promise<void> {
|
|||
}
|
||||
|
||||
async function test_reactivate_user(page: Page): Promise<void> {
|
||||
let cordelia_user_row = await user_row(page, "cordelia");
|
||||
let cordelia_user_row = await user_row(page, common.fullname.cordelia);
|
||||
await page.waitForSelector(cordelia_user_row + ".deactivated_user");
|
||||
await page.waitForSelector(cordelia_user_row + " .fa-user-plus");
|
||||
await page.click(cordelia_user_row + " .reactivate");
|
||||
|
@ -70,12 +70,12 @@ async function test_reactivate_user(page: Page): Promise<void> {
|
|||
await test_reactivation_confirmation_modal(page, common.fullname.cordelia);
|
||||
|
||||
await page.waitForSelector(cordelia_user_row + ":not(.deactivated_user)", {visible: true});
|
||||
cordelia_user_row = await user_row(page, "cordelia");
|
||||
cordelia_user_row = await user_row(page, common.fullname.cordelia);
|
||||
await page.waitForSelector(cordelia_user_row + " .fa-user-times");
|
||||
}
|
||||
|
||||
async function test_deactivated_users_section(page: Page): Promise<void> {
|
||||
const cordelia_user_row = await user_row(page, "cordelia");
|
||||
const cordelia_user_row = await user_row(page, common.fullname.cordelia);
|
||||
await test_deactivate_user(page);
|
||||
|
||||
// "Deactivated users" section doesn't render just deactivated users until reloaded.
|
||||
|
|
Loading…
Reference in New Issue