Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
33 lines
1.4 KiB
TypeScript
33 lines
1.4 KiB
TypeScript
import { fireEvent, screen, within } from "@testing-library/react";
|
||
|
||
function topPopover() {
|
||
const dialogs = screen.getAllByRole("dialog");
|
||
return dialogs[dialogs.length - 1];
|
||
}
|
||
|
||
/** Shows `iso`'s month in the popover's first calendar month and clicks the day. */
|
||
function clickDay(pop: HTMLElement, iso: string) {
|
||
const [month, year] = within(pop).getAllByRole("combobox");
|
||
const [y, m] = iso.split("-").map(Number);
|
||
fireEvent.change(year, { target: { value: String(y) } });
|
||
fireEvent.change(month, { target: { value: String(m - 1) } });
|
||
const day = pop.querySelector<HTMLButtonElement>(`[data-day="${iso}"] button`);
|
||
// A disabled day ignores the click, so fail loudly instead of letting the test pass vacuously.
|
||
if (!day || day.disabled) throw new Error(`pickDate: ${iso} is not an enabled day in the calendar`);
|
||
fireEvent.click(day);
|
||
}
|
||
|
||
/** Picks `iso` (yyyy-MM-dd) in the calendar of the date box labelled `label`. */
|
||
export function pickDate(label: string | RegExp | HTMLElement, iso: string) {
|
||
fireEvent.click(label instanceof HTMLElement ? label : screen.getByLabelText(label));
|
||
clickDay(topPopover(), iso);
|
||
}
|
||
|
||
/** Picks the range `from`–`to` in the calendar of the range box labelled `fromLabel`. */
|
||
export function pickRange(fromLabel: string | RegExp, from: string, to: string) {
|
||
fireEvent.click(screen.getByLabelText(fromLabel));
|
||
const pop = topPopover();
|
||
clickDay(pop, from);
|
||
clickDay(pop, to);
|
||
}
|