mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:40:53 -06:00
DEV: prevents route action to crash in tests (#28409)
`routeAction` is testing at runtime that a route exists when in debug mode. However in the case of components tested in isolation there's no existing route which was causing an exception, this commit prevents this check in this case as it's irrelevant.
This commit is contained in:
parent
2f8dc64caf
commit
ea8516b38d
@ -5,6 +5,7 @@ import { assert, runInDebug } from "@ember/debug";
|
||||
import { computed, get } from "@ember/object";
|
||||
import { getOwner } from "@ember/owner";
|
||||
import { join } from "@ember/runloop";
|
||||
import { isTesting } from "discourse-common/config/environment";
|
||||
|
||||
function getCurrentRouteInfos(router) {
|
||||
let routerLib = router._routerMicrolib || router.router;
|
||||
@ -30,13 +31,15 @@ function getRouteWithAction(router, actionName) {
|
||||
function routeAction(actionName, router, ...params) {
|
||||
assert("[ember-route-action-helper] Unable to lookup router", router);
|
||||
|
||||
runInDebug(() => {
|
||||
let { handler } = getRouteWithAction(router, actionName);
|
||||
assert(
|
||||
`[ember-route-action-helper] Unable to find action ${actionName}`,
|
||||
handler
|
||||
);
|
||||
});
|
||||
if (!isTesting() || router.currentRoute) {
|
||||
runInDebug(() => {
|
||||
let { handler } = getRouteWithAction(router, actionName);
|
||||
assert(
|
||||
`[ember-route-action-helper] Unable to find action ${actionName}`,
|
||||
handler
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return function (...invocationArgs) {
|
||||
let { action, handler } = getRouteWithAction(router, actionName);
|
||||
|
Loading…
Reference in New Issue
Block a user