stream_create: Fix puppeteer test flake from modal reopening.

In 245357c868 we added a redirect
after stream creation, to go to the stream feed. This means
the stream settings modal was closed partway through the tests.
This caused a flake where when the modal was reopened it was
not always open by the time we fetched the stream name.

The main fix in this commit is changing the classname for
the stream in the modal to be more specific (`stream-name`
can also be found in the left sidebar in many places) and
waiting for it to be visible again before getting text from
it.

More discussion here:
https://chat.zulip.org/#narrow/channel/43-automated-testing/topic/stream.20create.20puppeteer.20failure/near/1976724

Co-authored-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
evykassirer 2024-11-06 17:05:55 -08:00 committed by Anders Kaseorg
parent a669fece3a
commit cb6c60ef7a
1 changed files with 9 additions and 1 deletions

View File

@ -96,11 +96,19 @@ async function create_stream(page: Page): Promise<void> {
await common.wait_for_micromodal_to_open(page); await common.wait_for_micromodal_to_open(page);
await page.click(".dialog_submit_button"); await page.click(".dialog_submit_button");
await common.wait_for_micromodal_to_close(page); await common.wait_for_micromodal_to_close(page);
// We redirect to the channel message view.
await page.waitForSelector("#subscription_overlay", {hidden: true});
await page.waitForSelector(
`xpath///*[${common.has_class_x("message-header-navbar-title")} and text()="Puppeteer"]`,
);
await page.waitForSelector(".message-header-stream-settings-button"); await page.waitForSelector(".message-header-stream-settings-button");
await page.click(".message-header-stream-settings-button"); await page.click(".message-header-stream-settings-button");
await page.waitForSelector(".stream_section"); await page.waitForSelector(".stream_section");
await page.waitForSelector( await page.waitForSelector(
`xpath///*[${common.has_class_x("stream-name")} and text()="Puppeteer"]`, `xpath///*[${common.has_class_x("stream-name-title")} and text()="Puppeteer"]`,
{visible: true},
); );
const stream_name = await common.get_text_from_selector( const stream_name = await common.get_text_from_selector(
page, page,