diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json index d3173aecf3b..91d92173f8b 100644 --- a/oxlint-suppressions.json +++ b/oxlint-suppressions.json @@ -96,14 +96,6 @@ "count": 1 } }, - "web/app/(shareLayout)/components/authenticated-layout.tsx": { - "jsx_a11y/click-events-have-key-events": { - "count": 1 - }, - "jsx_a11y/no-static-element-interactions": { - "count": 1 - } - }, "web/app/(shareLayout)/webapp-reset-password/check-code/page.tsx": { "jsx_a11y/click-events-have-key-events": { "count": 1 diff --git a/web/app/(shareLayout)/components/__tests__/authenticated-layout.spec.tsx b/web/app/(shareLayout)/components/__tests__/authenticated-layout.spec.tsx index ca274a517e7..f3ba7a9a470 100644 --- a/web/app/(shareLayout)/components/__tests__/authenticated-layout.spec.tsx +++ b/web/app/(shareLayout)/components/__tests__/authenticated-layout.spec.tsx @@ -1,5 +1,7 @@ import type { AppData, AppMeta } from '@/models/share' import { render, screen } from '@testing-library/react' +import userEvent from '@testing-library/user-event' +import { webAppLogout } from '@/service/webapp-auth' import AuthenticatedLayout from '../authenticated-layout' type QueryState = { @@ -17,6 +19,7 @@ const updateAppInfo = vi.fn() const updateAppParams = vi.fn() const updateWebAppMeta = vi.fn() const updateUserCanAccessApp = vi.fn() +const replace = vi.fn() const mockWebAppState = { shareCode: 'share-code', @@ -74,7 +77,7 @@ vi.mock('@/context/web-app-context', () => ({ vi.mock('@/next/navigation', () => ({ usePathname: () => '/workflow/share-code', useRouter: () => ({ - replace: vi.fn(), + replace, }), useSearchParams: () => new URLSearchParams(), })) @@ -161,4 +164,16 @@ describe('AuthenticatedLayout', () => { expect(screen.queryByText('Workflow form content')).not.toBeInTheDocument() }) }) + + it('should expose the unauthorized logout action as a button', async () => { + const user = userEvent.setup() + userCanAccessAppQueryState.data = { result: false } + + renderLayout() + + await user.click(screen.getByRole('button', { name: 'common.userProfile.logout' })) + + expect(webAppLogout).toHaveBeenCalledWith('share-code') + expect(replace).toHaveBeenCalledWith('/webapp-signin?redirect_url=%2Fworkflow%2Fshare-code') + }) }) diff --git a/web/app/(shareLayout)/components/authenticated-layout.tsx b/web/app/(shareLayout)/components/authenticated-layout.tsx index a75c5312daa..f817b6c2ef6 100644 --- a/web/app/(shareLayout)/components/authenticated-layout.tsx +++ b/web/app/(shareLayout)/components/authenticated-layout.tsx @@ -96,9 +96,13 @@ const AuthenticatedLayout = ({ children }: { children: React.ReactNode }) => { return (
- +
) }