fix bug#8
Build & Push / Build & Push Docker Image (push) Successful in 4m2s
Test / Type Check (all packages) (push) Successful in 1m1s
Test / API Unit Tests (push) Successful in 50s
Test / Homepage Unit Tests (push) Successful in 43s
Test / Carplace Unit Tests (push) Successful in 41s
Test / Admin Unit Tests (push) Successful in 41s
Test / Dashboard Unit Tests (push) Successful in 42s
Test / API Integration Tests (push) Successful in 1m2s
Build & Push / Build & Push Docker Image (push) Successful in 4m2s
Test / Type Check (all packages) (push) Successful in 1m1s
Test / API Unit Tests (push) Successful in 50s
Test / Homepage Unit Tests (push) Successful in 43s
Test / Carplace Unit Tests (push) Successful in 41s
Test / Admin Unit Tests (push) Successful in 41s
Test / Dashboard Unit Tests (push) Successful in 42s
Test / API Integration Tests (push) Successful in 1m2s
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { APPROVED_BASELINE_MENU_KEYS, hasRenderableMenuItems, shouldUseGeneratedMenu } from './Sidebar'
|
||||
import { APPROVED_BASELINE_MENU_KEYS, getEmployeeLogoutRedirectUrl, hasRenderableMenuItems, shouldUseGeneratedMenu } from './Sidebar'
|
||||
|
||||
describe('Sidebar menu rendering helpers', () => {
|
||||
it('keeps the safe fallback menu to the approved seven baseline items in order', () => {
|
||||
@@ -14,6 +14,11 @@ describe('Sidebar menu rendering helpers', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('redirects employee logout to the public website instead of Carplace', () => {
|
||||
expect(getEmployeeLogoutRedirectUrl()).toBe('http://localhost:3000')
|
||||
expect(getEmployeeLogoutRedirectUrl()).not.toContain('/carplace')
|
||||
})
|
||||
|
||||
it('treats an empty employee menu as non-renderable so fallback navigation remains available', () => {
|
||||
expect(hasRenderableMenuItems(null)).toBe(false)
|
||||
expect(hasRenderableMenuItems([])).toBe(false)
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
AlertTriangle,
|
||||
} from 'lucide-react'
|
||||
import { DashboardLanguageSwitcher, DashboardThemeSwitcher, useDashboardI18n } from '@/components/I18nProvider'
|
||||
import { carplaceUrl } from '@/lib/urls'
|
||||
import { carplaceUrl, websiteUrl } from '@/lib/urls'
|
||||
import { EMPLOYEE_PROFILE_KEY, apiFetch } from '@/lib/api'
|
||||
import { toDashboardAppPath } from '@/lib/dashboardPaths'
|
||||
import { SHARED_LANGUAGE_KEY, readCurrentUserScopedPreference } from '@/lib/preferences'
|
||||
@@ -148,6 +148,10 @@ export function shouldUseGeneratedMenu(
|
||||
return hasRenderableMenuItems(items)
|
||||
}
|
||||
|
||||
export function getEmployeeLogoutRedirectUrl() {
|
||||
return websiteUrl
|
||||
}
|
||||
|
||||
function notifyParent(message: Record<string, unknown>) {
|
||||
if (typeof window === 'undefined' || window.parent === window) return
|
||||
window.parent.postMessage(message, '*')
|
||||
@@ -395,7 +399,7 @@ export default function Sidebar() {
|
||||
void fetch('/dashboard/api/v1/auth/employee/logout', { method: 'POST', credentials: 'include' })
|
||||
window.dispatchEvent(new CustomEvent('rentaldrivego:auth-changed'))
|
||||
notifyParent({ type: 'rentaldrivego:employee-logout' })
|
||||
window.location.href = carplaceUrl
|
||||
window.location.href = getEmployeeLogoutRedirectUrl()
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user