diff --git a/static/app/actionCreators/account.spec.tsx b/static/app/actionCreators/account.spec.tsx index 0fa7886cd9ceae..6f73b479ffd516 100644 --- a/static/app/actionCreators/account.spec.tsx +++ b/static/app/actionCreators/account.spec.tsx @@ -1,5 +1,3 @@ -import {redirect} from 'react-router-dom'; - import {waitFor} from 'sentry-test/reactTestingLibrary'; import {logout} from './account'; @@ -8,15 +6,16 @@ jest.mock('react-router-dom'); describe('logout', () => { it('has can logout', async function () { - const mock = MockApiClient.addMockResponse({ + jest.spyOn(window.location, 'assign').mockImplementation(() => {}); + const mockApi = new MockApiClient(); + const mockApiDelete = MockApiClient.addMockResponse({ url: '/auth/', method: 'DELETE', }); - const api = new MockApiClient(); - logout(api); + logout(mockApi); - await waitFor(() => expect(mock).toHaveBeenCalled()); - await waitFor(() => expect(redirect).toHaveBeenCalled()); + await waitFor(() => expect(mockApiDelete).toHaveBeenCalled()); + expect(window.location.assign).toHaveBeenCalledWith('/auth/login/'); }); }); diff --git a/static/app/actionCreators/account.tsx b/static/app/actionCreators/account.tsx index f754835352409a..ccadc2b20f2441 100644 --- a/static/app/actionCreators/account.tsx +++ b/static/app/actionCreators/account.tsx @@ -1,5 +1,3 @@ -import {redirect} from 'react-router-dom'; - import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator'; import {Client} from 'sentry/api'; import ConfigStore from 'sentry/stores/configStore'; @@ -52,7 +50,7 @@ export async function logout(api: Client, redirectUrl = '/auth/login/') { const data = await api.requestPromise('/auth/', {method: 'DELETE'}); // If there's a URL for SAML Single-logout, redirect back to IdP - redirect(data?.sloUrl || redirectUrl); + window.location.assign(data?.sloUrl || redirectUrl); } export function removeAuthenticator(api: Client, userId: string, authId: string) {