| 1 |
import * as SelectionPopup from "@point_of_sale/../tests/generic_helpers/selection_popup_util"; |
| 2 |
import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util"; |
| 3 |
import * as NumberPopup from "@point_of_sale/../tests/generic_helpers/number_popup_util"; |
| 4 |
import { negate } from "@point_of_sale/../tests/generic_helpers/utils"; |
| 5 |
|
| 6 |
export function clickLoginButton() { |
| 7 |
return [ |
| 8 |
{ |
| 9 |
content: "click login button", |
| 10 |
trigger: ".login-overlay .select-cashier", |
| 11 |
run: "click", |
| 12 |
}, |
| 13 |
]; |
| 14 |
} |
| 15 |
export function clickCashierName() { |
| 16 |
return [ |
| 17 |
{ |
| 18 |
content: "click cashier name", |
| 19 |
trigger: ".cashier-name", |
| 20 |
run: "click", |
| 21 |
}, |
| 22 |
]; |
| 23 |
} |
| 24 |
export function loginScreenIsShown() { |
| 25 |
return [ |
| 26 |
{ |
| 27 |
content: "login screen is shown", |
| 28 |
trigger: ".login-overlay .screen-login", |
| 29 |
}, |
| 30 |
]; |
| 31 |
} |
| 32 |
export function loginScreenIsNotShown() { |
| 33 |
return [ |
| 34 |
{ |
| 35 |
content: "login screen is not shown", |
| 36 |
trigger: negate(".login-overlay .screen-login"), |
| 37 |
}, |
| 38 |
]; |
| 39 |
} |
| 40 |
export function cashierNameIs(name) { |
| 41 |
return [ |
| 42 |
{ |
| 43 |
isActive: ["desktop"], |
| 44 |
content: `logged cashier is '${name}'`, |
| 45 |
trigger: `.pos .oe_status .username:contains("${name}")`, |
| 46 |
}, |
| 47 |
{ |
| 48 |
isActive: ["mobile"], |
| 49 |
content: `logged cashier is '${name}'`, |
| 50 |
trigger: `.pos .oe_status img[alt="${name}"]`, |
| 51 |
}, |
| 52 |
]; |
| 53 |
} |
| 54 |
export function login(name, pin) { |
| 55 |
const res = [...clickLoginButton(), ...SelectionPopup.has(name, { run: "click" })]; |
| 56 |
if (!pin) { |
| 57 |
return res; |
| 58 |
} |
| 59 |
return res.concat(enterPin(pin)); |
| 60 |
} |
| 61 |
export function enterPin(pin) { |
| 62 |
return [...NumberPopup.enterValue(pin), ...NumberPopup.isShown("••••"), Dialog.confirm()]; |
| 63 |
} |
| 64 |
export function clickLockButton() { |
| 65 |
return { |
| 66 |
content: "Click on the menu button", |
| 67 |
trigger: ".pos-rightheader i.fa-unlock", |
| 68 |
run: "click", |
| 69 |
}; |
| 70 |
} |
| 71 |
|
| 72 |
export function refreshPage() { |
| 73 |
return [ |
| 74 |
{ |
| 75 |
trigger: ".pos", |
| 76 |
run: () => { |
| 77 |
window.location.reload(); |
| 78 |
}, |
| 79 |
expectUnloadPage: true, |
| 80 |
}, |
| 81 |
]; |
| 82 |
} |