| 1 |
import { escapeRegExp } from "@web/core/utils/strings"; |
| 2 |
|
| 3 |
export const buttonTriger = (buttonValue) => |
| 4 |
`div.numpad button:contains(/^${escapeRegExp(buttonValue)}$/)`; // regex to match the exact button value ( for ex: avoids matching "+10" instead of "1") |
| 5 |
|
| 6 |
export const click = (buttonValue) => ({ |
| 7 |
content: `click numpad button: ${buttonValue}`, |
| 8 |
trigger: buttonTriger(buttonValue), |
| 9 |
run: "click", |
| 10 |
}); |
| 11 |
export const enterValue = (keys) => keys.split("").map((key) => click(key)); |
| 12 |
export const isActive = (buttonValue) => ({ |
| 13 |
content: `check if --${buttonValue}-- mode is activated`, |
| 14 |
trigger: `${buttonTriger(buttonValue)}.active`, |
| 15 |
}); |
| 16 |
|
| 17 |
export const isVisible = () => ({ |
| 18 |
content: "check if numpad is visible", |
| 19 |
trigger: "div.numpad:visible", |
| 20 |
}); |