router icon indicating copy to clipboard operation
router copied to clipboard

Child routes are not validated properly

Open SomeoneToIgnore opened this issue 7 years ago • 1 comments

There are two issues with the same feature:

  1. When I specify children property of a route as a non-array in top-level route, I get an error explaining me that I am wrong:

Test:

it('children is specified as an object, not array', async() => {
  router.setRoutes([{
    path: '/a',
    children: 
      {path: '/b', component: 'x-b'}
  }]);

  await router.render('/a/b');
});

Actual: [Vaadin.Router] Expected route config "/a" to include either "component", "redirect", "bundle" or "action" function but none found.

Expected: router telling me that I should declare children as an array of objects, not objects. Alternatively, since we have plenty of APIs already that call toArray method in such cases (for instance, setRoutes method, router can wrap this into the array for me automatically.

=========

  1. When I specify children property of a route as a non-array in child route, it is not validated at all.

Test:

it('child route is defined wrong', async() => {
  router.setRoutes([{
    path: '/a',
    children: [
      {path: '/b', children: {path: '/c', component: 'x-c'}}
    ]
  }]);

  await router.render('/a/b/c');
});

Actual: Page not found (/a/b/c)

Expected: same error message as above, but for the child route

SomeoneToIgnore avatar Jun 21 '18 07:06 SomeoneToIgnore

This can be a part of #171

vlukashov avatar Aug 11 '19 20:08 vlukashov