import { BaseMenu } from '@/manager/shared/base/BaseMenu';
import { Locator } from '@playwright/test';

export class OptionMenu extends BaseMenu {
  async select(value: string): Promise<void> {
    const option = await this.getOption(value);
    await option.click();
  }

  async getOption(name: string): Promise<Locator> {
    const body = await this.getBody();
    // TODO: not working correctly with more complex option names e.g. options having titles and subtitles
    return body.locator(`.v-list-item:has(:text-is("${name}"))`);
  }
}
