| 1 |
import { negate } from "@point_of_sale/../tests/generic_helpers/utils"; |
| 2 |
|
| 3 |
export function confirm(confirmationText, button = ".btn-primary") { |
| 4 |
let trigger = `.modal:not(.o_inactive_modal) .modal-footer ${button}`; |
| 5 |
if (confirmationText) { |
| 6 |
trigger += `:contains("${confirmationText}")`; |
| 7 |
} |
| 8 |
return { |
| 9 |
content: "confirm dialog", |
| 10 |
trigger, |
| 11 |
run: "click", |
| 12 |
}; |
| 13 |
} |
| 14 |
export function cancel({ title } = {}) { |
| 15 |
return { |
| 16 |
content: "cancel dialog", |
| 17 |
trigger: `.modal .modal-header${ |
| 18 |
title ? `:contains(${title})` : "" |
| 19 |
} button[aria-label="Close"]`, |
| 20 |
run: "click", |
| 21 |
}; |
| 22 |
} |
| 23 |
export function discard() { |
| 24 |
return { |
| 25 |
content: "discard dialog", |
| 26 |
trigger: `.modal .modal-footer button:contains("Discard")`, |
| 27 |
run: "click", |
| 28 |
}; |
| 29 |
} |
| 30 |
export function is({ title } = {}) { |
| 31 |
let trigger = ".modal .modal-content"; |
| 32 |
if (title) { |
| 33 |
trigger += ` .modal-header:contains("${title}")`; |
| 34 |
} |
| 35 |
return { |
| 36 |
content: "dialog is open", |
| 37 |
trigger, |
| 38 |
}; |
| 39 |
} |
| 40 |
export function isNot(...args) { |
| 41 |
const { trigger } = is(...args); |
| 42 |
return { |
| 43 |
content: "no dialog is open", |
| 44 |
trigger: negate(trigger), |
| 45 |
}; |
| 46 |
} |
| 47 |
|
| 48 |
export function bodyIs(body) { |
| 49 |
return { |
| 50 |
content: "dialog is open", |
| 51 |
trigger: `.modal-body:contains(${body})`, |
| 52 |
}; |
| 53 |
} |
| 54 |
|
| 55 |
export function footerBtnIsDisabled(buttonText) { |
| 56 |
return { |
| 57 |
content: `footer btn ${buttonText} should be disabled`, |
| 58 |
trigger: `.modal .modal-footer button:contains(${buttonText})[disabled]`, |
| 59 |
}; |
| 60 |
} |