From 821a409c8b894082dcd39f6fe1fc1d1e55383588 Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Wed, 7 Dec 2022 17:40:53 +0530 Subject: [PATCH] settings: Remove ID from save button in save-discard widget. This commit removes ID from save button in save-discard widget. Generating IDs using variables results in difficulty to grep the code and we can anyway access the save button by using ID of the settings-subsection-parent div. --- frontend_tests/puppeteer_tests/admin.ts | 24 +++++++++++-------- .../settings/settings_save_discard_widget.hbs | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/frontend_tests/puppeteer_tests/admin.ts b/frontend_tests/puppeteer_tests/admin.ts index 6ea471d073..c3815153f2 100644 --- a/frontend_tests/puppeteer_tests/admin.ts +++ b/frontend_tests/puppeteer_tests/admin.ts @@ -5,9 +5,11 @@ import type {ElementHandle, Page} from "puppeteer"; import * as common from "../puppeteer_lib/common"; async function submit_notifications_stream_settings(page: Page): Promise { - await page.waitForSelector('#org-submit-notifications[data-status="unsaved"]', {visible: true}); + await page.waitForSelector('#org-notifications .save-button[data-status="unsaved"]', { + visible: true, + }); - const save_button = "#org-submit-notifications"; + const save_button = "#org-notifications .save-button"; assert.strictEqual( await common.get_text_from_selector(page, save_button), "Save changes", @@ -15,14 +17,16 @@ async function submit_notifications_stream_settings(page: Page): Promise { ); await page.click(save_button); - await page.waitForSelector('#org-submit-notifications[data-status="saved"]', {visible: true}); + await page.waitForSelector('#org-notifications .save-button[data-status="saved"]', { + visible: true, + }); assert.strictEqual( - await common.get_text_from_selector(page, "#org-submit-notifications"), + await common.get_text_from_selector(page, "#org-notifications .save-button"), "Saved", "Saved text didn't appear after saving new stream notifications setting", ); - await page.waitForSelector("#org-submit-notifications", {hidden: true}); + await page.waitForSelector("#org-notifications .save-button", {hidden: true}); } async function test_change_new_stream_notifications_setting(page: Page): Promise { @@ -82,7 +86,7 @@ async function test_change_signup_notifications_stream(page: Page): Promise { - const saved_status = '#org-submit-stream-permissions[data-status="saved"]'; + const saved_status = '#org-stream-permissions .save-button[data-status="saved"]'; await page.waitForSelector(saved_status, { visible: true, }); @@ -90,7 +94,7 @@ async function test_permissions_change_save_worked(page: Page): Promise { } async function submit_stream_permissions_change(page: Page): Promise { - const save_button = "#org-submit-stream-permissions"; + const save_button = "#org-stream-permissions .save-button"; await page.waitForSelector(save_button, {visible: true}); assert.strictEqual( await common.get_text_from_selector(page, save_button), @@ -127,7 +131,7 @@ async function test_changing_create_streams_and_invite_to_stream_policies( } async function test_save_joining_organization_change_worked(page: Page): Promise { - const saved_status = '#org-submit-org-join[data-status="saved"]'; + const saved_status = '#org-join-settings .save-button[data-status="saved"]'; await page.waitForSelector(saved_status, { visible: true, }); @@ -135,7 +139,7 @@ async function test_save_joining_organization_change_worked(page: Page): Promise } async function submit_joining_organization_change(page: Page): Promise { - const save_button = "#org-submit-org-join"; + const save_button = "#org-join-settings .save-button"; await page.waitForSelector(save_button, {visible: true}); assert.strictEqual( await common.get_text_from_selector(page, save_button), @@ -301,7 +305,7 @@ async function test_authentication_methods(page: Page): Promise { }); await page.click(".method_row[data-method='Google'] input[type='checkbox'] + span"); - const save_button = "#org-submit-auth_settings"; + const save_button = "#org-auth_settings .save-button"; assert.strictEqual(await common.get_text_from_selector(page, save_button), "Save changes"); await page.click(save_button); diff --git a/static/templates/settings/settings_save_discard_widget.hbs b/static/templates/settings/settings_save_discard_widget.hbs index bd2e3c45e6..3b1243d551 100644 --- a/static/templates/settings/settings_save_discard_widget.hbs +++ b/static/templates/settings/settings_save_discard_widget.hbs @@ -1,7 +1,7 @@ {{#unless show_only_indicator}}
-