Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Load user personnel data into portal #1088

Merged
merged 19 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export SESSION_DOMAIN=localhost
##############################
export KEYSTONE_URL=http://localhost:3001

##############################
# Personnel API Config #
##############################
export PERSONNEL_API_URL=http://localhost:4000

###################################
# Database/Services Configuration #
###################################
Expand Down
1 change: 1 addition & 0 deletions docker-compose.client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
- MONGO_URL=mongodb://mongo:27017
- SAML_IDP_METADATA_URL=http://idp:8080/simplesaml/saml2/idp/metadata.php
- KEYSTONE_URL=http://keystone-cms:3001
- PERSONNEL_API_URL=http://personnel-api:4000
# same as set by .envrc
- SAML_ISSUER
- SESSION_SECRET
Expand Down
24 changes: 23 additions & 1 deletion src/__fixtures__/authUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const mockFeaturedShortcuts: Widget = {
type: 'FeaturedShortcuts',
}

export const testUser1: SessionUser = {
export const testUser1Session = {
userId: 'BERNADETTE.CAMPBELL.5244446289@testusers.cce.af.mil',
issuer: 'http://localhost:8080/simplesaml/saml2/idp/metadata.php',
nameID: '_9c9d48b40112e0d39413d937f9d3a940420d719fbb',
Expand All @@ -39,6 +39,28 @@ export const testUser1: SessionUser = {
},
}

export const testUser1Personnel = {
personnelData: {
Grade: '1',
DUTYTITLE: 'ANALYST',
DOD_ID: '5244446289',
MAJCOM: 'UNITED STATES SPACE FORCE FORCES (6F)',
Country: 'CALIFORNIA',
BASE_LOC: 'VANDENBERG',
Org_type: 'SQUADRON',
EOPDate: '1682812800000',
Last_Name: 'CAMPBELL',
First_name: 'BERNADETTE',
userType: 'Enlisted',
lastModifiedAt: '2023-08-28T14:39:06.732-07:00',
},
}

export const testUser1: SessionUser = {
...testUser1Session,
...testUser1Personnel,
}

export const testPortalUser1: PortalUser = {
userId: 'BERNADETTE.CAMPBELL.5244446289@testusers.cce.af.mil',
mySpace: [
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/pages/404.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ beforeEach(() => {
return {
user: testUser1,
portalUser: testPortalUser1,
loading: false
loading: false,
}
})
})
Expand All @@ -25,7 +25,7 @@ describe('404 page', () => {
return {
user: null,
portalUser: null,
loading: true
loading: true,
}
})
renderWithAuth(<Custom404 />, {})
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/pages/about-us/orbit-blog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ beforeEach(() => {
return {
user: testUser1,
portalUser: testPortalUser1,
loading: false
loading: false,
}
})
})
Expand Down Expand Up @@ -91,8 +91,8 @@ describe('ORBIT Blog page', () => {
jest.spyOn(useUserHooks, 'useUser').mockImplementation(() => {
return {
user: null,
portalUser: null,
loading: true
portalUser: null,
loading: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what is happening with all of these formatted commas in files I did not even touch 🤨

}
})

Expand Down
5 changes: 2 additions & 3 deletions src/__tests__/pages/announcements.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ jest.mock('../../lib/keystoneClient', () => ({
}))

describe('Announcements page', () => {

beforeEach(() => {
jest.spyOn(useUserHooks, 'useUser').mockImplementation(() => {
return {
user: testUser1,
portalUser: testPortalUser1,
loading: false
loading: false,
}
})
})
Expand All @@ -41,7 +40,7 @@ describe('Announcements page', () => {
return {
user: null,
portalUser: null,
loading: true
loading: true,
}
})

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/pages/article.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ beforeEach(() => {
return {
user: testUser1,
portalUser: testPortalUser1,
loading: false
loading: false,
}
})
})
Expand Down Expand Up @@ -180,7 +180,7 @@ describe('Single article page', () => {
return {
user: null,
portalUser: null,
loading: true
loading: true,
}
})
renderWithAuth(<SingleArticlePage article={mockOrbitBlogArticle} />, {})
Expand Down
9 changes: 6 additions & 3 deletions src/__tests__/pages/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import {
renderWithAuthAndApollo,
renderWithMySpaceAndModalContext,
} from '../../testHelpers'
import { testUser1, portalUserMaxedOutCollection } from '../../__fixtures__/authUsers'
import {
testUser1,
portalUserMaxedOutCollection,
} from '../../__fixtures__/authUsers'

import { cmsBookmarksMock as mockCmsBookmarks } from '../../__fixtures__/data/cmsBookmarks'
import { cmsAnnouncementsMock as mockCmsAnnouncements } from '../../__fixtures__/data/cmsAnnouncments'
Expand All @@ -36,7 +39,7 @@ beforeEach(() => {
return {
user: testUser1,
portalUser: portalUserMaxedOutCollection,
loading: false
loading: false,
}
})
})
Expand All @@ -48,7 +51,7 @@ describe('Home page', () => {
return {
user: null,
portalUser: null,
loading: true
loading: true,
}
})

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/pages/news-announcements.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ beforeEach(() => {
return {
user: testUser1,
portalUser: testPortalUser1,
loading: false
loading: false,
}
})
})
Expand All @@ -75,7 +75,7 @@ describe('News page', () => {
return {
user: null,
portalUser: null,
loading: true
loading: true,
}
})

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/pages/search.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ beforeEach(() => {
return {
user: testUser1,
portalUser: testPortalUser1,
loading: false
loading: false,
}
})
})
Expand Down Expand Up @@ -99,7 +99,7 @@ describe('Search page', () => {
return {
user: null,
portalUser: null,
loading: true
loading: true,
}
})
renderWithAuth(<SearchPage />, {})
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/pages/settings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ beforeEach(() => {
return {
user: testUser1,
portalUser: testPortalUser1,
loading: false
loading: false,
}
})
})
Expand All @@ -27,7 +27,7 @@ describe('Settings page', () => {
return {
user: null,
portalUser: null,
loading: true
loading: true,
}
})
renderWithAuthAndApollo(<Settings />)
Expand Down
16 changes: 8 additions & 8 deletions src/__tests__/pages/sites-and-applications.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ beforeEach(() => {
return {
user: testUser1,
portalUser: portalUserWithExampleCollection,
loading: false
loading: false,
}
})
})
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('Sites and Applications page', () => {
return {
user: null,
portalUser: null,
loading: true
loading: true,
}
})

Expand Down Expand Up @@ -358,7 +358,7 @@ describe('Sites and Applications page', () => {
return {
user: testUser1,
portalUser: portalUserAlmostAtCollectionLimit,
loading: false
loading: false,
}
})

Expand Down Expand Up @@ -435,7 +435,7 @@ describe('Sites and Applications page', () => {
return {
user: testUser1,
portalUser: portalUserCollectionLimit,
loading: false
loading: false,
}
})

Expand Down Expand Up @@ -609,12 +609,12 @@ describe('Sites and Applications page', () => {
const user = userEvent.setup({
advanceTimers: jest.advanceTimersByTime,
})

jest.spyOn(useUserHooks, 'useUser').mockImplementation(() => {
return {
user: testUser1,
portalUser: portalUserMaxedOutCollection,
loading: false
loading: false,
}
})

Expand Down Expand Up @@ -732,7 +732,7 @@ describe('Sites and Applications page', () => {
return {
user: testUser1,
portalUser: portalUserCollectionLimit,
loading: false
loading: false,
}
})

Expand All @@ -757,7 +757,7 @@ describe('Sites and Applications page', () => {
return {
user: testUser1,
portalUser: portalUserCollectionLimit,
loading: false
loading: false,
}
})

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/pages/ussf-documentation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ beforeEach(() => {
return {
user: testUser1,
portalUser: testPortalUser1,
loading: false
loading: false,
}
})
})
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('USSF Documentation page', () => {
return {
user: null,
portalUser: null,
loading: true
loading: true,
}
})
renderWithAuthAndApollo(
Expand Down
16 changes: 8 additions & 8 deletions src/components/ThemeToggle/ThemeToggle.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ beforeEach(() => {
return {
user: testUser1,
portalUser: testPortalUser1,
loading: false
loading: false,
}
})
})

describe('ThemeToggle component', () => {
test('renders nothing if no user', async () => {
jest.spyOn(useUserHooks, 'useUser').mockImplementation(() => {
return {
user: null,
portalUser: null,
loading: true,
}
})
jest.spyOn(useUserHooks, 'useUser').mockImplementation(() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more formatting weirdness in test files 🥲

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So many, I wonder how all these were missed? Maybe we got a new version of prettier that does a better job?

return {
user: null,
portalUser: null,
loading: true,
}
})
renderWithAuthAndApollo(<ThemeToggle />, {})

expect(screen.queryByTestId('theme-toggle')).toBeNull()
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useRSSFeed.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ describe('useRSSFeed hook', () => {
})

test('logs the error if the RSS fetch fails', async () => {
const consoleSpy = jest.spyOn(console, 'error').mockImplementation(jest.fn())
const consoleSpy = jest
.spyOn(console, 'error')
.mockImplementation(jest.fn())

mockedAxios.get.mockRejectedValueOnce(new Error('Error fetching RSS'))

Expand Down
Loading