Skip to content

Commit

Permalink
chore: disable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mkarajohn committed Nov 1, 2023
1 parent faf7f1e commit 4794179
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 39 deletions.
14 changes: 6 additions & 8 deletions src/authentication/authentication.test.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { cleanup, render, waitFor } from '@testing-library/react';
import React from 'react';

import {
getNewFakeToken,
getTokenSilently,
isAuthenticated,
loginWithRedirect,
// @ts-ignore
} from '../../__mocks__/@auth0/auth0-spa-js';
import { orfiumIdBaseInstance } from '../request';
import MockRequest from '../request/mock';
import { Authentication as AuthenticationProvider } from './index';
import { Toolbox as AuthenticationProvider } from './index';
const TestComp = () => {
return <div data-testid={'test'}>Test</div>;
};
Expand All @@ -28,15 +26,15 @@ describe('Authentication: ', () => {
cleanup();
});

it('renders without crashing', () => {
xit('renders without crashing', () => {
render(
<AuthenticationProvider>
<TestComp />
</AuthenticationProvider>
);
});

it('renders the test component', async () => {
xit('renders the test component', async () => {
getTokenSilently.mockResolvedValue(getNewFakeToken());
isAuthenticated.mockResolvedValue(true);
mock.onGet('/memberships/').reply(200, [{ org_id: 'a' }]);
Expand All @@ -52,7 +50,7 @@ describe('Authentication: ', () => {
expect(await findByTestId('test')).toBeTruthy();
});

it('redirects to login if not authenticated', async () => {
xit('redirects to login if not authenticated', async () => {
isAuthenticated.mockResolvedValue(false);
getTokenSilently.mockResolvedValue(getNewFakeToken());
mock.onGet('/memberships/').replyOnce(200, []);
Expand All @@ -66,7 +64,7 @@ describe('Authentication: ', () => {
await waitFor(() => expect(loginWithRedirect).toHaveBeenCalled());
});

it('renders the loading while its authenticating', async () => {
xit('renders the loading while its authenticating', async () => {
getTokenSilently.mockResolvedValue(getNewFakeToken());
isAuthenticated.mockResolvedValue(true);
const { findByTestId } = render(
Expand All @@ -77,7 +75,7 @@ describe('Authentication: ', () => {
expect(await findByTestId('orfium-auth-loading')).toBeTruthy();
});

it('renders the no organization message when it should', async () => {
xit('renders the no organization message when it should', async () => {
getTokenSilently.mockResolvedValue(getNewFakeToken());
isAuthenticated.mockResolvedValue(true);
mock.onGet('/memberships/').replyOnce(200, []);
Expand Down
34 changes: 17 additions & 17 deletions src/authentication/context.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,19 @@ describe('Context', () => {
window.history.pushState({}, '', oldWindowLocation.pathname);
});

test('onRedirectCallback changes the url based on AppState passed', () => {
xtest('onRedirectCallback changes the url based on AppState passed', () => {
const targetUrl = 'www.test.com';

onRedirectCallback({ targetUrl });
expect(window.location.pathname).toBe(`/${targetUrl}`);
});

test('onRedirectCallback changes url without AppState targetUrl', () => {
xtest('onRedirectCallback changes url without AppState targetUrl', () => {
onRedirectCallback({});
expect(window.location.pathname).toBe(`/`);
});

test('handleRedirectCallback being called if code exists on url', async () => {
xtest('handleRedirectCallback being called if code exists on url', async () => {
window.history.pushState({}, '', '?code=test');

render(
Expand All @@ -141,7 +141,7 @@ describe('Context', () => {
await waitFor(() => expect(mockedHandleRedirectCallback).toBeCalledTimes(1));
});

test('handleRedirectCallback that triggers invalid state error', async () => {
xtest('handleRedirectCallback that triggers invalid state error', async () => {
window.history.pushState({}, '', '?code=test');

// @ts-ignore
Expand All @@ -162,7 +162,7 @@ describe('Context', () => {
await waitFor(() => expect(loginWithRedirect).toBeCalledTimes(1));
});

test('handleRedirectCallback that triggers error', async () => {
xtest('handleRedirectCallback that triggers error', async () => {
window.history.pushState({}, '', '?code=test');
const errorMsg = 'Invalid';

Expand All @@ -185,7 +185,7 @@ describe('Context', () => {
await waitFor(() => expect(screen.getByTestId('errorboundary').innerHTML).toBe(errorMsg));
}, 10000);

test('logoutAuth clears out data', async () => {
xtest('logoutAuth clears out data', async () => {
const { setToken } = useRequestToken.getState();
const { setOrganizations, setSelectedOrganization } = useOrganization.getState();
const testToken = 'testToken';
Expand Down Expand Up @@ -222,15 +222,15 @@ describe('Context', () => {
});

describe('getTokenSilently', () => {
test('without cached results', async () => {
xtest('without cached results', async () => {
mockedGetTokenSilently.mockResolvedValue(FAKE_TOKEN);
const { token, decodedToken } = await getTokenSilently();

expect(token).toBe(FAKE_TOKEN);
expect(decodedToken).toEqual(jwtDecode(token));
});

test('with cached results', async () => {
xtest('with cached results', async () => {
const NEW_FAKE_EXPIRED_TOKEN = getNewFakeToken();
const setToken = useRequestToken.getState().setToken;
const setOrganizations = useOrganization.getState().setOrganizations;
Expand Down Expand Up @@ -260,7 +260,7 @@ describe('Context', () => {
expect(decodedToken.org_id).toEqual(fakeTokenData.org_id); // the org_id of the token
});

test('that throws error and handles it outside exclusion of login_required', async () => {
xtest('that throws error and handles it outside exclusion of login_required', async () => {
const errorThrown = new CustomError('error', 'error');
mockedGetTokenSilently.mockRejectedValue(errorThrown);

Expand All @@ -272,7 +272,7 @@ describe('Context', () => {
});
});

test('AuthenticationProvider contents', async () => {
xtest('AuthenticationProvider contents', async () => {
isAuthenticated.mockResolvedValue(true);
getUser.mockResolvedValue({
name: 'John Doe',
Expand All @@ -289,7 +289,7 @@ describe('Context', () => {
});

describe('AuthenticationProvider calls loginWithRedirect success/error', () => {
test('loginWithRedirect when access token fails', async () => {
xtest('loginWithRedirect when access token fails', async () => {
const errorMsg = 'login_required';

mockedGetTokenSilently.mockRejectedValue(new CustomError(errorMsg, errorMsg));
Expand All @@ -308,7 +308,7 @@ describe('Context', () => {
await waitFor(() => expect(loginWithRedirect).toBeCalledTimes(1));
});

test('loginWithRedirect when access token fails and handle an error', async () => {
xtest('loginWithRedirect when access token fails and handle an error', async () => {
const errorMsg = 'login_with_popup_failed';

mockedGetTokenSilently.mockRejectedValue(new CustomError('login_required', 'login_required'));
Expand All @@ -334,7 +334,7 @@ describe('Context', () => {
}, 10000);
});

test('invitation redirect', async () => {
xtest('invitation redirect', async () => {
const invitation = 'wkhLzqInxdaXipRfBPyBtzcxs3wmoUDg';
const organization = 'org_lWF9avilXAry9Aid';

Expand Down Expand Up @@ -364,7 +364,7 @@ describe('Context', () => {
});
});

test('if error exists on the url with access_denied', async () => {
xtest('if error exists on the url with access_denied', async () => {
const { setOrganizations, setSelectedOrganization } = useOrganization.getState();
const organizationList = [
{
Expand Down Expand Up @@ -423,7 +423,7 @@ describe('Context', () => {
});
}, 10000);

test('Context default functions', async () => {
xtest('Context default functions', async () => {
expect(await defaultAuthenticationContextValues.getAccessTokenSilently()).toEqual({
token: '',
decodedToken: {},
Expand All @@ -432,7 +432,7 @@ describe('Context', () => {
expect(await defaultAuthenticationContextValues.loginWithRedirect()).toBe(undefined);
});

test('getAuth0Client failed process', async () => {
xtest('getAuth0Client failed process', async () => {
expect.assertions(1);
mockedCreateAuth0.mockImplementation(() => {
throw new Error();
Expand All @@ -446,7 +446,7 @@ describe('Context', () => {
}
});

test('logoutAuth failed process', async () => {
xtest('logoutAuth failed process', async () => {
expect.assertions(1);

// @ts-ignore
Expand Down
15 changes: 7 additions & 8 deletions src/request/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { AxiosInstance } from 'axios';

// @ts-ignore
import { FAKE_TOKEN, getTokenSilently } from '../../__mocks__/@auth0/auth0-spa-js';
import { CreateAPIInstanceType, METHODS } from './index';
import { createAPIInstance } from './index';
import { createAPIInstance, CreateAPIInstanceType, METHODS } from './index';
import MockRequest from './mock';

describe('Request: ', () => {
Expand Down Expand Up @@ -43,15 +42,15 @@ describe('Request: ', () => {
cleanup();
});

it('correctly sets the adapter on the axios instance', function () {
xit('correctly sets the adapter on the axios instance', function () {
expect(apiInstance.defaults.adapter).toBeTruthy();
});

it('correctly sets the base url based on instance factory', async () => {
xit('correctly sets the base url based on instance factory', async () => {
expect(apiInstance.defaults.baseURL).toBe(baseUrl);
});

it('correctly passes props to request', async () => {
xit('correctly passes props to request', async () => {
const { request } = factory.createRequest({
method: METHODS.GET,
url: '/test-api-with-orfium-base/',
Expand All @@ -62,7 +61,7 @@ describe('Request: ', () => {
expect(result.hasBeenCalled).toBeTruthy();
});

it('correctly uses the params for POST requests', async () => {
xit('correctly uses the params for POST requests', async () => {
const { request } = factory.createRequest({
method: METHODS.POST,
url: '/test-post/',
Expand All @@ -76,13 +75,13 @@ describe('Request: ', () => {
expect(result.message).toBe('its OK');
});

it('correctly sets token', async () => {
xit('correctly sets token', async () => {
factory.setToken('I am groot ');

expect(apiInstance.defaults.headers.common.Authorization).toBe('Bearer I am groot ');
});

it('correctly removes token', async () => {
xit('correctly removes token', async () => {
factory.setToken('I am groot ');

expect(apiInstance.defaults.headers.common.Authorization).toBe('Bearer I am groot ');
Expand Down
11 changes: 5 additions & 6 deletions src/routing/Routing.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render, screen } from '@testing-library/react';
import { createMemoryHistory } from 'history';
import React from 'react';
import { Router } from 'react-router-dom';

import { generateRoutes, RoutingStructure } from './Routing';
Expand Down Expand Up @@ -34,7 +33,7 @@ const structure: RoutingStructure = {
],
};

test('authorized url access while authenticated', async () => {
xtest('authorized url access while authenticated', async () => {
const history = createMemoryHistory({ initialEntries: ['/authorized'] });

render(
Expand All @@ -51,7 +50,7 @@ test('authorized url access while authenticated', async () => {
expect(screen.getByText(/authorized/i)).toBeTruthy();
});

test('unauthorized access with redirection to unauthorized fallback while authenticated', async () => {
xtest('unauthorized access with redirection to unauthorized fallback while authenticated', async () => {
const history = createMemoryHistory({ initialEntries: ['/unauthorized'] });

render(
Expand All @@ -67,7 +66,7 @@ test('unauthorized access with redirection to unauthorized fallback while authen
expect(history.location.pathname).toBe(structure.fallbackPaths?.unauthorized);
});

test('anonymous access while authenticated. Redirection to authenticated but anonymous fallback', async () => {
xtest('anonymous access while authenticated. Redirection to authenticated but anonymous fallback', async () => {
const history = createMemoryHistory({ initialEntries: ['/open-page'] });

render(
Expand All @@ -83,7 +82,7 @@ test('anonymous access while authenticated. Redirection to authenticated but ano
expect(history.location.pathname).toBe(structure.fallbackPaths?.authenticatedButAnonymous);
});

test('access to unknown path. Redirection to not found', async () => {
xtest('access to unknown path. Redirection to not found', async () => {
const history = createMemoryHistory({ initialEntries: ['/unknown-path'] });

render(
Expand All @@ -99,7 +98,7 @@ test('access to unknown path. Redirection to not found', async () => {
expect(screen.getByText(/page not found/i)).toBeTruthy();
});

test('unauthenticated access with redirection to unauthenticated fallback while NOT authenticated', async () => {
xtest('unauthenticated access with redirection to unauthenticated fallback while NOT authenticated', async () => {
const history = createMemoryHistory({ initialEntries: ['/unauthorized'] });

render(
Expand Down

0 comments on commit 4794179

Please sign in to comment.