Skip to content

Commit a70456b

Browse files
committed
[FIX] website_sale_dynamic_review_snippet: Tests are added
1 parent f0877c1 commit a70456b

File tree

7 files changed

+71
-11
lines changed

7 files changed

+71
-11
lines changed

website_sale_dynamic_review_snippet/__manifest__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@
2424
"web.assets_frontend": [
2525
"website_sale_dynamic_review_snippet/static/src/boot/boot_service.esm.js",
2626
],
27+
"web.assets_tests": [
28+
"website_sale_dynamic_review_snippet/static/src/tests/*.esm.js"
29+
],
2730
},
2831
}

website_sale_dynamic_review_snippet/controllers/main.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,23 @@ def mail_review_messages(self, before=None, after=None, limit=30):
1818
("message_type", "=", "comment"),
1919
("rating_ids", "not in", []),
2020
]
21-
res = (
21+
result = (
2222
request.env["mail.message"]
2323
.sudo()
2424
._message_fetch(domain, None, before, after, None, limit)
2525
)
26-
messages = res.pop("messages")
27-
messages_result = messages.portal_message_format(
26+
messages = result.pop("messages")
27+
messages_vals_list = messages.portal_message_format(
2828
options={"rating_include": True}
2929
)
30-
for vals in messages_result:
31-
if not vals.get("model"):
32-
continue
30+
for vals in messages_vals_list:
3331
record = request.env[vals["model"]].sudo().browse(vals["res_id"])
3432
vals["thread"]["name"] = record.name
3533
vals["website_url"] = record.website_url
3634
return {
37-
**res,
35+
**result,
3836
"data": {
39-
"mail.message": messages_result,
37+
"mail.message": messages_vals_list,
4038
},
4139
"messages": Store.many_ids(messages),
4240
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {
2+
clickOnSave,
3+
insertSnippet,
4+
registerWebsitePreviewTour,
5+
} from "@website/js/tours/tour_utils";
6+
7+
registerWebsitePreviewTour(
8+
"dynamic_review",
9+
{
10+
url: "/",
11+
edition: true,
12+
},
13+
() => [
14+
...insertSnippet({id: "s_dynamic_review_snippet", groupName: "Products"}),
15+
...clickOnSave(),
16+
]
17+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_website_sale_dynamic_review
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from odoo.tests import HttpCase, tagged
2+
3+
from odoo.addons.mail.tests.common import mail_new_test_user
4+
5+
6+
@tagged("post_install", "-at_install")
7+
class TestUi(HttpCase):
8+
@classmethod
9+
def setUpClass(cls):
10+
super().setUpClass()
11+
cls.user_admin = cls.env.ref("base.user_admin")
12+
cls.company_admin = cls.user_admin.company_id
13+
cls.user_portal = mail_new_test_user(
14+
cls.env,
15+
login="portal_test",
16+
groups="base.group_portal",
17+
company_id=cls.company_admin.id,
18+
name="Chell Gladys",
19+
notification_type="email",
20+
)
21+
cls.partner_portal = cls.user_portal.partner_id
22+
23+
def test_admin_tour(self):
24+
product = self.env["product.template"].create(
25+
{
26+
"name": "Test Product",
27+
"is_published": True,
28+
}
29+
)
30+
product.with_user(self.user_portal).message_post(
31+
body="Not bad",
32+
message_type="comment",
33+
rating_value=3,
34+
subtype_xmlid="mail.mt_comment",
35+
)
36+
self.start_tour(
37+
self.env["website"].get_client_action_url("/"),
38+
"dynamic_review",
39+
login="admin",
40+
step_delay=2000,
41+
)

website_sale_dynamic_review_snippet/views/snippets/options.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
>
88
<t t-snippet="website_sale.s_dynamic_snippet_products" position="after">
99
<t
10-
t-snippet="website_sale_dynamic_review_snippet.s_customer_review_snippet"
10+
t-snippet="website_sale_dynamic_review_snippet.s_dynamic_review_snippet"
1111
group="products"
1212
string="Product Reviews Snippet"
1313
/>

website_sale_dynamic_review_snippet/views/snippets/s_dynamic_review.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<odoo>
3-
<template id="s_customer_review_snippet" name="Product Reviews Snippet">
3+
<template id="s_dynamic_review_snippet" name="Product Reviews Snippet">
44
<section
55
class="s_customer_review o_dynamic_empty container pt32 pb32"
6-
data-snippet="s_customer_review_snippet"
6+
data-snippet="s_dynamic_review_snippet"
77
>
88
<div class="o_not_editable">
99
<h3 class="mb32">Customer Reviews</h3>

0 commit comments

Comments
 (0)