2021-02-20 05:52:06 +01:00
|
|
|
import {strict as assert} from "assert";
|
2020-08-13 14:31:34 +02:00
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
import type {Page} from "puppeteer";
|
2020-08-13 14:31:34 +02:00
|
|
|
|
2023-02-22 23:04:11 +01:00
|
|
|
import * as common from "./lib/common";
|
2020-08-13 14:31:34 +02:00
|
|
|
|
2022-07-16 20:54:04 +02:00
|
|
|
// This will be the row of the the custom profile field we add.
|
|
|
|
const profile_field_row = "#admin_profile_fields_table tr:nth-last-child(1)";
|
2020-08-13 14:31:34 +02:00
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function test_add_new_profile_field(page: Page): Promise<void> {
|
2022-06-13 14:39:59 +02:00
|
|
|
await page.click("#add-custom-profile-field-btn");
|
|
|
|
await common.wait_for_micromodal_to_open(page);
|
|
|
|
assert.strictEqual(
|
|
|
|
await common.get_text_from_selector(page, ".dialog_heading"),
|
|
|
|
"Add a new custom profile field",
|
|
|
|
);
|
|
|
|
assert.strictEqual(
|
|
|
|
await common.get_text_from_selector(page, "#dialog_widget_modal .dialog_submit_button"),
|
|
|
|
"Add",
|
|
|
|
);
|
2020-08-13 14:31:34 +02:00
|
|
|
await page.waitForSelector(".admin-profile-field-form", {visible: true});
|
|
|
|
await common.fill_form(page, "form.admin-profile-field-form", {
|
|
|
|
field_type: "1",
|
2022-10-03 20:16:31 +02:00
|
|
|
name: "Teams",
|
2020-08-13 14:31:34 +02:00
|
|
|
});
|
2022-06-13 14:39:59 +02:00
|
|
|
await page.click("#dialog_widget_modal .dialog_submit_button");
|
|
|
|
await common.wait_for_micromodal_to_close(page);
|
2020-08-13 14:31:34 +02:00
|
|
|
|
2022-09-10 05:37:50 +02:00
|
|
|
await page.waitForSelector(
|
|
|
|
'xpath///*[@id="admin_profile_fields_table"]//tr[last()]/td[normalize-space()="Teams"]',
|
2021-03-12 23:13:45 +01:00
|
|
|
);
|
2020-08-13 14:31:34 +02:00
|
|
|
assert.strictEqual(
|
|
|
|
await common.get_text_from_selector(page, `${profile_field_row} span.profile_field_type`),
|
|
|
|
"Short text",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function test_edit_profile_field(page: Page): Promise<void> {
|
2022-07-16 20:54:04 +02:00
|
|
|
await page.click(`${profile_field_row} button.open-edit-form-modal`);
|
|
|
|
await common.wait_for_micromodal_to_open(page);
|
|
|
|
assert.strictEqual(
|
|
|
|
await common.get_text_from_selector(page, ".dialog_heading"),
|
|
|
|
"Edit custom profile field",
|
|
|
|
);
|
|
|
|
assert.strictEqual(
|
|
|
|
await common.get_text_from_selector(page, "#dialog_widget_modal .dialog_submit_button"),
|
|
|
|
"Save changes",
|
|
|
|
);
|
|
|
|
await common.fill_form(page, "form.name-setting", {
|
2020-08-13 14:31:34 +02:00
|
|
|
name: "team",
|
|
|
|
});
|
2022-07-16 20:54:04 +02:00
|
|
|
await page.click("#dialog_widget_modal .dialog_submit_button");
|
|
|
|
await common.wait_for_micromodal_to_close(page);
|
2020-08-13 14:31:34 +02:00
|
|
|
|
2022-09-10 05:37:50 +02:00
|
|
|
await page.waitForSelector(
|
|
|
|
'xpath///*[@id="admin_profile_fields_table"]//tr[last()]/td[normalize-space()="team"]',
|
2021-03-12 23:13:45 +01:00
|
|
|
);
|
2020-08-13 14:31:34 +02:00
|
|
|
assert.strictEqual(
|
|
|
|
await common.get_text_from_selector(page, `${profile_field_row} span.profile_field_type`),
|
|
|
|
"Short text",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function test_delete_custom_profile_field(page: Page): Promise<void> {
|
2020-08-13 14:31:34 +02:00
|
|
|
await page.click(`${profile_field_row} button.delete`);
|
2022-08-29 18:43:14 +02:00
|
|
|
await common.wait_for_micromodal_to_open(page);
|
|
|
|
assert.strictEqual(
|
|
|
|
await common.get_text_from_selector(page, ".dialog_heading"),
|
|
|
|
"Delete custom profile field?",
|
|
|
|
);
|
|
|
|
assert.strictEqual(
|
|
|
|
await common.get_text_from_selector(page, "#dialog_widget_modal .dialog_submit_button"),
|
|
|
|
"Confirm",
|
|
|
|
);
|
|
|
|
await page.click("#dialog_widget_modal .dialog_submit_button");
|
|
|
|
await common.wait_for_micromodal_to_close(page);
|
|
|
|
|
2020-08-13 14:31:34 +02:00
|
|
|
await page.waitForSelector("#admin-profile-field-status img", {visible: true});
|
|
|
|
assert.strictEqual(
|
|
|
|
await common.get_text_from_selector(page, "div#admin-profile-field-status"),
|
|
|
|
"Saved",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-02-20 05:52:06 +01:00
|
|
|
async function test_custom_profile(page: Page): Promise<void> {
|
2020-08-13 14:31:34 +02:00
|
|
|
await common.log_in(page);
|
|
|
|
await common.manage_organization(page);
|
|
|
|
|
|
|
|
console.log("Testing custom profile fields");
|
|
|
|
await page.click("li[data-section='profile-field-settings']");
|
|
|
|
|
|
|
|
await test_add_new_profile_field(page);
|
|
|
|
await test_edit_profile_field(page);
|
|
|
|
await test_delete_custom_profile_field(page);
|
|
|
|
}
|
|
|
|
|
|
|
|
common.run_test(test_custom_profile);
|