[IMP] web: mock routes/methods defined outside web
Add a registry on the mockServer to allow mocking routes/methods defined outside web Co-authored-by: Samuel Degueldre <sad@odoo.com>
This commit is contained in:
committed by
Mathieu Duckerts-Antoine
co-authored by
Samuel Degueldre
parent
24c643bc4f
commit
b27ec4067a
@@ -374,6 +374,17 @@ export class MockServer {
|
||||
}
|
||||
|
||||
_performRPC(route, args) {
|
||||
// Check if there is an handler in the mockRegistry: either specific for this model
|
||||
// (with key 'model/method'), or global (with key 'method')
|
||||
// This allows to mock routes/methods defined outside web.
|
||||
const methodName = args.method || route;
|
||||
const mockFunction =
|
||||
registry.category("mock_server").get(`${args.model}/${methodName}`, null) ||
|
||||
registry.category("mock_server").get(methodName, null);
|
||||
if (mockFunction) {
|
||||
return mockFunction.call(this, route, args);
|
||||
}
|
||||
|
||||
switch (route) {
|
||||
case "/web/webclient/load_menus":
|
||||
return Promise.resolve(this.mockLoadMenus());
|
||||
|
||||
Reference in New Issue
Block a user