diff --git a/src/settings/components/general-settings/logout.test.tsx b/src/settings/components/general-settings/logout.test.tsx deleted file mode 100644 index aeefc82d..00000000 --- a/src/settings/components/general-settings/logout.test.tsx +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Zextras - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import React from 'react'; - -import { act, screen, waitFor } from '@testing-library/react'; - -import { Logout } from './logout'; -import { waitForRequest } from '../../../mocks/server'; -import * as networkUtils from '../../../network/utils'; -import { useLoginConfigStore } from '../../../store/login/store'; -import { setup } from '../../../tests/utils'; - -describe('Logout', () => { - test('should redirect to custom logout url on manual logout', async () => { - const customLogout = 'custom.logout.url'; - const goToFn = jest.spyOn(networkUtils, 'goTo').mockImplementation(); - const goToLoginFn = jest.spyOn(networkUtils, 'goToLogin').mockImplementation(); - useLoginConfigStore.setState((s) => ({ ...s, carbonioWebUiLogoutURL: customLogout })); - const { user } = setup(); - const logout = waitForRequest('get', '/logout'); - await user.click(screen.getByRole('button', { name: /logout/i })); - await logout; - act(() => { - jest.runOnlyPendingTimers(); - }); - await waitFor(() => expect(goToFn).toHaveBeenCalled()); - expect(goToFn).toHaveBeenCalledTimes(1); - expect(goToFn).toHaveBeenCalledWith(customLogout); - expect(goToLoginFn).not.toHaveBeenCalled(); - }); - - test('should redirect to login if no custom logout url is set', async () => { - const goToFn = jest.spyOn(networkUtils, 'goTo').mockImplementation(); - const goToLoginFn = jest.spyOn(networkUtils, 'goToLogin').mockImplementation(); - useLoginConfigStore.setState((s) => ({ ...s, carbonioWebUiLogoutURL: '' })); - const { user } = setup(); - const logout = waitForRequest('get', '/logout'); - await user.click(screen.getByRole('button', { name: /logout/i })); - await logout; - act(() => { - jest.runOnlyPendingTimers(); - }); - await waitFor(() => expect(goToLoginFn).toHaveBeenCalled()); - expect(goToLoginFn).toHaveBeenCalledTimes(1); - expect(goToFn).not.toHaveBeenCalled(); - }); -}); diff --git a/src/settings/components/general-settings/logout.tsx b/src/settings/components/general-settings/logout.tsx deleted file mode 100644 index f6a56372..00000000 --- a/src/settings/components/general-settings/logout.tsx +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2021 Zextras - * - * SPDX-License-Identifier: AGPL-3.0-only - */ - -import React, { useMemo } from 'react'; - -import { Button, FormSubSection } from '@zextras/carbonio-design-system'; -import { useTranslation } from 'react-i18next'; - -import { logout } from '../../../network/logout'; -import { accountSubSection } from '../../general-settings-sub-sections'; - -export const Logout = (): React.JSX.Element => { - const [t] = useTranslation(); - - const sectionTitle = useMemo(() => accountSubSection(t), [t]); - - return ( - -