Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

1.0 KB
Raw Blame
import { screen, within } from '@testing-library/react';
import type { UserEvent } from '@testing-library/user-event';

/**
 * Picks an option of the phone's own select (MAdminSelect): taps the combobox
 * named `name`, then the option labelled `option` in the picker sheet it opens.
 */
export async function pickMobileOption(user: UserEvent, name: string, option: string): Promise<void> {
  await user.click(screen.getByRole('combobox', { name }));
  const sheet = await screen.findByRole('dialog', { name });
  await user.click(within(sheet).getByRole('button', { name: option }));
}

/** The labels a phone select offers, read from its open picker sheet. */
export async function mobileOptionLabels(user: UserEvent, name: string): Promise<string[]> {
  await user.click(screen.getByRole('combobox', { name }));
  const sheet = await screen.findByRole('dialog', { name });
  return within(sheet)
    .getAllByRole('button')
    .filter((button) => button.getAttribute('aria-label') === null)
    .map((button) => button.textContent ?? '');
}