mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
puppeteer: Migrate custom profile test from casper.
This commit is contained in:
@@ -1,72 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
var common = require("../casper_lib/common.js");
|
|
||||||
|
|
||||||
common.start_and_log_in();
|
|
||||||
|
|
||||||
common.manage_organization();
|
|
||||||
|
|
||||||
// Test custom profile fields
|
|
||||||
casper.test.info("Testing custom profile fields");
|
|
||||||
casper.thenClick("li[data-section='profile-field-settings']");
|
|
||||||
casper.then(function () {
|
|
||||||
casper.waitUntilVisible(".admin-profile-field-form", function () {
|
|
||||||
casper.fill("form.admin-profile-field-form", {
|
|
||||||
name: "Teams",
|
|
||||||
field_type: "1",
|
|
||||||
});
|
|
||||||
casper.click("form.admin-profile-field-form button[type='submit']");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
casper.then(function () {
|
|
||||||
casper.waitUntilVisible("#admin-add-profile-field-status img", function () {
|
|
||||||
casper.test.assertSelectorHasText("div#admin-add-profile-field-status", "Saved");
|
|
||||||
common.wait_for_text(".profile-field-row span.profile_field_name", "Teams", function () {
|
|
||||||
casper.test.assertSelectorHasText(
|
|
||||||
".profile-field-row span.profile_field_name",
|
|
||||||
"Teams"
|
|
||||||
);
|
|
||||||
casper.test.assertSelectorHasText(
|
|
||||||
".profile-field-row span.profile_field_type",
|
|
||||||
"Short text"
|
|
||||||
);
|
|
||||||
casper.click(".profile-field-row button.open-edit-form");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
casper.then(function () {
|
|
||||||
casper.waitUntilVisible("tr.profile-field-form form", function () {
|
|
||||||
casper.fill("tr.profile-field-form form.name-setting", {
|
|
||||||
name: "team",
|
|
||||||
});
|
|
||||||
casper.click("tr.profile-field-form button.submit");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
casper.then(function () {
|
|
||||||
casper.waitUntilVisible("#admin-profile-field-status img", function () {
|
|
||||||
casper.test.assertSelectorHasText("div#admin-profile-field-status", "Saved");
|
|
||||||
});
|
|
||||||
casper.waitForSelectorTextChange(".profile-field-row span.profile_field_name", function () {
|
|
||||||
casper.test.assertSelectorHasText(".profile-field-row span.profile_field_name", "team");
|
|
||||||
casper.test.assertSelectorHasText(
|
|
||||||
".profile-field-row span.profile_field_type",
|
|
||||||
"Short text"
|
|
||||||
);
|
|
||||||
casper.click(".profile-field-row button.delete");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
casper.then(function () {
|
|
||||||
casper.waitUntilVisible("#admin-profile-field-status img", function () {
|
|
||||||
casper.test.assertSelectorHasText("div#admin-profile-field-status", "Saved");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
common.then_log_out();
|
|
||||||
|
|
||||||
casper.run(function () {
|
|
||||||
casper.test.done();
|
|
||||||
});
|
|
||||||
70
frontend_tests/puppeteer_tests/10-custom-profile.js
Normal file
70
frontend_tests/puppeteer_tests/10-custom-profile.js
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const assert = require("assert").strict;
|
||||||
|
|
||||||
|
const common = require("../puppeteer_lib/common");
|
||||||
|
|
||||||
|
// These will be the row and edit form of the the custom profile we add.
|
||||||
|
const profile_field_row = "#admin_profile_fields_table tr:nth-last-child(2)";
|
||||||
|
const profile_field_form = "#admin_profile_fields_table tr:nth-last-child(1)";
|
||||||
|
|
||||||
|
async function test_add_new_profile_field(page) {
|
||||||
|
await page.waitForSelector(".admin-profile-field-form", {visible: true});
|
||||||
|
await common.fill_form(page, "form.admin-profile-field-form", {
|
||||||
|
name: "Teams",
|
||||||
|
field_type: "1",
|
||||||
|
});
|
||||||
|
await page.click("form.admin-profile-field-form button[type='submit']");
|
||||||
|
|
||||||
|
await page.waitForSelector("#admin-add-profile-field-status img", {visible: true});
|
||||||
|
assert.strictEqual(
|
||||||
|
await common.get_text_from_selector(page, "div#admin-add-profile-field-status"),
|
||||||
|
"Saved",
|
||||||
|
);
|
||||||
|
await common.wait_for_text(page, `${profile_field_row} span.profile_field_name`, "Teams");
|
||||||
|
assert.strictEqual(
|
||||||
|
await common.get_text_from_selector(page, `${profile_field_row} span.profile_field_type`),
|
||||||
|
"Short text",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function test_edit_profile_field(page) {
|
||||||
|
await page.click(`${profile_field_row} button.open-edit-form`);
|
||||||
|
await page.waitForSelector(`${profile_field_form} form.name-setting`, {visible: true});
|
||||||
|
await common.fill_form(page, `${profile_field_form} form.name-setting`, {
|
||||||
|
name: "team",
|
||||||
|
});
|
||||||
|
await page.click(`${profile_field_form} button.submit`);
|
||||||
|
|
||||||
|
await page.waitForSelector("#admin-profile-field-status img", {visible: true});
|
||||||
|
await common.wait_for_text(page, `${profile_field_row} span.profile_field_name`, "team");
|
||||||
|
assert.strictEqual(
|
||||||
|
await common.get_text_from_selector(page, `${profile_field_row} span.profile_field_type`),
|
||||||
|
"Short text",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function test_delete_custom_profile_field(page) {
|
||||||
|
await page.click(`${profile_field_row} button.delete`);
|
||||||
|
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",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function test_custom_profile(page) {
|
||||||
|
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);
|
||||||
|
|
||||||
|
await common.log_out(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
common.run_test(test_custom_profile);
|
||||||
Reference in New Issue
Block a user