This module didn't worked on mobile: user cannot select the products or see their cart. This commit reworks the LunchKanbanWidget template and introduces a dedicated template for mobile. This template introduces a button at the bottom of the screen to toggle the "cart" widget on mobile (hiding it by default). It tries to make the best use of the existing Bootstrap classes allowing to have a more responsive layout and reducing the custom CSS required by this module (both in desktop and in mobile). This commit adds a decent JS tests-suite (mobile & desktop) to this module as the existing one left substential parts of the UI untested (opening wizard when clicking on a kanban record, cart's lines content, clear cart button, widget structure and content based on the state...). Those tests are also less based on DOM nodes order/tag names and use instead dedicated classnames. It also modifies the LunchKanbanRecord click handling to had a dedicated event handler instead of overriding the default _onGlobalClick() and make it more testable. Task ID: 1945032
59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
odoo.define('lunch.test_utils', function (require) {
|
|
"use strict";
|
|
|
|
const AbstractStorageService = require('web.AbstractStorageService');
|
|
const RamStorage = require('web.RamStorage');
|
|
const {createView} = require('web.test_utils');
|
|
|
|
/**
|
|
* Helper to create a lunch kanban view with searchpanel
|
|
*
|
|
* @param {object} params
|
|
*/
|
|
function createLunchKanbanView(params) {
|
|
const archPieces = params.arch.split('</templates>');
|
|
params.arch = `
|
|
${archPieces[0]}</templates>
|
|
<searchpanel>
|
|
<field name="category_id" select="multi" string="Categories"/>
|
|
<field name="supplier_id" select="multi" string="Vendors"/>
|
|
</searchpanel>
|
|
${archPieces[1]}
|
|
`;
|
|
if (!params.services || !params.services.local_storage) {
|
|
// the searchPanel uses the localStorage to store/retrieve default
|
|
// active category value
|
|
params.services = params.services || {};
|
|
const RamStorageService = AbstractStorageService.extend({
|
|
storage: new RamStorage(),
|
|
});
|
|
params.services.local_storage = RamStorageService;
|
|
}
|
|
return createView(params);
|
|
}
|
|
|
|
/**
|
|
* Helper to generate a mockRPC function for the mandatory lunch routes (prefixed by '/lunch')
|
|
*
|
|
* @param {object} infos
|
|
* @param {integer} userLocation
|
|
*/
|
|
function mockLunchRPC({infos, userLocation}) {
|
|
return function (route) {
|
|
if (route === '/lunch/infos') {
|
|
return $.when(infos);
|
|
}
|
|
if (route === '/lunch/user_location_get') {
|
|
return $.when(userLocation);
|
|
}
|
|
return this._super.apply(this, arguments);
|
|
};
|
|
}
|
|
|
|
return {
|
|
createLunchKanbanView,
|
|
mockLunchRPC,
|
|
};
|
|
|
|
});
|