Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
bots settings: Add puppeteer test for edit bot setting.
akshatdalton5eff43f5d968
diff --git a/frontend_tests/puppeteer_tests/settings.ts b/frontend_tests/puppeteer_tests/settings.tsindex 2a166ed56a7..9670347cf9b 100644--- a/frontend_tests/puppeteer_tests/settings.ts+++ b/frontend_tests/puppeteer_tests/settings.ts@@ -186,12 +186,45 @@ async function test_edit_bot_form(page: Page): Promise<void> {await page.waitForFunction(() => $(".overlay.show").attr("style") === undefined);}+async function test_invalid_edit_bot_form(page: Page): Promise<void> {+ const bot1_email = "[email protected]";+ const bot1_edit_btn = `.open_edit_bot_form[data-email="${CSS.escape(bot1_email)}"]`;+ await page.click(bot1_edit_btn);++ const edit_form_selector = `.edit_bot_form[data-email="${CSS.escape(bot1_email)}"]`;+ await page.waitForSelector(edit_form_selector, {visible: true});+ const name_field_selector = edit_form_selector + " [name=bot_name]";+ assert(common.get_text_from_selector(page, name_field_selector), "Bot one");++ await common.fill_form(page, edit_form_selector, {bot_name: "Bot 2"});+ const save_btn_selector = edit_form_selector + " .edit_bot_button";+ await page.click(save_btn_selector);++ // The form should not get closed on saving. Errors should be visible on the form.+ await page.waitForSelector("#edit_bot_modal", {visible: true});+ await page.waitForSelector(".bot_edit_errors", {visible: true});+ assert.strictEqual(+ await common.get_text_from_selector(page, "div.bot_edit_errors"),+ "Name is already in use!",+ );+ await page.click("button.cancel_bot_button");+ await page.waitForSelector("#edit_bot_modal", {hidden: true});++ await page.waitForXPath(+ `//*[@class="btn open_edit_bot_form" and @data-email="${bot1_email}"]/ancestor::*[@class="details"]/*[@class="name" and text()="Bot one"]`,+ );++ // Ensure that the mouse events are enabled for the background for further tests.+ await page.waitForFunction(() => $(".overlay.show").attr("style") === undefined);+}+async function test_your_bots_section(page: Page): Promise<void> {await page.click('[data-section="your-bots"]');await test_webhook_bot_creation(page);await test_normal_bot_creation(page);await test_botserverrc(page);await test_edit_bot_form(page);+ await test_invalid_edit_bot_form(page);}const alert_word_status_selector = "#alert_word_status";diff --git a/static/templates/edit_bot.hbs b/static/templates/edit_bot.hbsindex be0a1da3910..bf5aa03073d 100644--- a/static/templates/edit_bot.hbs+++ b/static/templates/edit_bot.hbs@@ -18,7 +18,7 @@list_placeholder=(t 'Filter users')reset_button_text=(t '[Remove owner]')}}</div>- <div class="">+ <div class="edit-bot-name"><label for="edit_bot_name">{{t "Full name" }}</label><input id="edit_bot_name" type="text" name="bot_name" class="edit_bot_name required" value="{{bot.full_name}}" maxlength=50 /><div><label for="edit_bot_name" generated="true" class="text-error"></label></div>@@ -38,7 +38,7 @@<div><div class="modal-footer"><div class="edit_bot_spinner"></div>- <button class="button white rounded" type="button" data-dismiss="modal">{{t "Cancel" }}</button>+ <button class="button white rounded cancel_bot_button" type="button" data-dismiss="modal">{{t "Cancel" }}</button><input type="submit" class="button rounded sea-green edit_bot_button" value="{{t 'Save' }}" /></div></div>