diff --git a/addons/website_event_sale/static/tests/tours/website_event_sale_last_ticket.js b/addons/website_event_sale/static/tests/tours/website_event_sale_last_ticket.js new file mode 100644 index 00000000000..576109e72fa --- /dev/null +++ b/addons/website_event_sale/static/tests/tours/website_event_sale_last_ticket.js @@ -0,0 +1,92 @@ +odoo.define('website_event_sale.tour.last_ticket', function (require) { +'use strict'; + +var tour = require('web_tour.tour'); + +tour.register('event_buy_last_ticket', { + test: true, + url: '/event', +},[{ + content: "Open the Last ticket test event page", + trigger: '.o_wevent_events_list a:contains("Last ticket test")', + }, + { + content: "Show available Tickets", + trigger: '.btn-primary:contains("Register")', + }, + { + content: "Select 2 units of `VIP` ticket type", + extra_trigger: '#wrap:not(:has(a[href*="/event"]:contains("Last ticket test")))', + trigger: 'select:eq(0)', + run: 'text 2', + }, + { + content: "Click on `Order Now` button", + extra_trigger: 'select:eq(0):has(option:contains(2):propSelected)', + trigger: '.a-submit:contains("Register")', + }, + { + content: "Fill attendees details", + trigger: 'form[id="attendee_registration"] .btn:contains("Continue")', + run: function () { + $("input[name='1-name']").val("Att1"); + $("input[name='1-phone']").val("111 111"); + $("input[name='1-email']").val("att1@example.com"); + $("input[name='2-name']").val("Att2"); + $("input[name='2-phone']").val("222 222"); + $("input[name='2-email']").val("att2@example.com"); + }, + }, + { + content: "Validate attendees details", + extra_trigger: "input[name='1-name'], input[name='2-name']", + trigger: 'button:contains("Continue")', + }, + { + content: "Fill address", + trigger: 'form.checkout_autoformat', + run: function () { + $("input[name='name']").val("test1"); + $("input[name='email']").val("test@example.com"); + $("input[name='phone']").val("111 111"); + $("input[name='street']").val("street test 1"); + $("input[name='city']").val("testCity"); + $("input[name='zip']").val("123"); + $('#country_id option:eq(1)').attr('selected', true); + }, + }, + { + content: "Validate address", + trigger: '.btn-primary:contains("Next")', + }, + { + // if the seats_available checking logic is not correct, + // the shopping cart will be cleared when selling the last ticket + // the tour test will be failed here + content: "Select `Wire Transfer` payment method", + trigger: '#payment_method label:contains("Wire Transfer")', + }, + // following steps are based on the website_sale_buy.js + { + content: "Pay", + //Either there are multiple payment methods, and one is checked, either there is only one, and therefore there are no radio inputs + extra_trigger: '#payment_method label:contains("Wire Transfer") input:checked,#payment_method:not(:has("input:radio:visible"))', + trigger: 'button[name="o_payment_submit_button"]:visible:not(:disabled)', + }, + { + content: "payment finish", + trigger: '.oe_website_sale:contains("Please use the following transfer details")', + // Leave /shop/confirmation to prevent RPC loop to /shop/payment/get_status. + // The RPC could be handled in python while the tour is killed (and the session), leading to crashes + run: function () { + window.location.href = '/contactus'; // Redirect in JS to avoid the RPC loop (20x1sec) + }, + timeout: 30000, + }, + { + content: "wait page loaded", + trigger: 'h1:contains("Contact us")', + run: function () {}, // it's a check + }, +]); +}); diff --git a/addons/website_event_sale/tests/test_frontend_buy_tickets.py b/addons/website_event_sale/tests/test_frontend_buy_tickets.py index 628fea935ae..2ef773771e3 100644 --- a/addons/website_event_sale/tests/test_frontend_buy_tickets.py +++ b/addons/website_event_sale/tests/test_frontend_buy_tickets.py @@ -37,8 +37,27 @@ class TestUi(HttpCaseWithUserDemo): 'price': 1500.0, }]) + self.event_3 = self.env['event.event'].create({ + 'name': 'Last ticket test', + 'user_id': self.env.ref('base.user_admin').id, + 'date_begin': (Datetime.today() + timedelta(days=5)).strftime('%Y-%m-%d 07:00:00'), + 'date_end': (Datetime.today() + timedelta(days=5)).strftime('%Y-%m-%d 16:30:00'), + 'website_published': True, + }) + + self.env['event.event.ticket'].create([{ + 'name': 'VIP', + 'event_id': self.event_3.id, + 'product_id': self.env.ref('event_sale.product_product_event').id, + 'end_sale_datetime': (Datetime.today() + timedelta(90)).strftime('%Y-%m-%d'), + 'price': 1500.0, + 'seats_max': 2, + }]) + + # flush event to ensure having tickets available in the tests self.event_2.flush() + self.event_3.flush() (self.env.ref('base.partner_admin') + self.partner_demo).write({ 'street': '215 Vine St', @@ -65,4 +84,7 @@ class TestUi(HttpCaseWithUserDemo): def test_demo(self): self.start_tour("/", 'event_buy_tickets', login="demo") + def test_buy_last_ticket(self): + self.start_tour("/", 'event_buy_last_ticket') + # TO DO - add public test with new address when convert to web.tour format. diff --git a/addons/website_event_sale/views/assets.xml b/addons/website_event_sale/views/assets.xml new file mode 100644 index 00000000000..eb1cf85e5f7 --- /dev/null +++ b/addons/website_event_sale/views/assets.xml @@ -0,0 +1,11 @@ + + + + + +