合并企业版代码(未测试,先提交到测试分支)
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
odoo.define('mrp_workorder.tourHelper', function (require) {
|
||||
'use strict';
|
||||
|
||||
var tour = require('web_tour.tour');
|
||||
|
||||
function fail(errorMessage) {
|
||||
tour._consume_tour(tour.running_tour, errorMessage);
|
||||
}
|
||||
|
||||
function assertIn(item, itemList, info) {
|
||||
if (!itemList.includes(item)) {
|
||||
fail(info + ': "' + item + '" not in "' + itemList + '".');
|
||||
}
|
||||
}
|
||||
function assert(current, expected, info) {
|
||||
if (current !== expected) {
|
||||
fail(info + ': "' + current + '" instead of "' + expected + '".');
|
||||
}
|
||||
}
|
||||
|
||||
function assertRainbow(present = false) {
|
||||
const $summaryStep = $('.o_tablet_summary');
|
||||
const $rainbow = $('.o_reward_rainbow_man');
|
||||
assert(Boolean($summaryStep.length && present ? $rainbow.length : !$rainbow.length), true, 'Rainbow man check');
|
||||
}
|
||||
|
||||
function assertDoneButton(present = false) {
|
||||
const $doneButton = $('button.btn-primary[name=do_finish');
|
||||
assert(Boolean(present ? $doneButton.length : !$doneButton.length), true, 'mark as done check');
|
||||
}
|
||||
|
||||
function assertQtyToProduce(qty_producing, qty_remaining) {
|
||||
let $qty_producing = $('input[id="qty_producing"]');
|
||||
if ($qty_producing.length === 0) {
|
||||
$qty_producing = $('div[name="qty_producing"]');
|
||||
assert(Number($qty_producing[0].textContent), qty_producing, `wrong quantity done`);
|
||||
} else {
|
||||
assert(Number($qty_producing[0].value), qty_producing, `wrong quantity done`);
|
||||
}
|
||||
assert($qty_producing.length, 1, `no qty_producing`);
|
||||
|
||||
const $qty_remaining = $('div[name="qty_remaining"]');
|
||||
assert($qty_remaining.length, 1, `no qty_remaining`);
|
||||
assert(Number($qty_remaining[0].textContent), qty_remaining, `wrong quantity remaining`);
|
||||
}
|
||||
|
||||
function assertComponent(name, style, qty_done, qty_remaining) {
|
||||
assertIn(style, ['readonly', 'editable']);
|
||||
const $label = $('div[name="component_id"] > span');
|
||||
assert($label.length, 1, `no field`);
|
||||
assert($label[0].textContent, name, `wrong component name`);
|
||||
if (style === 'readonly') {
|
||||
const $qty_done = $('div[name="qty_done"]');
|
||||
assert($qty_done.length, 1, `no qty_done`);
|
||||
assert(Number($qty_done[0].textContent), qty_done, `wrong quantity done`);
|
||||
} else {
|
||||
const $qty_done = $('input[id="qty_done"]');
|
||||
assert($qty_done.length, 1, `no qty_done`);
|
||||
assert(Number($qty_done[0].value), qty_done, `wrong quantity done`);
|
||||
}
|
||||
const $qty_remaining = $('div[name="component_remaining_qty"]');
|
||||
assert($qty_remaining.length, 1, `no qty_remaining`);
|
||||
assert(Number($qty_remaining[0].textContent), qty_remaining, `wrong quantity remaining`);
|
||||
}
|
||||
|
||||
function assertCurrentCheck(text) {
|
||||
const $button = $('.o_selected');
|
||||
assert($button.length, 1, `no selected check`);
|
||||
assert($button[0].textContent, text, `wrong check title`);
|
||||
}
|
||||
|
||||
function assertCheckLength(length) {
|
||||
const button = $('.o_tablet_step');
|
||||
assert(button.length, length, `There should be "${length}" steps`);
|
||||
}
|
||||
function assertValidatedCheckLength(length) {
|
||||
const marks = $('.o_tablet_step_ok');
|
||||
assert(marks.length, length, `There should be "${length}" validated steps`);
|
||||
}
|
||||
|
||||
return {
|
||||
assert: assert,
|
||||
assertCurrentCheck: assertCurrentCheck,
|
||||
assertCheckLength: assertCheckLength,
|
||||
assertComponent: assertComponent,
|
||||
assertValidatedCheckLength: assertValidatedCheckLength,
|
||||
assertQtyToProduce: assertQtyToProduce,
|
||||
assertRainbow: assertRainbow,
|
||||
assertDoneButton: assertDoneButton,
|
||||
fail: fail,
|
||||
};
|
||||
|
||||
});
|
||||
292
mrp_workorder/static/tests/tours/tour_test_workorder.js
Normal file
292
mrp_workorder/static/tests/tours/tour_test_workorder.js
Normal file
@@ -0,0 +1,292 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import tour from 'web_tour.tour';
|
||||
import helper from 'mrp_workorder.tourHelper';
|
||||
|
||||
tour.register('test_add_component', {test: true}, [
|
||||
{
|
||||
trigger: '.o_tablet_client_action',
|
||||
run: function () {
|
||||
helper.assertCheckLength(2);
|
||||
helper.assertValidatedCheckLength(0);
|
||||
helper.assertQtyToProduce(1, 1);
|
||||
helper.assertCurrentCheck('Register Consumed Materials "Elon Musk"');
|
||||
helper.assertComponent('Elon Musk', 'readonly', 1, 1);
|
||||
}
|
||||
},
|
||||
{trigger: '.btn[name="button_start"]'},
|
||||
{
|
||||
trigger: '.o_workorder_icon_btn',
|
||||
extra_trigger: '.btn[name="button_pending"]',
|
||||
},
|
||||
{trigger: '.o_tablet_popups'},
|
||||
{trigger: '.btn:contains("Add Component")'},
|
||||
{trigger: '.modal-title:contains("Add Component")'},
|
||||
{
|
||||
trigger: "div.o_field_widget[name='product_id'] input ",
|
||||
position: 'bottom',
|
||||
run: 'text extra',
|
||||
}, {
|
||||
trigger: '.ui-menu-item > a:contains("extra")',
|
||||
in_modal: false,
|
||||
auto: true,
|
||||
}, {
|
||||
trigger: "div.o_field_widget[name='product_qty'] input",
|
||||
in_modal: true,
|
||||
position: 'bottom',
|
||||
run: 'text 3',
|
||||
},
|
||||
{trigger: '.btn-primary[name="add_product"]'},
|
||||
{
|
||||
trigger: '.o_tablet_client_action',
|
||||
run: function () {
|
||||
helper.assertCheckLength(3);
|
||||
helper.assertValidatedCheckLength(0);
|
||||
helper.assertQtyToProduce(1, 1);
|
||||
helper.assertCurrentCheck('Register Consumed Materials "extra"');
|
||||
helper.assertComponent('extra', 'editable', 3, 3);
|
||||
}
|
||||
}, {
|
||||
trigger: "div.o_field_widget[name='lot_id'] input ",
|
||||
position: 'bottom',
|
||||
run: 'text lot1',
|
||||
}, {
|
||||
trigger: '.ui-menu-item > a:contains("lot1")',
|
||||
in_modal: false,
|
||||
auto: true,
|
||||
}, {
|
||||
trigger: '.o_tablet_client_action',
|
||||
run: () => {
|
||||
helper.assertCheckLength(3);
|
||||
helper.assertValidatedCheckLength(0);
|
||||
helper.assertQtyToProduce(1, 1);
|
||||
helper.assertCurrentCheck('Register Consumed Materials "extra"');
|
||||
helper.assertComponent('extra', 'editable', 3, 3);
|
||||
helper.assert($('div.o_field_widget[name="lot_id"] input').val(), 'lot1');
|
||||
}
|
||||
},
|
||||
// go to Elon Musk step (second one since 'extra')
|
||||
{trigger: '.o_tablet_step:nth-child(2)'},
|
||||
{trigger: '.o_selected:contains("Elon")'},
|
||||
{
|
||||
trigger: '.o_tablet_client_action',
|
||||
run: function () {
|
||||
helper.assertCheckLength(3);
|
||||
helper.assertValidatedCheckLength(0);
|
||||
helper.assertQtyToProduce(1, 1);
|
||||
helper.assertCurrentCheck('Register Consumed Materials "Elon Musk"');
|
||||
helper.assertComponent('Elon Musk', 'readonly', 1, 1);
|
||||
}
|
||||
},
|
||||
// go to metal cylinder step
|
||||
{trigger: '.btn[name="action_next"]'},
|
||||
{trigger: 'div[name="component_id"]:contains("Metal")'},
|
||||
{
|
||||
trigger: '.o_tablet_client_action',
|
||||
run: function () {
|
||||
helper.assertComponent('Metal cylinder', 'editable', 2, 2);
|
||||
helper.assertCheckLength(3);
|
||||
helper.assertValidatedCheckLength(1);
|
||||
helper.assertQtyToProduce(1, 1);
|
||||
helper.assertCurrentCheck('Register Consumed Materials "Metal cylinder"');
|
||||
}
|
||||
}, {
|
||||
trigger: 'input[id="qty_done"]',
|
||||
position: 'bottom',
|
||||
run: 'text 1',
|
||||
}, {
|
||||
trigger: 'div.o_field_widget[name="lot_id"] input',
|
||||
position: 'bottom',
|
||||
run: 'text mc1',
|
||||
},
|
||||
{trigger: '.o_workorder_icon_btn'},
|
||||
{trigger: '.o_tablet_popups'},
|
||||
{trigger: '.btn:contains("Add By-product")'},
|
||||
{trigger: '.modal-title:contains("Add By-Product")'},
|
||||
{
|
||||
trigger: "div.o_field_widget[name='product_id'] input ",
|
||||
position: 'bottom',
|
||||
run: 'text extra-bp',
|
||||
}, {
|
||||
trigger: '.ui-menu-item > a:contains("extra-bp")',
|
||||
in_modal: false,
|
||||
auto: true,
|
||||
}, {
|
||||
trigger: "div.o_field_widget[name='product_qty'] input",
|
||||
in_modal: true,
|
||||
position: 'bottom',
|
||||
run: 'text 1',
|
||||
},
|
||||
{trigger: '.btn-primary[name="add_product"]'},
|
||||
{
|
||||
trigger: '.o_tablet_client_action',
|
||||
run: function () {
|
||||
helper.assertCheckLength(4);
|
||||
helper.assertValidatedCheckLength(1);
|
||||
helper.assertQtyToProduce(1, 1);
|
||||
helper.assertCurrentCheck('Register By-products "extra-bp"');
|
||||
helper.assertComponent('extra-bp', 'editable', 1, 1);
|
||||
}
|
||||
}, {
|
||||
trigger: "div.o_field_widget[name='lot_id'] input ",
|
||||
position: 'bottom',
|
||||
run: 'text lot2',
|
||||
}, {
|
||||
trigger: '.ui-menu-item > a:contains("lot2")',
|
||||
in_modal: false,
|
||||
auto: true,
|
||||
},
|
||||
{trigger: '.btn[name=action_next]'},
|
||||
{
|
||||
trigger: 'div[name="component_id"]:contains("Metal")',
|
||||
run: function () {
|
||||
helper.assertCheckLength(4);
|
||||
helper.assertValidatedCheckLength(2);
|
||||
helper.assertQtyToProduce(1, 1);
|
||||
helper.assertCurrentCheck('Register Consumed Materials "Metal cylinder"');
|
||||
helper.assertComponent('Metal cylinder', 'editable', 2, 2);
|
||||
}
|
||||
},
|
||||
{trigger: '.btn[name=action_next]'},
|
||||
// go back to the first not done check
|
||||
{
|
||||
trigger: 'div[name="component_id"]:contains("extra")',
|
||||
run: function () {
|
||||
helper.assertComponent('extra', 'editable', 3, 3);
|
||||
helper.assertCheckLength(4);
|
||||
helper.assertValidatedCheckLength(3);
|
||||
helper.assertQtyToProduce(1, 1);
|
||||
helper.assertCurrentCheck('Register Consumed Materials "extra"');
|
||||
}
|
||||
},
|
||||
{trigger: '.btn[name=action_next]'},
|
||||
// we have the rainbow man once
|
||||
{
|
||||
trigger: '.o_tablet_step:nth-child(5)',
|
||||
run: function () {
|
||||
helper.assertRainbow(true);
|
||||
}
|
||||
},
|
||||
{trigger: '.o_reward_rainbow_man'},
|
||||
{
|
||||
trigger: 'h1:contains("Good Job")',
|
||||
run: function () {
|
||||
helper.assertDoneButton(true);
|
||||
}
|
||||
},
|
||||
// we do not have it twice
|
||||
{trigger: '.o_tablet_step:nth-child(2)'},
|
||||
{
|
||||
trigger: 'div[name="component_id"]:contains("Elon")',
|
||||
run: function () {
|
||||
helper.assertCheckLength(5);
|
||||
helper.assertValidatedCheckLength(4);
|
||||
helper.assertQtyToProduce(1, 1);
|
||||
helper.assertCurrentCheck('Register Consumed Materials "Elon Musk"');
|
||||
helper.assertComponent('Elon Musk', 'readonly', 1, 0);
|
||||
}
|
||||
},
|
||||
{trigger: '.o_tablet_step:nth-child(5)'},
|
||||
{
|
||||
trigger: 'h1:contains("Good Job")',
|
||||
run: function () {
|
||||
helper.assertRainbow(false);
|
||||
helper.assertDoneButton(true);
|
||||
}
|
||||
},
|
||||
{
|
||||
trigger: "input[id='finished_lot_id']",
|
||||
position: 'bottom',
|
||||
run: 'text F0001',
|
||||
},
|
||||
{
|
||||
trigger: '.ui-menu-item > a:contains("F0001")',
|
||||
in_modal: false,
|
||||
auto: true,
|
||||
},
|
||||
{trigger: '.btn[name=do_finish]'},
|
||||
{trigger: '.o_searchview_input'},
|
||||
]);
|
||||
|
||||
tour.register('test_add_step', {test: true}, [
|
||||
{
|
||||
trigger: '.o_tablet_client_action',
|
||||
run: function () {
|
||||
helper.assertCheckLength(1);
|
||||
helper.assertValidatedCheckLength(0);
|
||||
helper.assertQtyToProduce(1, 1);
|
||||
helper.assertCurrentCheck('Register Consumed Materials "Metal cylinder"');
|
||||
helper.assertComponent('Metal cylinder', 'editable', 2, 2);
|
||||
}
|
||||
},
|
||||
{trigger: '.btn[name="button_start"]'},
|
||||
{
|
||||
trigger: '.o_workorder_icon_btn',
|
||||
extra_trigger: '.btn[name="button_pending"]',
|
||||
},
|
||||
{trigger: '.o_tablet_popups'},
|
||||
{trigger: '.btn:contains("Add a Step")'},
|
||||
{trigger: '.modal-title:contains("Add a Step")'},
|
||||
{
|
||||
trigger: "div[name=title] input",
|
||||
position: 'bottom',
|
||||
run: 'text my very new step',
|
||||
}, {
|
||||
trigger: "div[name=note] p",
|
||||
position: 'bottom',
|
||||
run: 'text why am I adding a step',
|
||||
},
|
||||
{trigger: '.btn-primary[name="add_check_in_chain"]'},
|
||||
{
|
||||
trigger: '.o_tablet_client_action',
|
||||
run: function () {
|
||||
helper.assertCheckLength(2);
|
||||
helper.assertValidatedCheckLength(0);
|
||||
helper.assertQtyToProduce(1, 1);
|
||||
helper.assertCurrentCheck('Register Consumed Materials "Metal cylinder"');
|
||||
helper.assertComponent('Metal cylinder', 'editable', 2, 2);
|
||||
}
|
||||
},
|
||||
// go to new step
|
||||
{trigger: '.o_tablet_step:nth-child(2)'},
|
||||
{trigger: 'div:contains("why am I")'},
|
||||
{
|
||||
trigger: '.o_tablet_client_action',
|
||||
run: function () {
|
||||
helper.assertCheckLength(2);
|
||||
helper.assertValidatedCheckLength(0);
|
||||
helper.assertQtyToProduce(1, 1);
|
||||
helper.assertCurrentCheck("my very new step");
|
||||
}
|
||||
},
|
||||
{trigger: 'div[name=note]:contains("why am I adding a step")'},
|
||||
{trigger: '.o_tablet_client_action'},
|
||||
{trigger: '.o_tablet_step:nth-child(1)'},
|
||||
{
|
||||
trigger: 'span:contains("Metal")',
|
||||
run: function () {
|
||||
helper.assertCheckLength(2);
|
||||
helper.assertValidatedCheckLength(0);
|
||||
helper.assertQtyToProduce(1, 1);
|
||||
helper.assertCurrentCheck('Register Consumed Materials "Metal cylinder"');
|
||||
helper.assertComponent('Metal cylinder', 'editable', 2, 2);
|
||||
}
|
||||
},
|
||||
{trigger: 'button[name=openMenuPopup]'},
|
||||
{trigger: '.o_tablet_popups'},
|
||||
{trigger: '.btn:contains("Update Instruction")'},
|
||||
{trigger: '.modal-title:contains("Update Instruction")'},
|
||||
{
|
||||
trigger: 'input#comment',
|
||||
run: 'text my reason',
|
||||
},
|
||||
|
||||
{trigger: '.btn-primary[name="process"]'},
|
||||
{trigger: '.o_tablet_client_action'},
|
||||
{trigger: '.btn[name=action_next]'},
|
||||
{trigger: 'div[name=note]:contains("why am I adding a step")'},
|
||||
{trigger: '.btn[name=action_next]'},
|
||||
{trigger: '.btn[name=action_generate_serial]'},
|
||||
{trigger: '.btn[name=do_finish]'},
|
||||
{trigger: '.o_searchview_input'},
|
||||
]);
|
||||
Reference in New Issue
Block a user