Files
odoo_source/addons/knowledge/tests/test_knowledge_form_ui.py
T
Julien Banken 083e35f570 [FIX] knowledge: make custom emoji picker compatible with new standard templates
The template of the standard emoji picker has recently been updated. This
commit will update the emoji picker of Knowledge to make the custom
component compatible with the new standard templates.

Related: https://github.com/odoo/odoo/commit/9830406020ef1c3b0c57045a6e285a31ebf81143
task-2871883

closes odoo/odoo#93243

X-original-commit: 7f35a0bf19bfe02200244847b09ae43f4bc02494
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-06-13 08:34:55 +02:00

75 lines
3.6 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields
from odoo.tests.common import tagged, HttpCase
@tagged('post_install', '-at_install', 'knowledge', 'knowledge_tour')
class TestKnowledgeUI(HttpCase):
@classmethod
def setUpClass(cls):
super(TestKnowledgeUI, cls).setUpClass()
# remove existing articles to ease tour management
cls.env['knowledge.article'].search([]).unlink()
def test_knowledge_main_flow(self):
# as the knowledge.article#_resequence method is based on write date
# force the write_date to be correctly computed
# otherwise it always returns the same value as we are in a single transaction
self.patch(self.env.cr, 'now', fields.Datetime.now)
self.start_tour('/web', 'knowledge_main_flow_tour', login='admin', step_delay=100)
# check our articles were correctly created
# with appropriate default values (section / internal_permission)
private_article = self.env['knowledge.article'].search([('name', '=', 'My Private Article')])
self.assertTrue(bool(private_article))
self.assertEqual(private_article.category, 'private')
self.assertEqual(private_article.internal_permission, 'none')
workspace_article = self.env['knowledge.article'].search([('name', '=', 'My Workspace Article')])
self.assertTrue(bool(workspace_article))
self.assertEqual(workspace_article.category, 'workspace')
self.assertEqual(workspace_article.internal_permission, 'write')
children_workspace_articles = workspace_article.child_ids.sorted('sequence')
self.assertEqual(len(children_workspace_articles), 2)
child_article_1 = children_workspace_articles.filtered(
lambda article: article.name == 'Child Article 1')
child_article_2 = children_workspace_articles.filtered(
lambda article: article.name == 'Child Article 2')
# as we re-ordered children, article 2 should come first
self.assertEqual(children_workspace_articles[0], child_article_2)
self.assertEqual(children_workspace_articles[1], child_article_1)
# workspace article should have one partner invited on it
invited_member = workspace_article.article_member_ids
self.assertEqual(len(invited_member), 1)
invited_partner = invited_member.partner_id
self.assertEqual(len(invited_partner), 1)
self.assertEqual(invited_partner.name, 'micheline@knowledge.com')
self.assertEqual(invited_partner.email, 'micheline@knowledge.com')
# check that the partner received an invitation link
invitation_message = self.env['mail.message'].search([
('partner_ids', 'in', invited_partner.id)
])
self.assertEqual(len(invitation_message), 1)
self.assertIn(
workspace_article._get_invite_url(invited_partner),
invitation_message.body
)
# as we re-ordered our favorites, private article should come first
article_favorites = self.env['knowledge.article.favorite'].search([])
self.assertEqual(len(article_favorites), 2)
self.assertEqual(article_favorites[0].article_id, private_article)
self.assertEqual(article_favorites[1].article_id, workspace_article)
def test_knowledge_pick_emoji(self):
"""This tour will check that the emojis of the form view are properly updated
when the user picks an emoji from an emoji picker."""
self.start_tour('/web', 'knowledge_pick_emoji_tour', login='admin', step_delay=100)