How to do it...

Follow these steps to add a tour test case for books:

  1. Add a /static/src/js/my_library_tour.js file, and add a tour like this:
odoo.define('my_library.tour', function (require) {
"use strict";

var core = require('web.core');
var tour = require('web_tour.tour');

var _t = core._t;

tour.register('library_tour', {
url: "/web",
}, [tour.STEPS.SHOW_APPS_MENU_ITEM, {
trigger: '.o_app[data-menu-xmlid="my_library.library_base_menu"]',
content: _t('Manage books and authors in<b>Library app</b>.'),
position: 'right'
}, {
trigger: '.o_list_button_add',
content: _t("Let's create new book."),
position: 'bottom'
}, {
trigger: 'input[name="name"]',
extra_trigger: '.o_form_editable',
content: _t('Set the book title'),
position: 'right',
run: function (actions) {
actions.text('Test Book');
},
}, {
trigger: '.o_int_colorpicker',
extra_trigger: '.o_form_editable',
content: _t('Set the book color'),
position: 'right',
run: function () {
this.$anchor.find('.o_color_3').click();
}
}, {
trigger: '.o_form_button_save',
content: _t('Save this book record'),
position: 'bottom',
}
]);

});
  1. Add a /tests/test_tour.py file, and run the tour through HttpCase, as follows:
from odoo.tests.common import HttpCase, tagged

class TestBookUI(HttpCase):

@tagged('post_install', '-at_install')
def test_01_book_tour(self):
"""Books UI tour test case"""
self.browser_js("/web",
"odoo.__DEBUG__.services['web_tour.tour'].run('library_tour')",
"odoo.__DEBUG__.services['web_tour.tour'].tours.library_tour.ready",
login="admin")

In order to run test cases, start the Odoo server with the following option:

./odoo-bin -c server.conf -i my_library --test-enable

Now, check the server log. Here, you will find the following logs if our test cases ran successfully:

...INFO test odoo.addons.my_library.tests.test_tour.TestBookUI: console log: Tour library_tour succeeded 
...INFO test odoo.addons.my_library.tests.test_tour.TestBookUI: console log: ok
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset