+
Please enter your information to request access from an OFA
administrator
@@ -172,6 +178,55 @@ function Home() {
handleBlur={handleBlur}
/>
{shouldShowSttComboBox && (
+
+ )}
+ {jurisdictionType && shouldShowSttComboBox && (
)}
diff --git a/tdrs-frontend/src/components/Home/Home.test.jsx b/tdrs-frontend/src/components/Home/Home.test.jsx
index 0d85cd65a..a58904d50 100644
--- a/tdrs-frontend/src/components/Home/Home.test.jsx
+++ b/tdrs-frontend/src/components/Home/Home.test.jsx
@@ -256,6 +256,12 @@ describe('Pre-approval Home page', () => {
code: 'AK',
name: 'Aleutian/Pribilof Islands Association, Inc.',
},
+ {
+ id: 1111,
+ type: 'territory',
+ code: 'G',
+ name: 'Guam',
+ },
],
},
})
@@ -267,7 +273,101 @@ describe('Pre-approval Home page', () => {
const options = wrapper.find('option')
- expect(options.length).toEqual(4)
+ expect(options.length).toEqual(3)
+ })
+
+ it('should mount a list of tribe options based on stts from the store', () => {
+ const store = mockStore({
+ ...initialState,
+ stts: {
+ sttList: [
+ {
+ id: 1,
+ type: 'state',
+ code: 'AL',
+ name: 'Alabama',
+ },
+ {
+ id: 2,
+ type: 'state',
+ code: 'AK',
+ name: 'Alaska',
+ },
+ {
+ id: 140,
+ type: 'tribe',
+ code: 'AK',
+ name: 'Aleutian/Pribilof Islands Association, Inc.',
+ },
+ {
+ id: 1111,
+ type: 'territory',
+ code: 'G',
+ name: 'Guam',
+ },
+ ],
+ },
+ })
+ const wrapper = mount(
+
+
+
+ )
+
+ const radio = wrapper.find('#tribe')
+ radio.simulate('change', {
+ target: { name: 'jurisdictionType', value: 'tribe' },
+ })
+
+ const options = wrapper.find('option')
+ expect(options.length).toEqual(2)
+ })
+
+ it('should mount a list of territory options based on stts from the store', () => {
+ const store = mockStore({
+ ...initialState,
+ stts: {
+ sttList: [
+ {
+ id: 1,
+ type: 'state',
+ code: 'AL',
+ name: 'Alabama',
+ },
+ {
+ id: 2,
+ type: 'state',
+ code: 'AK',
+ name: 'Alaska',
+ },
+ {
+ id: 140,
+ type: 'tribe',
+ code: 'AK',
+ name: 'Aleutian/Pribilof Islands Association, Inc.',
+ },
+ {
+ id: 1111,
+ type: 'territory',
+ code: 'G',
+ name: 'Guam',
+ },
+ ],
+ },
+ })
+ const wrapper = mount(
+
+
+
+ )
+
+ const radio = wrapper.find('#territory')
+ radio.simulate('change', {
+ target: { name: 'jurisdictionType', value: 'territory' },
+ })
+
+ const options = wrapper.find('option')
+ expect(options.length).toEqual(2)
})
it('should not show the stt combno box for non-STT users', () => {
@@ -330,9 +430,7 @@ describe('Pre-approval Home page', () => {
expect(getByText('First Name is required')).toBeInTheDocument()
expect(getByText('Last Name is required')).toBeInTheDocument()
- expect(
- getByText('A state, tribe, or territory is required')
- ).toBeInTheDocument()
+ expect(getByText('A state is required')).toBeInTheDocument()
})
it('should not require an stt for ofa users', () => {
@@ -379,9 +477,7 @@ describe('Pre-approval Home page', () => {
expect(getByText('First Name is required')).toBeInTheDocument()
expect(getByText('Last Name is required')).toBeInTheDocument()
- expect(
- queryByText('A state, tribe, or territory is required')
- ).not.toBeInTheDocument()
+ expect(queryByText('A state is required')).not.toBeInTheDocument()
})
it('should remove error message when you add a character and blur out of input', () => {
@@ -575,7 +671,7 @@ describe('Pre-approval Home page', () => {
)
- const select = getByLabelText('Associated State, Tribe, or Territory*', {
+ const select = getByLabelText('State*', {
selector: 'input',
})
diff --git a/tdrs-frontend/src/components/STTComboBox/STTComboBox.jsx b/tdrs-frontend/src/components/STTComboBox/STTComboBox.jsx
index 21da77488..d2ed13b80 100644
--- a/tdrs-frontend/src/components/STTComboBox/STTComboBox.jsx
+++ b/tdrs-frontend/src/components/STTComboBox/STTComboBox.jsx
@@ -4,6 +4,7 @@ import { useDispatch, useSelector } from 'react-redux'
import { fetchSttList } from '../../actions/sttList'
import ComboBox from '../ComboBox'
import Modal from '../Modal'
+import { toTitleCase } from '../../utils/stringUtils'
/**
* @param {function} selectStt - Function to reference and change the
@@ -14,7 +15,7 @@ import Modal from '../Modal'
* @param {function} error - Reference to stt errors object.
*/
-function STTComboBox({ selectStt, selectedStt, handleBlur, error }) {
+function STTComboBox({ selectStt, selectedStt, handleBlur, error, sttType }) {
const sttListRequest = useSelector((state) => state?.stts)
const dispatch = useDispatch()
const [numTries, setNumTries] = useState(0)
@@ -45,22 +46,34 @@ function STTComboBox({ selectStt, selectedStt, handleBlur, error }) {
<>
- {sttListRequest.sttList.map((stt) => (
-
- ))}
+ {sttListRequest.sttList.map(
+ (stt) =>
+ (sttType == null || stt.type === sttType) && (
+
+ )
+ )}
+ str &&
+ str.replace(
+ /\w\S*/g,
+ (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()
+ )
diff --git a/tdrs-frontend/src/utils/stringUtils.test.js b/tdrs-frontend/src/utils/stringUtils.test.js
new file mode 100644
index 000000000..307167ce8
--- /dev/null
+++ b/tdrs-frontend/src/utils/stringUtils.test.js
@@ -0,0 +1,14 @@
+import { toTitleCase } from './stringUtils'
+
+describe('toTitleCase', () => {
+ it.each([
+ ['test me', 'Test Me'],
+ ['tribe', 'Tribe'],
+ [' i like peanuts ', ' I Like Peanuts '],
+ ['jeffrey wuz 123here', 'Jeffrey Wuz 123here'],
+ ['', ''],
+ [null, null],
+ ])('Capitalizes first char of each word', (original, expected) => {
+ expect(toTitleCase(original)).toEqual(expected)
+ })
+})