diff --git a/packages/editor-ui/src/components/MainSidebar.vue b/packages/editor-ui/src/components/MainSidebar.vue index bb35959474..0ed9eaab58 100644 --- a/packages/editor-ui/src/components/MainSidebar.vue +++ b/packages/editor-ui/src/components/MainSidebar.vue @@ -219,7 +219,7 @@ const onUserActionToggle = (action: string) => { onLogout(); break; case 'settings': - void router.push({ name: VIEWS.PERSONAL_SETTINGS }); + void router.push({ name: VIEWS.SETTINGS }); break; default: break; diff --git a/packages/editor-ui/src/constants.ts b/packages/editor-ui/src/constants.ts index 0ee70b9929..a5236db849 100644 --- a/packages/editor-ui/src/constants.ts +++ b/packages/editor-ui/src/constants.ts @@ -487,6 +487,7 @@ export const enum VIEWS { SETUP = 'SetupView', FORGOT_PASSWORD = 'ForgotMyPasswordView', CHANGE_PASSWORD = 'ChangePasswordView', + SETTINGS = 'Settings', USERS_SETTINGS = 'UsersSettings', LDAP_SETTINGS = 'LdapSettings', PERSONAL_SETTINGS = 'PersonalSettings', diff --git a/packages/editor-ui/src/router.ts b/packages/editor-ui/src/router.ts index f3bf9f656a..cdf162717e 100644 --- a/packages/editor-ui/src/router.ts +++ b/packages/editor-ui/src/router.ts @@ -480,8 +480,10 @@ export const routes: RouteRecordRaw[] = [ }, { path: '/settings', + name: VIEWS.SETTINGS, component: SettingsView, props: true, + redirect: { name: VIEWS.USAGE }, children: [ { path: 'usage', diff --git a/packages/editor-ui/src/views/SettingsView.test.ts b/packages/editor-ui/src/views/SettingsView.test.ts new file mode 100644 index 0000000000..87875147f8 --- /dev/null +++ b/packages/editor-ui/src/views/SettingsView.test.ts @@ -0,0 +1,122 @@ +import { createTestingPinia } from '@pinia/testing'; +import { createRouter, createWebHistory } from 'vue-router'; +import userEvent from '@testing-library/user-event'; +import { createComponentRenderer } from '@/__tests__/render'; +import SettingsView from '@/views/SettingsView.vue'; +import { VIEWS } from '@/constants'; +import { routes as originalRoutes } from '@/router'; + +const component = { template: '
' }; +const settingsRoute = originalRoutes.find((route) => route.name === VIEWS.SETTINGS); + +const settingsRouteChildren = + settingsRoute?.children?.map(({ name, path }) => ({ + name, + path, + component, + })) ?? []; + +const router = createRouter({ + history: createWebHistory(), + routes: [ + { + path: '/', + redirect: '/home', + }, + { + path: '/home', + name: 'Homepage', + redirect: '/home/workflows', + children: [ + { + path: 'workflows', + name: 'Workflows', + component, + }, + { + path: 'credentials', + name: 'Credentials', + component, + }, + { + path: 'executions', + name: 'Executions', + component, + }, + ], + }, + { + path: '/settings', + name: VIEWS.SETTINGS, + component: SettingsView, + props: true, + redirect: { name: VIEWS.USAGE }, + children: settingsRouteChildren, + }, + ], +}); + +const renderView = createComponentRenderer(SettingsView, { + pinia: createTestingPinia(), + global: { + plugins: [router], + }, +}); + +const renderApp = createComponentRenderer( + { + template: '