Skip to article
Documentation

e2e/money-input.ts

Linked repository file from this build.

import type { Locator } from "@playwright/test";

/**
 * Replace a MoneyInput value the way staff type it. The field keeps the caret at the end
 * and shifts digits in from the cents, so fill() would append to the old value.
 */
export async function enterMoney(field: Locator, amount: string) {
  await field.focus();
  await field.press("ControlOrMeta+a");
  await field.pressSequentially(amount.replace(/\D/g, ""));
}