Revert "chore: Fixup tests snapshots to match new testid behaviour"

This reverts commit e6bef1a168.
This commit is contained in:
Sebastian Malton committed 2023-05-23 10:08:42 -04:00
1 parent d90bdf6f14
commit 9276df0592
35 files changed
+16774 -1409

No files matched your search

@@ -8,7 +8,7 @@ import { extensionRegistratorInjectionToken } from "../../../extensions/extensio
import { sidebarItemInjectionToken } from "@k8slens/cluster-sidebar";
import { computed } from "mobx";
import routesInjectable from "../../routes/routes.injectable";
import { matches } from "lodash/fp";
import { matches, noop } from "lodash/fp";
import routeIsActiveInjectable from "../../routes/route-is-active.injectable";
import { navigateToRouteInjectionToken } from "../../../common/front-end-routing/navigate-to-route-injection-token";
import { getExtensionRoutePath } from "../../routes/for-extension";
@@ -23,55 +23,66 @@ const extensionSidebarItemRegistratorInjectable = getInjectable({
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const routes = di.inject(routesInjectable);
const extensionShouldBeEnabledForClusterFrame = di.inject(extensionShouldBeEnabledForClusterFrameInjectable, extension);
const extensionRoutes = computed(() => routes.get().filter(matches({ extension })));
return computed(() => extension.clusterPageMenus.map((registration) => {
const {
components,
title,
orderNumber = 9999,
parentId: rawParentId,
visible,
id: rawId,
target,
} = registration;
const id = rawId
? `sidebar-item-${extension.sanitizedExtensionId}-${rawId}`
: `sidebar-item-${extension.sanitizedExtensionId}`;
const parentId = rawParentId
? `sidebar-item-${extension.sanitizedExtensionId}-${rawParentId}`
: null;
const targetRoutePath = getExtensionRoutePath(extension, target?.pageId);
const targetRoute = computed(() => extensionRoutes.get().find(matches({ path: targetRoutePath })));
return computed(() => {
const extensionRoutes = routes.get().filter(matches({ extension }));
return getInjectable({
id,
instantiate: () => ({
orderNumber,
parentId,
isVisible: computed(() => extensionShouldBeEnabledForClusterFrame.value.get() && (visible?.get() ?? true)),
title,
getIcon: () => (components.Icon && <components.Icon />),
onClick: () => {
const route = targetRoute.get();
return extension.clusterPageMenus.map((registration) => {
const targetRoutePath = getExtensionRoutePath(
extension,
registration.target?.pageId,
);
if (route) {
navigateToRoute(route);
}
},
isActive: computed(() => {
const route = targetRoute.get();
const targetRoute = extensionRoutes.find(
matches({ path: targetRoutePath }),
);
if (!route) {
return false;
}
const isVisible = computed(() => {
if (!extensionShouldBeEnabledForClusterFrame.value.get()) {
return false;
}
return di.inject(routeIsActiveInjectable, route).get();
if (!registration.visible) {
return true;
}
return registration.visible.get();
});
const id = registration.id ?
`${extension.sanitizedExtensionId}-${registration.id}`
: extension.sanitizedExtensionId;
return getInjectable({
id: `sidebar-item-${id}`,
instantiate: () => ({
orderNumber: registration.orderNumber ?? 9999,
parentId: registration.parentId
? `${extension.sanitizedExtensionId}-${registration.parentId}`
: null,
isVisible,
title: registration.title,
getIcon: registration.components.Icon
? () => <registration.components.Icon />
: undefined,
...(targetRoute
? {
onClick: () => navigateToRoute(targetRoute),
isActive: di.inject(
routeIsActiveInjectable,
targetRoute,
),
}
: { onClick: noop }),
}),
}),
injectionToken: sidebarItemInjectionToken,
injectionToken: sidebarItemInjectionToken,
});
});
}));
});
},
injectionToken: extensionRegistratorInjectionToken,
@@ -82,7 +82,7 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
<a
aria-current="page"
class="navItem active"
data-testid="link-for-sidebar-item-cluster-overview"
data-testid="sidebar-item-link-for-cluster-overview"
href="/"
>
<i
@@ -104,7 +104,7 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
>
<a
class="navItem"
data-testid="link-for-sidebar-item-nodes"
data-testid="sidebar-item-link-for-nodes"
href="/"
>
<i
@@ -126,7 +126,7 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
>
<a
class="navItem"
data-testid="link-for-sidebar-item-workloads"
data-testid="sidebar-item-link-for-workloads"
href="/"
>
<i
@@ -141,7 +141,6 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
</span>
<i
class="Icon expandIcon material focusable"
data-testid="expand-icon-for-sidebar-item-workloads"
>
<span
class="icon"
@@ -152,6 +151,31 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
</i>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-config"
>
<a
class="navItem"
data-testid="sidebar-item-link-for-config"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="list"
>
list
</span>
</i>
<span>
Config
</span>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
@@ -159,7 +183,7 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
>
<a
class="navItem"
data-testid="link-for-sidebar-item-network"
data-testid="sidebar-item-link-for-network"
href="/"
>
<i
@@ -177,7 +201,6 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
</span>
<i
class="Icon expandIcon material focusable"
data-testid="expand-icon-for-sidebar-item-network"
>
<span
class="icon"
@@ -188,6 +211,31 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
</i>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-storage"
>
<a
class="navItem"
data-testid="sidebar-item-link-for-storage"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="storage"
>
storage
</span>
</i>
<span>
Storage
</span>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
@@ -195,7 +243,7 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
>
<a
class="navItem"
data-testid="link-for-sidebar-item-namespaces"
data-testid="sidebar-item-link-for-namespaces"
href="/"
>
<i
@@ -220,7 +268,7 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
>
<a
class="navItem"
data-testid="link-for-sidebar-item-helm"
data-testid="sidebar-item-link-for-helm"
href="/"
>
<i
@@ -235,7 +283,66 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
</span>
<i
class="Icon expandIcon material focusable"
data-testid="expand-icon-for-sidebar-item-helm"
>
<span
class="icon"
data-icon-name="keyboard_arrow_down"
>
keyboard_arrow_down
</span>
</i>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-user-management"
>
<a
class="navItem"
data-testid="sidebar-item-link-for-user-management"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="security"
>
security
</span>
</i>
<span>
Access Control
</span>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-custom-resources"
>
<a
class="navItem"
data-testid="sidebar-item-link-for-custom-resources"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="extension"
>
extension
</span>
</i>
<span>
Custom Resources
</span>
<i
class="Icon expandIcon material focusable"
>
<span
class="icon"
@@ -479,7 +586,7 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
<a
aria-current="page"
class="navItem active"
data-testid="link-for-sidebar-item-cluster-overview"
data-testid="sidebar-item-link-for-cluster-overview"
href="/"
>
<i
@@ -501,7 +608,7 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
>
<a
class="navItem"
data-testid="link-for-sidebar-item-nodes"
data-testid="sidebar-item-link-for-nodes"
href="/"
>
<i
@@ -523,7 +630,7 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
>
<a
class="navItem"
data-testid="link-for-sidebar-item-workloads"
data-testid="sidebar-item-link-for-workloads"
href="/"
>
<i
@@ -538,7 +645,6 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
</span>
<i
class="Icon expandIcon material focusable"
data-testid="expand-icon-for-sidebar-item-workloads"
>
<span
class="icon"
@@ -549,6 +655,31 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
</i>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-config"
>
<a
class="navItem"
data-testid="sidebar-item-link-for-config"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="list"
>
list
</span>
</i>
<span>
Config
</span>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
@@ -556,7 +687,7 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
>
<a
class="navItem"
data-testid="link-for-sidebar-item-network"
data-testid="sidebar-item-link-for-network"
href="/"
>
<i
@@ -574,7 +705,6 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
</span>
<i
class="Icon expandIcon material focusable"
data-testid="expand-icon-for-sidebar-item-network"
>
<span
class="icon"
@@ -585,6 +715,31 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
</i>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-storage"
>
<a
class="navItem"
data-testid="sidebar-item-link-for-storage"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="storage"
>
storage
</span>
</i>
<span>
Storage
</span>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
@@ -592,7 +747,7 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
>
<a
class="navItem"
data-testid="link-for-sidebar-item-namespaces"
data-testid="sidebar-item-link-for-namespaces"
href="/"
>
<i
@@ -617,7 +772,7 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
>
<a
class="navItem"
data-testid="link-for-sidebar-item-helm"
data-testid="sidebar-item-link-for-helm"
href="/"
>
<i
@@ -632,7 +787,66 @@ exports[`<ClusterFrame /> given cluster with list nodes and namespaces permissio
</span>
<i
class="Icon expandIcon material focusable"
data-testid="expand-icon-for-sidebar-item-helm"
>
<span
class="icon"
data-icon-name="keyboard_arrow_down"
>
keyboard_arrow_down
</span>
</i>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-user-management"
>
<a
class="navItem"
data-testid="sidebar-item-link-for-user-management"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="security"
>
security
</span>
</i>
<span>
Access Control
</span>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-custom-resources"
>
<a
class="navItem"
data-testid="sidebar-item-link-for-custom-resources"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="extension"
>
extension
</span>
</i>
<span>
Custom Resources
</span>
<i
class="Icon expandIcon material focusable"
>
<span
class="icon"
@@ -883,7 +1097,7 @@ exports[`<ClusterFrame /> given cluster without list nodes, but with namespaces
<a
aria-current="page"
class="navItem active"
data-testid="link-for-sidebar-item-workloads"
data-testid="sidebar-item-link-for-workloads"
href="/"
>
<i
@@ -898,7 +1112,6 @@ exports[`<ClusterFrame /> given cluster without list nodes, but with namespaces
</span>
<i
class="Icon expandIcon material focusable"
data-testid="expand-icon-for-sidebar-item-workloads"
>
<span
class="icon"
@@ -909,6 +1122,31 @@ exports[`<ClusterFrame /> given cluster without list nodes, but with namespaces
</i>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-config"
>
<a
class="navItem"
data-testid="sidebar-item-link-for-config"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="list"
>
list
</span>
</i>
<span>
Config
</span>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
@@ -916,7 +1154,7 @@ exports[`<ClusterFrame /> given cluster without list nodes, but with namespaces
>
<a
class="navItem"
data-testid="link-for-sidebar-item-network"
data-testid="sidebar-item-link-for-network"
href="/"
>
<i
@@ -934,7 +1172,6 @@ exports[`<ClusterFrame /> given cluster without list nodes, but with namespaces
</span>
<i
class="Icon expandIcon material focusable"
data-testid="expand-icon-for-sidebar-item-network"
>
<span
class="icon"
@@ -945,6 +1182,31 @@ exports[`<ClusterFrame /> given cluster without list nodes, but with namespaces
</i>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-storage"
>
<a
class="navItem"
data-testid="sidebar-item-link-for-storage"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="storage"
>
storage
</span>
</i>
<span>
Storage
</span>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
@@ -952,7 +1214,7 @@ exports[`<ClusterFrame /> given cluster without list nodes, but with namespaces
>
<a
class="navItem"
data-testid="link-for-sidebar-item-namespaces"
data-testid="sidebar-item-link-for-namespaces"
href="/"
>
<i
@@ -977,7 +1239,7 @@ exports[`<ClusterFrame /> given cluster without list nodes, but with namespaces
>
<a
class="navItem"
data-testid="link-for-sidebar-item-helm"
data-testid="sidebar-item-link-for-helm"
href="/"
>
<i
@@ -992,7 +1254,66 @@ exports[`<ClusterFrame /> given cluster without list nodes, but with namespaces
</span>
<i
class="Icon expandIcon material focusable"
data-testid="expand-icon-for-sidebar-item-helm"
>
<span
class="icon"
data-icon-name="keyboard_arrow_down"
>
keyboard_arrow_down
</span>
</i>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-user-management"
>
<a
class="navItem"
data-testid="sidebar-item-link-for-user-management"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="security"
>
security
</span>
</i>
<span>
Access Control
</span>
</a>
</div>
<div
class="SidebarItem"
data-is-active-test="false"
data-testid="sidebar-item-custom-resources"
>
<a
class="navItem"
data-testid="sidebar-item-link-for-custom-resources"
href="/"
>
<i
class="Icon material focusable"
>
<span
class="icon"
data-icon-name="extension"
>
extension
</span>
</i>
<span>
Custom Resources
</span>
<i
class="Icon expandIcon material focusable"
>
<span
class="icon"
@@ -1022,7 +1343,7 @@ exports[`<ClusterFrame /> given cluster without list nodes, but with namespaces
<div
class="Tab flex gaps align-center active"
data-is-active-test="true"
data-testid="tab-link-for-sidebar-item-workloads-overview"
data-testid="tab-link-for-overview"
role="tab"
tabindex="0"
>
@@ -14,10 +14,13 @@ const routeIsActiveInjectable = getInjectable({
instantiate: (di, route: Route<unknown>) => {
const currentPath = di.inject(currentPathInjectable);
return computed(() => !!matchPath(currentPath.get(), {
path: route.path,
exact: true,
}));
return computed(
() =>
!!matchPath(currentPath.get(), {
path: route.path,
exact: true,
}),
);
},
lifecycle: lifecycleEnum.keyedSingleton({