Skip to content

Commit

Permalink
[FIX] hr_expense: replace JS test by tour
Browse files Browse the repository at this point in the history
In /pull/138387, a new feature was added where clicking on an expense line in an expense sheet will highlight the receipts of that line in the attachment viewer if any. A JS test was included for this feature that mocked the fetching of the sheet's attachment. Since this changed in the backend in /pull/142029, the feature no longer worked but the test never broke since it was mocking the backend. This commit adds a tour to prevent that from happening again.

closes #155417

Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com>
  • Loading branch information
alialfie committed May 10, 2024
1 parent 754411b commit e189eac
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 109 deletions.
45 changes: 45 additions & 0 deletions addons/hr_expense/static/src/js/tours/show_expense_receipt_tour.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/** @odoo-module **/

import { registry } from "@web/core/registry";
import { stepUtils } from "@web_tour/tour_service/tour_utils";

registry.category("web_tour.tours").add('show_expense_receipt_tour', {
test: true,
url: '/web',
steps: () => [
...stepUtils.goToAppSteps('hr_expense.menu_hr_expense_root', "Go to the Expenses app"),
{
content: "Go to Expense Reports",
trigger: '.dropdown-item[data-menu-xmlid="hr_expense.menu_hr_expense_report"]',
position:'bottom',
},
{
content: "Go to a report",
trigger: '.o_data_row .o_data_cell[name="payment_state"]',
},
{
content: "Click on an expense line 2",
trigger: '.o_data_row .o_data_cell[data-tooltip="expense_2"]',
},
{
content: "Check attachment",
trigger: ".o_attachment_preview .o-mail-Attachment-imgContainer .img[src*='test_file_2.png']",
},
{
content: "Click on an expense line 3",
trigger: '.o_data_row .o_data_cell[data-tooltip="expense_3"]',
},
{
content: "Check attachment",
trigger: ".o_attachment_preview .o-mail-Attachment-imgContainer .img[src*='test_file_3.png']",
},
{
content: "Click on an expense line 1",
trigger: '.o_data_row .o_data_cell[data-tooltip="expense_1"]',
},
{
content: "Check attachment",
trigger: ".o_attachment_preview .o-mail-Attachment-imgContainer .img[src*='test_file_1.png']",
},
],
});
109 changes: 0 additions & 109 deletions addons/hr_expense/static/tests/views/expense_line_widget.test.js

This file was deleted.

1 change: 1 addition & 0 deletions addons/hr_expense/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
from . import test_expenses_multi_company
from . import test_expenses_tax
from . import test_expenses_standard_price_update_warning
from . import test_ui
62 changes: 62 additions & 0 deletions addons/hr_expense/tests/test_ui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from odoo import Command
from odoo.addons.hr_expense.tests.common import TestExpenseCommon
from odoo.tests import tagged, HttpCase


@tagged('-at_install', 'post_install')
class TestUi(TestExpenseCommon, HttpCase):
browser_size = "1920,1080"

def test_show_expense_receipt_on_expense_line_click(self):
expense_1, expense_2, expense_3 = self.env['hr.expense'].create([
{
'name': 'expense_1',
'employee_id': self.expense_employee.id,
'product_id': self.product_c.id,
'total_amount': 1000,
},
{
'name': 'expense_2',
'employee_id': self.expense_employee.id,
'product_id': self.product_c.id,
'total_amount': 999,
},
{
'name': 'expense_3',
'employee_id': self.expense_employee.id,
'product_id': self.product_c.id,
'total_amount': 998,
},
])
attachment_1, attachment_2, attachment_3 = self.env['ir.attachment'].create([
{
'name': "test_file_1.png",
'raw': b"R0lGODdhAQABAIAAAP///////ywAAAAAAQABAAACAkQBADs=1",
'res_id': expense_1.id,
'res_model': 'hr.expense',
},
{
'name': "test_file_2.png",
'raw': b"R0lGODdhAQABAIAAAP///////ywAAAAAAQABAAACAkQBADs=2",
'res_id': expense_2.id,
'res_model': 'hr.expense',
},
{
'name': "test_file_3.png",
'raw': b"R0lGODdhAQABAIAAAP///////ywAAAAAAQABAAACAkQBADs=3",
'res_id': expense_3.id,
'res_model': 'hr.expense',
},
])

expense_1.message_main_attachment_id = attachment_1
expense_2.message_main_attachment_id = attachment_2
expense_3.message_main_attachment_id = attachment_3

self.env['hr.expense.sheet'].create({
'employee_id': self.expense_employee.id,
'name': 'test sheet',
'expense_line_ids': [Command.set([expense_1.id, expense_2.id, expense_3.id])],
})

self.start_tour('/web', 'show_expense_receipt_tour', login=self.env.user.login)

0 comments on commit e189eac

Please sign in to comment.