Dashboard: DashboardPageProxy - Use chaining operators to prevent runtime error (#86507)

* Use chaining operators to prevent runtime error

* Fix tests

---------

Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com>
This commit is contained in:
Alexa V
2024-04-18 17:15:18 +02:00
committed by GitHub
co-authored by Ivan Ortega
parent e65669bc0d
commit 7a147f2ce8
2 changed files with 10 additions and 3 deletions
@@ -147,7 +147,7 @@ describe('DashboardPageProxy', () => {
act(() => {
setup({
route: { routeName: DashboardRoutes.Home, component: () => null, path: '/' },
match: { params: {}, isExact: true, path: '/', url: '/' },
match: { params: { uid: '' }, isExact: true, path: '/', url: '/' },
});
});
@@ -176,7 +176,14 @@ describe('DashboardPageProxy', () => {
act(() => {
setup({
route: { routeName: DashboardRoutes.Home, component: () => null, path: '/' },
match: { params: {}, isExact: true, path: '/', url: '/' },
match: {
params: {
uid: '',
},
isExact: true,
path: '/',
url: '/',
},
});
});
@@ -54,7 +54,7 @@ function DashboardPageProxy(props: DashboardPageProxyProps) {
return null;
}
if (dashboard.value && dashboard.value.dashboard.uid && dashboard.value.dashboard.uid !== props.match.params.uid) {
if (dashboard?.value?.dashboard?.uid !== props.match.params.uid) {
return null;
}