tests: Fix admin.test.ts failing puppeteer test using waitForFunction.

(cherry picked from commit f7129ae550)
This commit is contained in:
Sayam Samal
2025-04-09 01:38:25 +05:30
committed by Tim Abbott
parent 68c9866a6e
commit bf1c5e08ec

View File

@@ -10,17 +10,26 @@ async function submit_announcements_stream_settings(page: Page): Promise<void> {
});
const save_button = "#org-notifications .save-button";
const button_text = await common.get_text_from_selector(page, save_button);
assert.strictEqual(button_text, "Save changes", "Save button has incorrect text.");
await page.waitForFunction(
(save_button: string) => {
const button = document.querySelector(save_button);
return button && button.textContent?.trim() === "Save changes";
},
{},
save_button,
);
await page.click(save_button);
await page.waitForSelector('#org-notifications .save-button[data-status="saved"]', {
visible: true,
});
assert.strictEqual(
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.waitForFunction(
(save_button: string) => {
const button = document.querySelector(save_button);
return button && button.textContent?.trim() === "Saved";
},
{},
save_button,
);
await page.waitForSelector("#org-notifications .save-button", {hidden: true});