mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 03:53:50 +00:00 
			
		
		
		
	compose: Change stream field in composebox to be a dropdown.
Fixes #11832 This lets the user see more options than the three that appear in the typeahead menu, and prevents them from inputting invalid stream names. This change replaces the input field with the dropdown, and updates everything that referred to the classnames of the old input field, so that they now get the data they need from the new dropdown.
This commit is contained in:
		| @@ -14,7 +14,11 @@ import {test_credentials} from "../../../var/puppeteer/test_credentials"; | ||||
| const root_dir = path.resolve(__dirname, "../../.."); | ||||
| const puppeteer_dir = path.join(root_dir, "var/puppeteer"); | ||||
|  | ||||
| type Message = Record<string, string | boolean> & {recipient?: string; content: string}; | ||||
| type Message = Record<string, string | boolean> & { | ||||
|     recipient?: string; | ||||
|     content: string; | ||||
|     stream?: string; | ||||
| }; | ||||
|  | ||||
| let browser: Browser | null = null; | ||||
| let screenshot_id = 0; | ||||
| @@ -205,7 +209,10 @@ export async function check_compose_state( | ||||
| ): Promise<void> { | ||||
|     const form_params: Record<string, string> = {content: params.content}; | ||||
|     if (params.stream) { | ||||
|         form_params.stream_message_recipient_stream = params.stream; | ||||
|         assert.equal( | ||||
|             await get_text_from_selector(page, "#compose_select_stream_name"), | ||||
|             params.stream, | ||||
|         ); | ||||
|     } | ||||
|     if (params.topic) { | ||||
|         form_params.stream_message_recipient_topic = params.topic; | ||||
| @@ -377,6 +384,26 @@ export async function wait_for_fully_processed_message(page: Page, content: stri | ||||
|     await scroll_delay; | ||||
| } | ||||
|  | ||||
| export async function select_item_via_dropdown( | ||||
|     page: Page, | ||||
|     dropdown_selector: string, | ||||
|     item: string, | ||||
| ): Promise<void> { | ||||
|     console.log(`Clicking on ${dropdown_selector} to select ${item}`); | ||||
|     const menu_visible = (await page.$(`${dropdown_selector} .open`)) !== null; | ||||
|     if (!menu_visible) { | ||||
|         await page.waitForSelector(dropdown_selector, {visible: true}); | ||||
|         await page.click(`${dropdown_selector} .dropdown-toggle`); | ||||
|         await page.waitForSelector(`${dropdown_selector} .dropdown-menu`, {visible: true}); | ||||
|     } | ||||
|     const entry_selector = `xpath///*[${has_class_x( | ||||
|         "list_item", | ||||
|     )} and contains(normalize-space(), "${item}")]`; | ||||
|     await page.waitForSelector(entry_selector, {visible: true}); | ||||
|     await page.click(entry_selector); | ||||
|     await page.waitForSelector(`.dropdown-menu`, {visible: false}); | ||||
| } | ||||
|  | ||||
| // Wait for any previous send to finish, then send a message. | ||||
| export async function send_message( | ||||
|     page: Page, | ||||
| @@ -405,7 +432,7 @@ export async function send_message( | ||||
|     } | ||||
|  | ||||
|     if (params.stream) { | ||||
|         params.stream_message_recipient_stream = params.stream; | ||||
|         await select_item_via_dropdown(page, "#compose_select_stream_widget", params.stream); | ||||
|         delete params.stream; | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user