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:
Joffrey JAFFEUX
2024-08-17 13:52:20 +02:00
committed by GitHub
parent 2f8dc64caf
commit ea8516b38d

View File

@@ -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,6 +31,7 @@ function getRouteWithAction(router, actionName) {
function routeAction(actionName, router, ...params) {
assert("[ember-route-action-helper] Unable to lookup router", router);
if (!isTesting() || router.currentRoute) {
runInDebug(() => {
let { handler } = getRouteWithAction(router, actionName);
assert(
@@ -37,6 +39,7 @@ function routeAction(actionName, router, ...params) {
handler
);
});
}
return function (...invocationArgs) {
let { action, handler } = getRouteWithAction(router, actionName);