Skip to content

Commit

Permalink
[IMP] resource_booking: Partial change from tour test to js
Browse files Browse the repository at this point in the history
  • Loading branch information
victoralmau authored and norlinhenrik committed Aug 28, 2023
1 parent 2c1bc3d commit 01f2144
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 18 deletions.
1 change: 1 addition & 0 deletions resource_booking/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
],
"assets": {
"web.assets_frontend": ["resource_booking/static/src/scss/portal.scss"],
"web.assets_tests": ["resource_booking/static/src/js/resource_booking_tour.js"],
},
"demo": ["demo/res_users_demo.xml"],
}
44 changes: 44 additions & 0 deletions resource_booking/static/src/js/resource_booking_tour.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
odoo.define("resource_booking.tour", function (require) {
"use strict";

var tour = require("web_tour.tour");

tour.register(
"resource_booking_ptl_tour",
{
test: true,
url: "/my",
},
[
{
content: "Go /my/bookings url",
trigger: 'a[href*="/my/bookings"]',
},
{
content: "There are currently no bookings for your account.",
trigger: "p",
},
]
);
tour.register(
"resource_booking_ptl2_tour",
{
test: true,
url: "/my",
},
[
{
content: "Go /my/bookings url",
trigger: 'a[href*="/my/bookings"]',
},
{
content: "Go to Booking item",
trigger: ".tr_resource_booking_link:eq(0)",
},
{
content: "Schedule button",
trigger: ".badge:contains('Pending')",
},
]
);
});
5 changes: 4 additions & 1 deletion resource_booking/templates/portal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@
<t t-foreach="bookings" t-as="booking">
<tr>
<td>
<a t-att-href="booking.get_portal_url()">
<a
t-att-href="booking.get_portal_url()"
t-attf-class="tr_resource_booking_link"
>
<span t-field="booking.display_name" />
</a>
</td>
Expand Down
20 changes: 3 additions & 17 deletions resource_booking/tests/test_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,14 @@ def _url_xml(self, url, data=None, timeout=10):
return fromstring(response.content)

def test_portal_no_bookings(self):
self.authenticate("ptl", "ptl")
page = fromstring(self.url_open("/my").content)
self.assertTrue(page.cssselect(".o_portal_docs"))
self.assertFalse(page.cssselect('.o_portal_docs a:contains("Bookings")'))
self.start_tour("/", "resource_booking_ptl_tour", login="ptl")

def test_portal_list_with_bookings(self):
# Create one pending booking
booking = self.env["resource.booking"].create(
self.env["resource.booking"].create(
{"partner_id": self.user_portal.partner_id.id, "type_id": self.rbt.id}
)
self.authenticate("ptl", "ptl")
# Main portal page contains bookings count
page = self._url_xml("/my")
link = page.cssselect('.o_portal_docs a:contains("Bookings")')[0]
self.assertEqual(link.cssselect(".badge")[0].text.strip(), "1")
# Bookings page lists 1 booking
page = self._url_xml(link.get("href"))
self.assertEqual(len(page.cssselect(".o_portal_my_doc_table tr")), 2)
link = page.cssselect('.o_portal_my_doc_table a:contains("%d")' % booking.id)[0]
# Booking page has schedule button
page = self._url_xml(link.get("href"))
self.assertTrue(page.cssselect('.badge:contains("Pending")'))
self.start_tour("/", "resource_booking_ptl2_tour", login="ptl")

def test_portal_scheduling_conflict(self):
"""Produce a scheduling conflict and see how UI behaves.
Expand Down

0 comments on commit 01f2144

Please sign in to comment.