bemade_fsm: test refactoring complete (all passing).
This commit is contained in:
parent
3771c36899
commit
2b85408e8d
8 changed files with 68 additions and 53 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import tour from 'web_tour.tour';
|
import tour from 'web_tour.tour';
|
||||||
|
|
||||||
const TEST_COMPANY = "Test Partner Company";
|
const TEST_COMPANY = "Test Partner";
|
||||||
const TEST_EQPT1 = "Test Equipment 1";
|
const TEST_EQPT1 = "Test Equipment 1";
|
||||||
const TEST_EQPT2 = "Test Equipment 2";
|
const TEST_EQPT2 = "Test Equipment 2";
|
||||||
tour.register('equipment_base_tour', {
|
tour.register('equipment_base_tour', {
|
||||||
|
|
@ -21,7 +21,6 @@ tour.register('equipment_base_tour', {
|
||||||
}, {
|
}, {
|
||||||
content: 'Click the create button',
|
content: 'Click the create button',
|
||||||
trigger: '.o_list_button_add',
|
trigger: '.o_list_button_add',
|
||||||
extra_trigger: 'li.breadcrumb-item.active:has(span:contains(Equipment))',
|
|
||||||
}, {
|
}, {
|
||||||
content: 'Add a tag',
|
content: 'Add a tag',
|
||||||
trigger: 'input[name="pid_tag"]',
|
trigger: 'input[name="pid_tag"]',
|
||||||
|
|
@ -33,13 +32,13 @@ tour.register('equipment_base_tour', {
|
||||||
}, {
|
}, {
|
||||||
content: 'Set the partner',
|
content: 'Set the partner',
|
||||||
trigger: 'div[name="partner_location_id"] div div input',
|
trigger: 'div[name="partner_location_id"] div div input',
|
||||||
run: 'text Test Partner Company',
|
run: `text ${TEST_COMPANY}`,
|
||||||
}, {
|
}, {
|
||||||
content: 'Click the partner in the dropdown',
|
content: 'Click the partner in the dropdown',
|
||||||
trigger: `li a.dropdown-item:contains(${TEST_COMPANY})`,
|
trigger: `li a.dropdown-item:contains(${TEST_COMPANY})`,
|
||||||
}, {
|
}, {
|
||||||
content: 'Save equipment',
|
content: 'Save equipment',
|
||||||
trigger: 'button.o_form_button_save',
|
trigger: 'button.o_list_button_save',
|
||||||
}, {
|
}, {
|
||||||
/* Navigate to the client and make sure that there are two equipments saved (one from the Python test case) */
|
/* Navigate to the client and make sure that there are two equipments saved (one from the Python test case) */
|
||||||
content: 'Navigate to the Clients submenu',
|
content: 'Navigate to the Clients submenu',
|
||||||
|
|
@ -65,7 +64,6 @@ tour.register('equipment_base_tour', {
|
||||||
extra_trigger: `h1 span.o_field_partner_autocomplete[name="name"]:contains(${TEST_COMPANY})`,
|
extra_trigger: `h1 span.o_field_partner_autocomplete[name="name"]:contains(${TEST_COMPANY})`,
|
||||||
}, {
|
}, {
|
||||||
content: 'Make sure we have a first test equipment',
|
content: 'Make sure we have a first test equipment',
|
||||||
/*trigger: `div[name="equipment_ids"]:has(td:contains(${TEST_EQPT1}))`,*/
|
|
||||||
trigger: `td:contains(${TEST_EQPT1})`,
|
trigger: `td:contains(${TEST_EQPT1})`,
|
||||||
run: function () {
|
run: function () {
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,10 @@ tour.register('sale_order_tour', {
|
||||||
}, {
|
}, {
|
||||||
content: 'Click the view tasks button',
|
content: 'Click the view tasks button',
|
||||||
trigger: 'button[name="action_view_task"]',
|
trigger: 'button[name="action_view_task"]',
|
||||||
}, {
|
}, /*{
|
||||||
content: 'Click the first task',
|
content: 'Click the first task',
|
||||||
trigger: `div.o_kanban_record:has(span:contains(${PRODUCT_NAME}))`,
|
trigger: `div.o_kanban_record:has(span:contains(${PRODUCT_NAME}))`,
|
||||||
}, {
|
},*/ {
|
||||||
content: 'Click on the ready to invoice button',
|
content: 'Click on the ready to invoice button',
|
||||||
trigger: 'button[name="action_fsm_validate"]',
|
trigger: 'button[name="action_fsm_validate"]',
|
||||||
extra_trigger: `li.breadcrumb-item.active:has(span:contains(${PRODUCT_NAME}))`
|
extra_trigger: `li.breadcrumb-item.active:has(span:contains(${PRODUCT_NAME}))`
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ tour.register('task_equipment_tour', {
|
||||||
trigger: `li a.dropdown-item:contains(${TEST_COMPANY})`,
|
trigger: `li a.dropdown-item:contains(${TEST_COMPANY})`,
|
||||||
}, {
|
}, {
|
||||||
content: 'Save equipment',
|
content: 'Save equipment',
|
||||||
trigger: 'button.o_form_button_save',
|
trigger: 'button.o_list_button_save',
|
||||||
}, {
|
}, {
|
||||||
/* Navigate to the client and make sure that there are two equipments saved (one from the Python test case) */
|
/* Navigate to the client and make sure that there are two equipments saved (one from the Python test case) */
|
||||||
content: 'Navigate to the Clients submenu',
|
content: 'Navigate to the Clients submenu',
|
||||||
|
|
|
||||||
|
|
@ -7,24 +7,21 @@ class BemadeFSMBaseTest(TransactionCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _generate_project_manager_user(cls, name, login):
|
def _generate_project_manager_user(cls, name, login):
|
||||||
user_group_employee = cls.env.ref('base.group_user')
|
group_ids = cls.__get_user_groups()
|
||||||
user_group_project_user = cls.env.ref('project.group_project_user')
|
|
||||||
user_group_project_manager = cls.env.ref('project.group_project_manager')
|
user_group_project_manager = cls.env.ref('project.group_project_manager')
|
||||||
user_group_fsm_user = cls.env.ref('industry_fsm.group_fsm_user')
|
|
||||||
user_group_fsm_manager = cls.env.ref('industry_fsm.group_fsm_manager')
|
user_group_fsm_manager = cls.env.ref('industry_fsm.group_fsm_manager')
|
||||||
user_group_sales_manager = cls.env.ref('sales_team.group_sale_manager')
|
group_ids.append(user_group_fsm_manager.id)
|
||||||
user_group_sales_user = cls.env.ref('sales_team.group_sale_salesman')
|
group_ids.append(user_group_project_manager.id)
|
||||||
user_product_customer = cls.env.ref('customer_product_code.group_product_customer_code_user')
|
|
||||||
|
|
||||||
group_ids = [user_group_employee.id,
|
return cls.__generate_user(name, login, group_ids)
|
||||||
user_group_project_user.id,
|
|
||||||
user_group_project_manager.id,
|
@classmethod
|
||||||
user_group_fsm_user.id,
|
def _generate_project_user(cls, name, login):
|
||||||
user_group_fsm_manager.id,
|
group_ids = cls.__get_user_groups()
|
||||||
user_group_sales_user.id,
|
return cls.__generate_user(name, login, group_ids)
|
||||||
user_group_sales_manager.id, ]
|
|
||||||
if user_product_customer:
|
@classmethod
|
||||||
group_ids.append(user_product_customer.id)
|
def __generate_user(cls, name, login, group_ids):
|
||||||
return cls.env['res.users'].with_context({'no_reset_password': True}).create({
|
return cls.env['res.users'].with_context({'no_reset_password': True}).create({
|
||||||
'name': name,
|
'name': name,
|
||||||
'login': login,
|
'login': login,
|
||||||
|
|
@ -34,10 +31,22 @@ class BemadeFSMBaseTest(TransactionCase):
|
||||||
})
|
})
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _generate_project_user(cls, name, login):
|
def __get_user_groups(cls):
|
||||||
user = cls._generate_project_manager_user(name, login)
|
user_group_employee = cls.env.ref('base.group_user')
|
||||||
user.write({'groups_id': [Command.unlink(cls.env.ref('project.group_project_manager'))]})
|
user_group_project_user = cls.env.ref('project.group_project_user')
|
||||||
user.write({'groups_id': [Command.unlink(cls.env.ref('industry_fsm.group_fsm_manager'))]})
|
user_group_fsm_user = cls.env.ref('industry_fsm.group_fsm_user')
|
||||||
|
user_group_sales_user = cls.env.ref('sales_team.group_sale_salesman')
|
||||||
|
user_group_sales_manager = cls.env.ref('sales_team.group_sale_manager')
|
||||||
|
user_product_customer = cls.env.ref('customer_product_code.group_product_customer_code_user')
|
||||||
|
|
||||||
|
group_ids = [user_group_employee.id,
|
||||||
|
user_group_project_user.id,
|
||||||
|
user_group_fsm_user.id,
|
||||||
|
user_group_sales_manager.id,
|
||||||
|
user_group_sales_user.id, ]
|
||||||
|
if user_product_customer:
|
||||||
|
group_ids.append(user_product_customer.id)
|
||||||
|
return group_ids
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _generate_partner(cls, name: str = 'Test Company', company_type: str = 'company', parent=None,
|
def _generate_partner(cls, name: str = 'Test Company', company_type: str = 'company', parent=None,
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,11 @@ class TestEquipmentTours(HttpCase, BemadeFSMBaseTest):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
cls._generate_partner()
|
super().setUpClass()
|
||||||
cls._generate_partner('Site Contact', 'person', cls.partner_company)
|
partner = cls._generate_partner("Test Partner")
|
||||||
cls._generate_equipment('Test Equipment 1', cls.partner_company)
|
cls._generate_partner('Site Contact', 'person', parent=partner)
|
||||||
cls.user = cls._generate_project_manager_user()
|
cls._generate_equipment(name='Test Equipment 1', partner=partner)
|
||||||
|
cls.user = cls._generate_project_manager_user("Mister PM", 'misterpm')
|
||||||
|
|
||||||
def test_equipment_base_tour(self):
|
def test_equipment_base_tour(self):
|
||||||
self.start_tour('/web', 'equipment_base_tour',
|
self.start_tour('/web', 'equipment_base_tour',
|
||||||
|
|
|
||||||
|
|
@ -89,26 +89,6 @@ class TestSalesOrder(TestTaskTemplateCommon):
|
||||||
parent_task.action_fsm_validate()
|
parent_task.action_fsm_validate()
|
||||||
self.assertTrue(sol.qty_delivered != 0)
|
self.assertTrue(sol.qty_delivered != 0)
|
||||||
|
|
||||||
|
|
||||||
@tagged("-at_install", "post_install", "slow")
|
|
||||||
class TestSaleOrderTour(HttpCase, TestSalesOrder):
|
|
||||||
def test_sale_order_tour_no_invoice_button_for_non_manager(self):
|
|
||||||
# Make sure a non-manager cannot mark a task as ready to invoice
|
|
||||||
so = self.sale_order2
|
|
||||||
so.action_confirm()
|
|
||||||
with self.assertRaises(AssertionError) as e:
|
|
||||||
self.start_tour('/web', 'sale_order_tour',
|
|
||||||
login='mruser', )
|
|
||||||
self.assertTrue("Click on the ready to invoice button" in str(e.exception))
|
|
||||||
|
|
||||||
def test_task_mark_to_invoice(self):
|
|
||||||
# Make sure that when a manager clicks the ready to invoice button, the qty delivered is updated on the SO
|
|
||||||
so = self.sale_order2
|
|
||||||
so.action_confirm()
|
|
||||||
sol = so.order_line.filtered(lambda l: 'Test Product 3' in l.name)
|
|
||||||
self.start_tour('/web', 'sale_order_tour', login='misterpm')
|
|
||||||
self.assertTrue(sol.qty_delivered != 0)
|
|
||||||
|
|
||||||
def test_task_contacts_through_sale_order(self):
|
def test_task_contacts_through_sale_order(self):
|
||||||
""" Make sure the site contacts and work order contacts transfer correctly from the SO to the task."""
|
""" Make sure the site contacts and work order contacts transfer correctly from the SO to the task."""
|
||||||
|
|
||||||
|
|
@ -121,7 +101,7 @@ class TestSaleOrderTour(HttpCase, TestSalesOrder):
|
||||||
})
|
})
|
||||||
so = self._generate_sale_order(partner)
|
so = self._generate_sale_order(partner)
|
||||||
product = self._generate_product()
|
product = self._generate_product()
|
||||||
sol = self._generate_sale_order_line(product=product)
|
sol = self._generate_sale_order_line(sale_order=so, product=product)
|
||||||
|
|
||||||
so.action_confirm()
|
so.action_confirm()
|
||||||
|
|
||||||
|
|
@ -156,3 +136,26 @@ class TestSaleOrderTour(HttpCase, TestSalesOrder):
|
||||||
|
|
||||||
self.assertEqual(task.site_contacts, so.site_contacts)
|
self.assertEqual(task.site_contacts, so.site_contacts)
|
||||||
self.assertEqual(task.work_order_contacts, so.work_order_contacts)
|
self.assertEqual(task.work_order_contacts, so.work_order_contacts)
|
||||||
|
|
||||||
|
|
||||||
|
@tagged("-at_install", "post_install", "slow")
|
||||||
|
class TestSaleOrderTour(HttpCase, TestSalesOrder):
|
||||||
|
def test_sale_order_tour_no_invoice_button_for_non_manager(self):
|
||||||
|
so = self._generate_sale_order(client_order_ref='TEST ORDER 2')
|
||||||
|
self._generate_sale_order_line(so, self._generate_product(name='Test Product 3'))
|
||||||
|
self._generate_project_user('Mr. User', 'mruser')
|
||||||
|
so.action_confirm()
|
||||||
|
# Make sure a non-manager cannot mark a task as ready to invoice
|
||||||
|
with self.assertRaises(AssertionError) as e:
|
||||||
|
self.start_tour('/web', 'sale_order_tour',
|
||||||
|
login='mruser', )
|
||||||
|
self.assertTrue("Click on the ready to invoice button" in str(e.exception))
|
||||||
|
|
||||||
|
def test_task_mark_to_invoice(self):
|
||||||
|
# Make sure that when a manager clicks the ready to invoice button, the qty delivered is updated on the SO
|
||||||
|
so = self._generate_sale_order(client_order_ref='TEST ORDER 2')
|
||||||
|
sol = self._generate_sale_order_line(so, self._generate_product(name='Test Product 3'))
|
||||||
|
so.action_confirm()
|
||||||
|
user = self._generate_project_manager_user('Mr. User', 'mruser')
|
||||||
|
self.start_tour('/web', 'sale_order_tour', login=user.login)
|
||||||
|
self.assertTrue(sol.qty_delivered != 0)
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,10 @@ class TestTaskTemplate(TestTaskTemplateCommon):
|
||||||
|
|
||||||
@tagged('-at_install', 'post_install', 'slow')
|
@tagged('-at_install', 'post_install', 'slow')
|
||||||
class TestTaskTemplateTour(HttpCase, TestTaskTemplateCommon):
|
class TestTaskTemplateTour(HttpCase, TestTaskTemplateCommon):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super().setUpClass()
|
||||||
|
cls._generate_project_manager_user('Mister PM', 'misterpm')
|
||||||
|
|
||||||
def test_task_template_tour(self):
|
def test_task_template_tour(self):
|
||||||
self.start_tour('/web', 'task_template_tour',
|
self.start_tour('/web', 'task_template_tour',
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="description"/>
|
<field name="description"/>
|
||||||
<field name="tag_ids" widget="many2many_tags" options="{'no_open': False}"/>
|
<field name="tag_ids" widget="many2many_tags" options="{'no_open': False}"/>
|
||||||
<field name="partner_id"/>
|
<field name="partner_location_id"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue