Skip to content

Commit

Permalink
Test corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
asanchezr committed Jan 17, 2024
1 parent 51020d3 commit 3b517ed
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 51 deletions.
10 changes: 5 additions & 5 deletions source/frontend/src/features/account/Login.test.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useKeycloak } from '@react-keycloak/web';
import { cleanup, fireEvent, render } from '@testing-library/react';
import { createMemoryHistory, MemoryHistory } from 'history';
import React from 'react';
import { Provider } from 'react-redux';
import { Router } from 'react-router-dom';
import renderer from 'react-test-renderer';
import configureMockStore, { MockStoreEnhanced } from 'redux-mock-store';
import thunk from 'redux-thunk';
import { ThemeProvider } from 'styled-components';

import { Roles } from '@/constants';
import { ADD_ACTIVATE_USER } from '@/constants/actionTypes';
import { mockLookups } from '@/mocks/index.mock';
import { lookupCodesSlice } from '@/store/slices/lookupCodes';
Expand Down Expand Up @@ -77,17 +77,17 @@ describe('login', () => {
it('authenticated users are redirected to the mapview', () => {
process.env.REACT_APP_TENANT = 'MOTI';
(useKeycloak as jest.Mock).mockReturnValue({
keycloak: { authenticated: true, userInfo: { client_roles: ['System Administrator'] } },
keycloak: { authenticated: true, userInfo: { client_roles: [Roles.SYSTEM_ADMINISTRATOR] } },
});
const history = createMemoryHistory();
render(<TestLogin history={history} />);
expect(history.location.pathname).toBe('/mapview');
});

it('authenticated finance users are redirected to the lease list', () => {
it('authenticated lease functional users are redirected to the lease list', () => {
process.env.REACT_APP_TENANT = 'MOTI';
(useKeycloak as jest.Mock).mockReturnValue({
keycloak: { authenticated: true, userInfo: { client_roles: ['Finance'] } },
keycloak: { authenticated: true, userInfo: { client_roles: [Roles.LEASE_FUNCTIONAL] } },
});
const history = createMemoryHistory();
render(<TestLogin history={history} />);
Expand All @@ -97,7 +97,7 @@ describe('login', () => {
it('new users are sent to the guest page', () => {
process.env.REACT_APP_TENANT = 'MOTI';
(useKeycloak as jest.Mock).mockReturnValue({
keycloak: { authenticated: true, realmAccess: { client_roles: [{}] } },
keycloak: { authenticated: true, realmAccess: { client_roles: [] } },
});
const history = createMemoryHistory();
const activatedAction: IGenericNetworkAction = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,45 +479,87 @@ exports[`AccessRequestContainer component makes a request based on the access re
</option>
<option
class="option"
data-testid="select-option-6"
value="6"
data-testid="select-option-3"
value="3"
>
Finance
Acquisition functional
</option>
<option
class="option"
data-testid="select-option-7"
value="7"
data-testid="select-option-4"
value="4"
>
Functional
Acquisition read-only
</option>
<option
class="option"
data-testid="select-option-8"
value="8"
data-testid="select-option-25"
value="25"
>
Functional (Restricted)
Disposition functional
</option>
<option
class="option"
data-testid="select-option-10"
value="10"
data-testid="select-option-26"
value="26"
>
Management functional
Disposition read-only
</option>
<option
class="option"
data-testid="select-option-5"
value="5"
>
Lease/License functional
</option>
<option
class="option"
data-testid="select-option-6"
value="6"
>
Lease/License read-only
</option>
<option
class="option"
data-testid="select-option-11"
value="11"
>
Management functional
</option>
<option
class="option"
data-testid="select-option-12"
value="12"
>
Management read-only
</option>
<option
class="option"
data-testid="select-option-7"
value="7"
>
Project functional
</option>
<option
class="option"
data-testid="select-option-8"
value="8"
>
Project read-only
</option>
<option
class="option"
data-testid="select-option-9"
value="9"
>
Read Only
Research functional
</option>
<option
class="option"
data-testid="select-option-10"
value="10"
>
Research read-only
</option>
</select>
</div>
Expand Down Expand Up @@ -1160,45 +1202,87 @@ exports[`AccessRequestContainer component makes a request when no id is provided
</option>
<option
class="option"
data-testid="select-option-6"
value="6"
data-testid="select-option-3"
value="3"
>
Finance
Acquisition functional
</option>
<option
class="option"
data-testid="select-option-7"
value="7"
data-testid="select-option-4"
value="4"
>
Functional
Acquisition read-only
</option>
<option
class="option"
data-testid="select-option-8"
value="8"
data-testid="select-option-25"
value="25"
>
Functional (Restricted)
Disposition functional
</option>
<option
class="option"
data-testid="select-option-10"
value="10"
data-testid="select-option-26"
value="26"
>
Management functional
Disposition read-only
</option>
<option
class="option"
data-testid="select-option-5"
value="5"
>
Lease/License functional
</option>
<option
class="option"
data-testid="select-option-6"
value="6"
>
Lease/License read-only
</option>
<option
class="option"
data-testid="select-option-11"
value="11"
>
Management functional
</option>
<option
class="option"
data-testid="select-option-12"
value="12"
>
Management read-only
</option>
<option
class="option"
data-testid="select-option-7"
value="7"
>
Project functional
</option>
<option
class="option"
data-testid="select-option-8"
value="8"
>
Project read-only
</option>
<option
class="option"
data-testid="select-option-9"
value="9"
>
Read Only
Research functional
</option>
<option
class="option"
data-testid="select-option-10"
value="10"
>
Research read-only
</option>
</select>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,45 +473,87 @@ exports[`AccessRequestForm component renders as expected 1`] = `
</option>
<option
class="option"
data-testid="select-option-6"
value="6"
data-testid="select-option-3"
value="3"
>
Finance
Acquisition functional
</option>
<option
class="option"
data-testid="select-option-7"
value="7"
data-testid="select-option-4"
value="4"
>
Functional
Acquisition read-only
</option>
<option
class="option"
data-testid="select-option-8"
value="8"
data-testid="select-option-25"
value="25"
>
Functional (Restricted)
Disposition functional
</option>
<option
class="option"
data-testid="select-option-10"
value="10"
data-testid="select-option-26"
value="26"
>
Management functional
Disposition read-only
</option>
<option
class="option"
data-testid="select-option-5"
value="5"
>
Lease/License functional
</option>
<option
class="option"
data-testid="select-option-6"
value="6"
>
Lease/License read-only
</option>
<option
class="option"
data-testid="select-option-11"
value="11"
>
Management functional
</option>
<option
class="option"
data-testid="select-option-12"
value="12"
>
Management read-only
</option>
<option
class="option"
data-testid="select-option-7"
value="7"
>
Project functional
</option>
<option
class="option"
data-testid="select-option-8"
value="8"
>
Project read-only
</option>
<option
class="option"
data-testid="select-option-9"
value="9"
>
Read Only
Research functional
</option>
<option
class="option"
data-testid="select-option-10"
value="10"
>
Research read-only
</option>
</select>
</div>
Expand Down
Loading

0 comments on commit 3b517ed

Please sign in to comment.