/**
* Selects an option from a PrimeFaces/JSF dropdown menu.
* @param {*} page
* @param {*} locator
* @param {*} option
* @param {*} timeout
*/
const selectDropDown = async (page, locator, option, timeout = 500) => {
// 1. Click the dropdown trigger
await page.locator(locator).click();
// 2. Wait for the option text to be visible anywhere on the page
// This is robust for PrimeFaces where options are often divs/li with text content
const optionLocator = page.getByText(option, { exact: true }).first();
// Wait up to 5 seconds for the option to appear
await expect(optionLocator).toBeVisible({ timeout: 5000 });
// 3. Click the option
await optionLocator.click();
}