Enable Dark Mode!
how-to-create-a-tour-test-case-in-odoo-15.jpg
By: Aiswarya JP

How to Create a Tour Test Case in Odoo 15

Technical Odoo 15

In Odoo, we have seen Python and Javascript test cases, where both work separately without interacting with each other. In contrast to this, Odoo tour test cases can be used to test integration between both Python and Javascript, thereby we can ensure that python and Javascript sides work each other properly.
Other than testing purposes, tours can also be used for demonstration purposes. With tours, we can guide an end user through steps while giving feedback to the user along the way.
To add a tour test case for a custom module, follow the below-mentioned steps;
1. Create a tour by first registering it
odoo.define('mobile_service_shop.mobile_tour', function (require) {
            "use strict";
            var core = require('web.core');
            var tour = require('web_tour.tour');

            var _t = core._t;
            tour.register('mobile_tour', {
                        url: "/web",
                        test: true,
                        skip_enabled: true,
                    },
Below listed are some possible options that can be defined for a tour
i. URL: The page from where the tour should start.
ii. skip_enabled: Add a skip button on the tip.
iii. test: Must set test option as true for testing purpose. By default, it will be false.
2. Add a required number of steps to the tour.
[tour.stepUtils.showAppsMenuItem(), {
        trigger: '.o_app[data-menu-xmlid="mobile_service_shop.mobile_service_main_menu"]',
        content: _t('Want to manage your services? It starts here.'),
        position: 'bottom',
        width: 300,
    },
    {
        trigger: '.o_list_button_add',
        extra_trigger: '.o_mobile_service',
        content: _t('Let\'s create your first service by clicking on create.'),
        position: 'bottom',
    },
    {
        trigger: 'input[name="contact_no"]',
        auto: true,
        content: _t('Fill in the contact Number.'),
        // When you run the test (from the developer tools) it will automatically fill in '1555555'.
        run: function (actions) {
            actions.text('155555');
        },
        position: 'right',
    }
]);
});
Each step in the tour can have a set of arguments. Some possible arguments are;
i. trigger: selector/element/jQuery you want to trigger
ii. extra-trigger: option to make sure the step is on the screen.
iii. run: In the run function, we can specify the action that needs to be performed when tours run automatically. By default, it will perform actions.auto(), which will click on the specified element in the step.
iv. edition: specify the edition in which the step needs to be run.
v. position: the position where the text and icon need to be displayed.
3. Add tour.js file in a manifest.
	'assets': {
    'web.assets_backend': [
        '/mobile_service_shop/static/src/js/tour.js'
    ]
}
4. In order to run a test case, add the tests/test_tour.py file and run the tour test case by class inherited from HTTPCase
def test_mobile_tour(self): #Optional Setup
# Optional Setup
self.start_tour("/web", 'mobile_service_shop.mobile_tour', login = "admin")
5. To run the test case, start the server with the following option;
 ./odoo-bin -c odoo14.conf -i mobile_service_shop - - test - tags=mobile_service_shop
6. If our test case ran successfully, the following log will be displayed.
 …INFO test odoo.addons.mobile_service_shop.tests.mobile_tour.TestMobileTour:
console log: Tour mobile_tour succeeded
This is how we can create a tour test case in Odoo which will make us able to check if the web client and the server work together properly.


If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment

 


whatsapp
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message