[FIX] project: write tests for project tags filter

Created custom filters using tag_ids for the tour to click on
using the add custom filter in the filter dropdown was buggy when used in the tour
the o_filter_condition div didnt update when changing the custom filter

Task-3511261

closes odoo/odoo#138930

X-original-commit: cf44186bdd082bb822eb1801534f8bf4b5a904e2
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
Bastien (bvdn)
2023-10-18 07:51:42 +00:00
parent 7ac121b54d
commit 7bd5bc9969
3 changed files with 107 additions and 0 deletions
@@ -0,0 +1,48 @@
/** @odoo-module **/
import { registry } from "@web/core/registry";
import { stepUtils } from "@web_tour/tour_service/tour_utils";
function changeFilter(filterName) {
return [
{
trigger: '.o_control_panel_actions .o_searchview_dropdown_toggler',
content: 'open searchview menu',
},
{
trigger: `.o_favorite_menu .dropdown-item span:contains("${filterName}")`,
},
{
trigger: '.o_control_panel_actions .o_searchview_dropdown_toggler',
content: 'close searchview menu',
},
];
}
registry.category("web_tour.tours").add('project_tags_filter_tour',
{
test: true,
url: '/web',
steps: () => [stepUtils.showAppsMenuItem(),{
trigger: '.o_app[data-menu-xmlid="project.menu_main_pm"]',
},
...changeFilter("Corkscrew tail tag filter"),
{
trigger: '.o_kanban_group:has(.o_kanban_header:has(span:contains("pig"))) .o_kanban_record:has(span:contains("Pigs"))',
extra_trigger: '.o_kanban_group:has(.o_kanban_header:has(span:contains("goat"))):not(:has(.o_kanban_record))',
content: 'check that the corkscrew tail filter has taken effect',
run: () => {},
}, ...changeFilter("horned tag filter"),
{
trigger: '.o_kanban_group:has(.o_kanban_header:has(span:contains("goat"))) .o_kanban_record:has(span:contains("Goats"))',
extra_trigger: '.o_kanban_group:has(.o_kanban_header:has(span:contains("pig"))):not(:has(.o_kanban_record))',
content: 'check that the horned filter has taken effect',
run: () => {},
}, ...changeFilter("4 Legged tag filter"),
{
trigger: '.o_kanban_group:has(.o_kanban_header:has(span:contains("goat"))) .o_kanban_record:has(span:contains("Goats"))',
extra_trigger: '.o_kanban_group:has(.o_kanban_header:has(span:contains("pig"))) .o_kanban_record:has(span:contains("Pigs"))',
content: 'check that the 4 legged filter has taken effect',
run: () => {},
},
]});
+1
View File
@@ -13,6 +13,7 @@ from . import test_project_sharing_portal_access
from . import test_project_sharing_ui
from . import test_project_stage_multicompany
from . import test_project_subtasks
from . import test_project_tags_filter
from . import test_project_task_type
from . import test_project_ui
from . import test_project_update_access_rights
@@ -0,0 +1,58 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests import tagged, HttpCase
from odoo import Command
from .test_project_base import TestProjectCommon
@tagged('-at_install', 'post_install')
class TestProjectTags(HttpCase, TestProjectCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env['project.tags'].create([
{'name': 'Corkscrew tailed', 'project_ids': [Command.link(cls.project_pigs.id)]},
{'name': 'Horned', 'project_ids': [Command.link(cls.project_goats.id)]},
{
'name': '4 Legged',
'project_ids': [
Command.link(cls.project_goats.id),
Command.link(cls.project_pigs.id),
],
},
])
cls.project_pigs.write({
'stage_id': cls.env['project.project.stage'].create({
'name': 'pig stage',
}).id,
})
cls.project_goats.write({
'stage_id': cls.env['project.project.stage'].create({
'name': 'goat stage',
}).id,
})
cls.env["res.config.settings"].create({'group_project_stages': True}).execute()
cls.env['ir.filters'].create([
{
'name': 'Corkscrew tail tag filter',
'model_id': 'project.project',
'domain': '[("tag_ids", "ilike", "Corkscrew")]',
},
{
'name': 'horned tag filter',
'model_id': 'project.project',
'domain': '[("tag_ids", "ilike", "horned")]',
},
{
'name': '4 Legged tag filter',
'model_id': 'project.project',
'domain': '[("tag_ids", "ilike", "4 Legged")]',
},
])
def test_01_project_tags(self):
self.start_tour("/web", 'project_tags_filter_tour', login="admin")