| 1 |
function createNewSalesOrder() { |
| 2 |
return [ |
| 3 |
{ |
| 4 |
trigger: '.o_sale_order', |
| 5 |
}, { |
| 6 |
content: "Create new order", |
| 7 |
trigger: '.o_list_button_add', |
| 8 |
run: 'click', |
| 9 |
}, |
| 10 |
] |
| 11 |
} |
| 12 |
|
| 13 |
function selectCustomer(customerName) { |
| 14 |
return [ |
| 15 |
{ |
| 16 |
content: `Select customer ${customerName}`, |
| 17 |
trigger: '.o_field_widget[name=partner_id] input', |
| 18 |
run: `edit ${customerName}`, |
| 19 |
}, |
| 20 |
{ |
| 21 |
trigger: `ul.ui-autocomplete > li > a:contains("${customerName}")`, |
| 22 |
run: 'click', |
| 23 |
}, |
| 24 |
]; |
| 25 |
} |
| 26 |
|
| 27 |
function addProduct(productName, rowNumber=1) { |
| 28 |
return [ |
| 29 |
{ |
| 30 |
content: `Add product ${productName}`, |
| 31 |
trigger: 'a:contains("Add a product")', |
| 32 |
run: 'click', |
| 33 |
}, |
| 34 |
{ |
| 35 |
content: 'wait for new row to be created', |
| 36 |
trigger: `.o_data_row:nth-child(${rowNumber})`, |
| 37 |
}, |
| 38 |
{ |
| 39 |
trigger: 'div[name="product_template_id"] input', // TODO VFE o_selected_row |
| 40 |
run: `edit ${productName}`, |
| 41 |
}, |
| 42 |
{ |
| 43 |
trigger: `ul.ui-autocomplete a:contains("${productName}")`, |
| 44 |
run: 'click', |
| 45 |
}, |
| 46 |
]; |
| 47 |
} |
| 48 |
|
| 49 |
function clickSomewhereElse() { |
| 50 |
return [ |
| 51 |
// TODO find a way for onchange to finish first ? |
| 52 |
{ |
| 53 |
content: 'click somewhere else to exit cell focus', |
| 54 |
trigger: 'a[name=order_lines]', // click on notebook tab to stop the sol edit mode. |
| 55 |
run: 'click', |
| 56 |
}, |
| 57 |
{ |
| 58 |
content: 'check that the soline is not focused anymore', |
| 59 |
trigger: 'table.o_section_and_note_list_view:not(:has(.o_selected_row))', |
| 60 |
} |
| 61 |
] |
| 62 |
} |
| 63 |
|
| 64 |
function checkSOLDescriptionContains(productName, text) { |
| 65 |
// TODO in the future: look directly into the textarea value |
| 66 |
let trigger = '.o_field_product_label_section_and_note_cell'; |
| 67 |
if (productName) { |
| 68 |
trigger = `${trigger}:has(:contains("${productName}"), input:value("${productName}"))`; |
| 69 |
} |
| 70 |
if (text) { |
| 71 |
trigger = `${trigger} .o_input`; |
| 72 |
} |
| 73 |
return { trigger }; |
| 74 |
} |
| 75 |
|
| 76 |
function editLineMatching(productName, text) { |
| 77 |
let base_step = checkSOLDescriptionContains(productName, text); |
| 78 |
base_step['run'] = 'click'; |
| 79 |
return base_step; |
| 80 |
} |
| 81 |
|
| 82 |
function editConfiguration() { |
| 83 |
return { |
| 84 |
trigger: '[name=product_template_id] button.fa-pencil', |
| 85 |
run: 'click', |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
export default { |
| 90 |
createNewSalesOrder, |
| 91 |
selectCustomer, |
| 92 |
addProduct, |
| 93 |
checkSOLDescriptionContains, |
| 94 |
editLineMatching, |
| 95 |
editConfiguration, |
| 96 |
clickSomewhereElse, |
| 97 |
}; |