Tour tests are preset scenarios designed to subject the system to different conditions, effectively helping to detect potential defects. In Odoo, Test Tours integrates both Individual Python and JavaScript testing aspects and provides an exploratory testing approach.
Apart from testing purposes, tours in Odoo play a pivotal role in enhancing user experience, onboarding new users, and ensuring effective utilization of the platform's extensive features. This blog will help you get an idea of how to create a test tour, with each step made easy for new users.
For adding tours in a module, follow these steps,
* Firstly register for the tour of your module
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
import { stepUtils } from "@web_tour/tour_service/tour_utils";
registry.category("web_tour.tours").add(mobile_tour, {
url: "/web",
test: true
}
URL - The page from which the tour should start
test - If it is set to true, then this tour will be used only for testing purposes.
* Add steps to the tour
steps: () => [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: 200,
}, {
trigger: ".o_list_button_add",
extra_trigger: ".o_mobile_service"
content: _t("Let\'s create your first service by clicking on create."),
position: "bottom",
edition: "community",
}, {
trigger: "input[name="contact_no"]",
auto: true,
content: _t("Fill in the contact number."),
run: function (actions) {
actions.text("155555");
},
position : "right"
}
}]
Each step in the tour can include a set of arguments. Some possible arguments are:
trigger - The jQuery element or selector which needs to trigger.
extra-trigger - Extra trigger acts the same as the triggers, and you can make use of this in situations where you need to wait for a specific event to happen.
run - The action that needs to run.
edition - The edition in which the tests are needed to run.
position - The position where the icons and texts should be displayed.
* Add tour file in the manifest
'assets': {
'web.assets_backend': [
'/mobile_service_shop/static/src/js/tour.js',
]
}
* To run a test case, add the test file and execute the tour test case using a class that inherits from `HTTPCase`.
def test_mobile_tour(self):
self.start_tour("/web", 'mobile_tour', login = "admin")
* Run the test case using the command
./odoo-bin -c odoo14.conf -i mobile_service_shop - - test - tags=mobile_service_shop
Overall, tours facilitate feature discovery, enabling users to uncover and utilize the full capabilities of Odoo, which they might otherwise overlook. However, This blog will guide you in creating a tour for your custom module effectively.
To read more about How to Create a Tour Test Case in Odoo 15, refer to our blog How to Create a Tour Test Case in Odoo 15.