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

Front/119/reports #461

Merged
merged 21 commits into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
552588a
update .env.development with correct non-evaluative times
hilvitzs Dec 8, 2020
e8d6681
make sttList test more complete
hilvitzs Dec 8, 2020
f0c56cd
add NavItem component to be resued in Header, update Header and Heade…
hilvitzs Dec 8, 2020
5e5f5c8
add Reports component
hilvitzs Dec 8, 2020
6995f9b
add upload action and corresponding tests
hilvitzs Dec 8, 2020
9f60c77
update routes with '/reports' and update tests
hilvitzs Dec 8, 2020
50ba4d4
add upload reducer to handle `SET_YEAR` and default to 2020, add test…
hilvitzs Dec 8, 2020
e44655c
Merge branch 'header-title-match' of github.com:raft-tech/TANF-app in…
hilvitzs Dec 8, 2020
966a8c2
remove unnecessary `grid-container` in Reports
hilvitzs Dec 8, 2020
07b9c24
update yarn.lock
hilvitzs Dec 8, 2020
075c44d
Merge branch 'raft-tdp-main' of github.com:raft-tech/TANF-app into fr…
hilvitzs Dec 8, 2020
231bf36
remove dynamic h1 title on Reports
hilvitzs Dec 8, 2020
acf1987
change text NavItem prop to tabTitle and add docs to NavItem
hilvitzs Dec 8, 2020
37dd447
fix EditProfile whitespace
hilvitzs Dec 8, 2020
ca92215
remove pathnameToMatch from NavItem and Header
hilvitzs Dec 10, 2020
af3d1ef
fix header test
hilvitzs Dec 10, 2020
818e0a3
add selectedYear to TANF Report p tag per design request
hilvitzs Dec 11, 2020
d25afba
add documentation to Reports component
hilvitzs Dec 11, 2020
932c532
fix key on NavItem
hilvitzs Dec 11, 2020
812a6b9
rename upload action and reducer to reports for clarity
hilvitzs Dec 17, 2020
50a7e05
fix header.test titles
hilvitzs Dec 18, 2020
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
3 changes: 3 additions & 0 deletions tdrs-frontend/src/actions/sttList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,8 @@ describe('actions/stts.js', () => {
const actions = store.getActions()
expect(actions[0].type).toBe(FETCH_STTS)
expect(actions[1].type).toBe(SET_STTS_ERROR)
expect(actions[1].payload).toStrictEqual({
error: Error({ message: 'something went wrong' }),
})
})
})
5 changes: 5 additions & 0 deletions tdrs-frontend/src/actions/upload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const SET_YEAR = 'SET_YEAR'

export const setYear = (year) => (dispatch) => {
dispatch({ type: SET_YEAR, payload: { year } })
}
19 changes: 19 additions & 0 deletions tdrs-frontend/src/actions/upload.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import thunk from 'redux-thunk'
import configureStore from 'redux-mock-store'

import { setYear, SET_YEAR } from './upload'

describe('actions/setYear', () => {
const mockStore = configureStore([thunk])

it('should dispatch SET_YEAR', async () => {
const store = mockStore()

await store.dispatch(setYear(2020))

const actions = store.getActions()

expect(actions[0].type).toBe(SET_YEAR)
expect(actions[0].payload).toStrictEqual({ year: 2020 })
})
})
126 changes: 63 additions & 63 deletions tdrs-frontend/src/components/EditProfile/EditProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,76 +139,76 @@ function EditProfile() {
return <Redirect to="/request" />
}

return (
<>
<p className="margin-top-1 margin-bottom-4">
Please enter your information to request access from an OFA
administrator
</p>
<form className="usa-form" onSubmit={handleSubmit}>
<div
className={`usa-error-message ${
return (
<>
<p className="margin-top-1 margin-bottom-4">
Please enter your information to request access from an OFA
administrator
</p>
<form className="usa-form" onSubmit={handleSubmit}>
<div
className={`usa-error-message ${
!!Object.keys(errors).length && !!Object.keys(touched).length
? 'display-block'
: 'display-none'
}`}
ref={errorRef}
tabIndex="-1"
role="alert"
>
There are {Object.keys(errors).length} errors in this form
</div>
<FormGroup
error={errors.firstName}
name="firstName"
label="First Name"
inputValue={profileInfo.firstName}
handleChange={handleChange}
handleBlur={handleBlur}
/>
<FormGroup
error={errors.lastName}
name="lastName"
label="Last Name"
inputValue={profileInfo.lastName}
handleChange={handleChange}
handleBlur={handleBlur}
/>
<div
className={`usa-form-group ${
ref={errorRef}
tabIndex="-1"
role="alert"
>
There are {Object.keys(errors).length} errors in this form
</div>
<FormGroup
error={errors.firstName}
name="firstName"
label="First Name"
inputValue={profileInfo.firstName}
handleChange={handleChange}
handleBlur={handleBlur}
/>
<FormGroup
error={errors.lastName}
name="lastName"
label="Last Name"
inputValue={profileInfo.lastName}
handleChange={handleChange}
handleBlur={handleBlur}
/>
<div
className={`usa-form-group ${
errors.stt ? 'usa-form-group--error' : ''
}`}
>
<ComboBox
name="stt"
error={errors.stt}
handleSelect={setStt}
selected={
profileInfo.stt &&
profileInfo.stt.name &&
profileInfo.stt.name.toLowerCase()
}
handleBlur={handleBlur}
placeholder="- Select or Search -"
>
<ComboBox
name="stt"
error={errors.stt}
handleSelect={setStt}
selected={
profileInfo.stt &&
profileInfo.stt.name &&
profileInfo.stt.name.toLowerCase()
}
handleBlur={handleBlur}
placeholder="- Select or Search -"
>
<option value="">Select an STT</option>
{sttList.map((stt) => (
<option
className="sttOption"
key={stt.id}
value={stt.name.toLowerCase()}
>
<option value="">Select an STT</option>
{sttList.map((stt) => (
<option
className="sttOption"
key={stt.id}
value={stt.name.toLowerCase()}
>
{stt.name}
</option>
))}
</ComboBox>
</div>
<Button type="submit" className="width-full request-access-button">
Request Access
</Button>
</form>
</>
)
{stt.name}
</option>
))}
</ComboBox>
</div>
<Button type="submit" className="width-full request-access-button">
Request Access
</Button>
</form>
</>
)
}

export default EditProfile
20 changes: 9 additions & 11 deletions tdrs-frontend/src/components/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useSelector } from 'react-redux'
import closeIcon from 'uswds/dist/img/close.svg'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faSignOutAlt, faUserCircle } from '@fortawesome/free-solid-svg-icons'
import NavItem from '../NavItem/NavItem'

/**
* This component is rendered on every page and contains the navigation bar.
Expand Down Expand Up @@ -41,17 +42,14 @@ function HeaderComp() {
<img src={closeIcon} alt="close" />
</button>
<ul className="usa-nav__primary usa-accordion">
<li className="usa-nav__primary-item">
<a
href="/"
key="welcome"
className={`usa-nav__link ${
pathname === '/edit-profile' ? 'usa-current' : ''
}`}
>
<span>Welcome</span>
</a>
</li>
<NavItem pathname={pathname} tabTitle="Welcome" href="/welcome" />
<NavItem pathname={pathname} tabTitle="Reports" href="/reports" />
<NavItem
pathname={pathname}
tabTitle="Profile"
href="/edit-profile"
/>
<NavItem pathname={pathname} tabTitle="Admin" href="/admin" />
</ul>
<div className="usa-nav__secondary">
<ul className="usa-nav__secondary-links">
Expand Down
114 changes: 107 additions & 7 deletions tdrs-frontend/src/components/Header/Header.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,54 @@ describe('Header', () => {
expect(title).toIncludeText('TANF Data Portal')
})

it('should have a primary navigation', () => {
it('should have a navigation link for Welcome', () => {
const store = mockStore(initialState)
const wrapper = mount(
<Provider store={store}>
<Header />
</Provider>
)
const welcomeLink = wrapper.find('.usa-nav__link')
const welcomeLink = wrapper.find('#welcome')
expect(welcomeLink).toExist()
expect(welcomeLink).toIncludeText('Welcome')
})

it('should have a navigation link for Reports', () => {
const store = mockStore(initialState)
const wrapper = mount(
<Provider store={store}>
<Header />
</Provider>
)
const reportsLink = wrapper.find('#reports')
expect(reportsLink).toExist()
expect(reportsLink).toIncludeText('Reports')
})

it('should have a navigation link for Profile', () => {
const store = mockStore(initialState)
const wrapper = mount(
<Provider store={store}>
<Header />
</Provider>
)
const profileLink = wrapper.find('#profile')
expect(profileLink).toExist()
expect(profileLink).toIncludeText('Profile')
})

it('should have a navigation link for Admin', () => {
const store = mockStore(initialState)
const wrapper = mount(
<Provider store={store}>
<Header />
</Provider>
)
const adminLink = wrapper.find('#admin')
expect(adminLink).toExist()
expect(adminLink).toIncludeText('Admin')
})

it('should find menu button', () => {
const store = mockStore(initialState)
const wrapper = mount(
Expand All @@ -49,29 +85,93 @@ describe('Header', () => {
expect(menuBtn).toExist()
})

it("should add usa-current class to Welcome tab when on '/edit-profile'", () => {
const store = mockStore(initialState)
it("should add usa-current class to Welcome tab when on '/welcome'", () => {
const store = mockStore({
...initialState,
router: { location: { pathname: '/welcome' } },
})
const wrapper = mount(
<Provider store={store}>
<Header />
</Provider>
)

const welcomeTab = wrapper.find('.usa-nav__link')
const welcomeTab = wrapper.find('#welcome')

expect(welcomeTab.hasClass('usa-current')).toEqual(true)
})

it("should add usa-current class to Reports tab when on '/reports'", () => {
const store = mockStore({
...initialState,
router: { location: { pathname: '/reports' } },
})
const wrapper = mount(
<Provider store={store}>
<Header />
</Provider>
)

const reportsTab = wrapper.find('#reports')

expect(reportsTab.hasClass('usa-current')).toEqual(true)
})

it("should add usa-current class to Reports tab when on '/reports/*'", () => {
const store = mockStore({
...initialState,
router: { location: { pathname: '/reports/upload' } },
})
const wrapper = mount(
<Provider store={store}>
<Header />
</Provider>
)

const reportsTab = wrapper.find('#reports')

expect(reportsTab.hasClass('usa-current')).toEqual(true)
})

it("should add usa-current class to Profile tab when on '/reports'", () => {
const store = mockStore(initialState)
const wrapper = mount(
<Provider store={store}>
<Header />
</Provider>
)

const profileTab = wrapper.find('#profile')

expect(profileTab.hasClass('usa-current')).toEqual(true)
})

it("should add usa-current class to Admin tab when on '/reports'", () => {
const store = mockStore({
...initialState,
router: { location: { pathname: '/admin' } },
})
const wrapper = mount(
<Provider store={store}>
<Header />
</Provider>
)

const adminTab = wrapper.find('#admin')

expect(adminTab.hasClass('usa-current')).toEqual(true)
})

it("should not add usa-current class to Welcome tab when not on '/edit-profile'", () => {
initialState = { ...initialState, router: { location: '/' } }
initialState = { ...initialState, router: { location: { pathname: '/' } } }
const store = mockStore(initialState)
const wrapper = mount(
<Provider store={store}>
<Header />
</Provider>
)

const welcomeTab = wrapper.find('.usa-nav__link')
const welcomeTab = wrapper.find('#welcome')

expect(welcomeTab.hasClass('usa-current')).toEqual(false)
})
Expand Down
Loading