Skip to content

Commit

Permalink
removes twitter input from apply (Vets-Who-Code#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
axecopfire authored Feb 21, 2023
1 parent 19e2667 commit f3343cf
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 52 deletions.
27 changes: 0 additions & 27 deletions src/components/Forms/ApplyForm/ApplyForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,33 +315,6 @@ function ApplyForm() {
<FormAlert errorMessage={errors.yearSeparated.message} />
)}
</div>
<div className="col-md-8">
<div className="form-group">
<label htmlFor="twitterAccountName" className="dark-text">
Twitter Profile URL<sup>*</sup>
</label>
<input
className="form-control input-lg"
id="twitterAccountName"
name="twitterAccountName"
placeholder="Twitter Profile URL"
type="text"
ref={register({
required: true,
pattern: {
value: /http(s)?:\/\/(.*\.)?twitter\.com\/[A-z0-9_]+\/?/,
message: 'Please enter a valid twitter account url',
},
})}
/>
</div>
{errors.twitterAccountName && errors.twitterAccountName.type === 'required' && (
<FormAlert />
)}
{errors.twitterAccountName && errors.twitterAccountName.type === 'pattern' && (
<FormAlert errorMessage={errors.twitterAccountName.message} />
)}
</div>
<div className="col-md-8">
<div className="form-group">
<label htmlFor="linkedInAccountName" className="dark-text">
Expand Down
3 changes: 0 additions & 3 deletions src/pages/api/apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default async function handler(req, res) {
branchOfService,
yearJoined,
yearSeparated,
twitterAccountName,
linkedInAccountName,
githubAccountName,
preworkLink,
Expand All @@ -32,7 +31,6 @@ export default async function handler(req, res) {
'branchOfService',
'yearJoined',
'yearSeparated',
'twitterAccountName',
'linkedInAccountName',
'githubAccountName',
'preworkLink',
Expand All @@ -59,7 +57,6 @@ export default async function handler(req, res) {
`\nBranch of Service: \`${branchOfService}\``,
`\nYear Joined: \`${yearJoined}\``,
`\nYear Separated: \`${yearSeparated}\``,
`\nTwitter Account Name: \`${twitterAccountName}\``,
`\nLinkedIn Account Name: \`${linkedInAccountName}\``,
`\nGithub Account Name: \`${githubAccountName}\``,
`\nPre Work Link: \`${preworkLink}\``,
Expand Down
3 changes: 0 additions & 3 deletions tests/api/apply.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe('contact handler', () => {
branchOfService: 'All of them',
yearJoined: '1990',
yearSeparated: '1990',
twitterAccountName: '@mrstealyoursignificantother',
linkedInAccountName: 'https://linkedin.com/in/mrstealyoursignificantother',
githubAccountName: 'https://linkedin.com/in/mrstealyoursignificantother',
preworkLink: "https://I-didn't-do-the-work",
Expand Down Expand Up @@ -47,7 +46,6 @@ describe('contact handler', () => {
branchOfService: 'All of them',
yearJoined: '1990',
yearSeparated: '1990',
twitterAccountName: '@mrstealyoursignificantother',
linkedInAccountName: 'https://linkedin.com/in/mrstealyoursignificantother',
githubAccountName: 'https://linkedin.com/in/mrstealyoursignificantother',
preworkLink: "https://I-didn't-do-the-work",
Expand Down Expand Up @@ -87,7 +85,6 @@ describe('contact handler', () => {
branchOfService: 'All of them',
yearJoined: '1990',
yearSeparated: '1990',
twitterAccountName: '@mrstealyoursignificantother',
linkedInAccountName: 'https://linkedin.com/in/mrstealyoursignificantother',
githubAccountName: 'https://linkedin.com/in/mrstealyoursignificantother',
preworkLink: "https://I-didn't-do-the-work",
Expand Down
26 changes: 7 additions & 19 deletions tests/components/Forms/ApplyForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ describe('<ApplyForm />', () => {
const branchOfService = container.querySelector('#branchOfService')
const yearJoined = container.querySelector('#yearJoined')
const yearSeparated = container.querySelector('#yearSeparated')
const twitterAccountName = container.querySelector('#twitterAccountName')
const linkedInAccountName = container.querySelector('#linkedInAccountName')
const githubAccountName = container.querySelector('#githubAccountName')
const preworkLink = container.querySelector('#preworkLink')
Expand All @@ -40,7 +39,6 @@ describe('<ApplyForm />', () => {
fireEvent.input(branchOfService, { target: { value: 'USMC' } })
fireEvent.input(yearJoined, { target: { value: 2000 } })
fireEvent.input(yearSeparated, { target: { value: 2004 } })
fireEvent.input(twitterAccountName, { target: { value: 'https://twitter.com/fake-user' } })
fireEvent.input(linkedInAccountName, {
target: { value: 'https://linkedin.com/in/fake-user' },
})
Expand Down Expand Up @@ -77,7 +75,6 @@ describe('<ApplyForm />', () => {
const branchOfService = container.querySelector('#branchOfService')
const yearJoined = container.querySelector('#yearJoined')
const yearSeparated = container.querySelector('#yearSeparated')
const twitterAccountName = container.querySelector('#twitterAccountName')
const linkedInAccountName = container.querySelector('#linkedInAccountName')
const githubAccountName = container.querySelector('#githubAccountName')
const preworkLink = container.querySelector('#preworkLink')
Expand All @@ -94,7 +91,6 @@ describe('<ApplyForm />', () => {
fireEvent.input(branchOfService, { target: { value: 'USMC' } })
fireEvent.input(yearJoined, { target: { value: 2000 } })
fireEvent.input(yearSeparated, { target: { value: 2004 } })
fireEvent.input(twitterAccountName, { target: { value: 'https://twitter.com/fake-user' } })
fireEvent.input(linkedInAccountName, {
target: { value: 'https://linkedin.com/in/fake-user' },
})
Expand Down Expand Up @@ -125,7 +121,6 @@ describe('<ApplyForm />', () => {
const branchOfService = container.querySelector('#branchOfService')
const yearJoined = container.querySelector('#yearJoined')
const yearSeparated = container.querySelector('#yearSeparated')
const twitterAccountName = container.querySelector('#twitterAccountName')
const linkedInAccountName = container.querySelector('#linkedInAccountName')
const githubAccountName = container.querySelector('#githubAccountName')
const preworkLink = container.querySelector('#preworkLink')
Expand All @@ -142,7 +137,6 @@ describe('<ApplyForm />', () => {
fireEvent.input(branchOfService, { target: { value: '' } })
fireEvent.input(yearJoined, { target: { value: '' } })
fireEvent.input(yearSeparated, { target: { value: '' } })
fireEvent.input(twitterAccountName, { target: { value: '' } })
fireEvent.input(linkedInAccountName, {
target: { value: '' },
})
Expand All @@ -154,7 +148,7 @@ describe('<ApplyForm />', () => {

const errorMessages = container.querySelectorAll('.alert-danger')

expect(errorMessages.length).toBe(15)
expect(errorMessages.length).toBe(14)

await waitFor(() => {
fireEvent.input(firstName, { target: { value: 'New' } })
Expand All @@ -167,7 +161,6 @@ describe('<ApplyForm />', () => {
fireEvent.change(branchOfService, { target: { value: 'USMC' } })
fireEvent.input(yearJoined, { target: { value: 2000 } })
fireEvent.input(yearSeparated, { target: { value: 2004 } })
fireEvent.input(twitterAccountName, { target: { value: 'https://twitter.com/fake-user' } })
fireEvent.input(linkedInAccountName, {
target: { value: 'https://linkedin.com/in/fake-user' },
})
Expand All @@ -193,7 +186,6 @@ describe('<ApplyForm />', () => {
const branchOfService = container.querySelector('#branchOfService')
const yearJoined = container.querySelector('#yearJoined')
const yearSeparated = container.querySelector('#yearSeparated')
const twitterAccountName = container.querySelector('#twitterAccountName')
const linkedInAccountName = container.querySelector('#linkedInAccountName')
const githubAccountName = container.querySelector('#githubAccountName')
const preworkLink = container.querySelector('#preworkLink')
Expand All @@ -204,7 +196,7 @@ describe('<ApplyForm />', () => {

const errorMessages = container.querySelectorAll('.alert-danger')

expect(errorMessages.length).toBe(15)
expect(errorMessages.length).toBe(14)

await waitFor(() => {
fireEvent.input(firstName, { target: { value: 'New' } })
Expand All @@ -217,7 +209,6 @@ describe('<ApplyForm />', () => {
fireEvent.change(branchOfService, { target: { value: 'USMC' } })
fireEvent.input(yearJoined, { target: { value: 200 } })
fireEvent.input(yearSeparated, { target: { value: 204 } })
fireEvent.input(twitterAccountName, { target: { value: 'https ://twitter.com/fake-user' } })
fireEvent.input(linkedInAccountName, {
target: { value: 'https ://linkedin.com/in/fake-user' },
})
Expand All @@ -227,7 +218,7 @@ describe('<ApplyForm />', () => {
})

const errorsAfterSubmit = container.querySelectorAll('.alert-danger')
expect(errorsAfterSubmit.length).toBe(9)
expect(errorsAfterSubmit.length).toBe(8)
// valid email
expect(errorsAfterSubmit[0].textContent).toContain('Please enter a valid email address')
// zip-code custom error
Expand All @@ -238,18 +229,16 @@ describe('<ApplyForm />', () => {
expect(errorsAfterSubmit[2].textContent).toContain('Please enter year in YYYY format')
// year separated custom error
expect(errorsAfterSubmit[3].textContent).toContain('Please enter year in YYYY format')
// valid twitter account url
expect(errorsAfterSubmit[4].textContent).toContain('Please enter a valid twitter account url')
// valid linkedin account url
expect(errorsAfterSubmit[5].textContent).toContain(
expect(errorsAfterSubmit[4].textContent).toContain(
'Please enter a valid LinkedIn url https://linkedin.com/in/user-name'
)
// valid github username
expect(errorsAfterSubmit[6].textContent).toContain('Please enter your github username')
expect(errorsAfterSubmit[5].textContent).toContain('Please enter your github username')
// valid prework url
expect(errorsAfterSubmit[7].textContent).toContain('Please enter a valid url')
expect(errorsAfterSubmit[6].textContent).toContain('Please enter a valid url')
// valid github url
expect(errorsAfterSubmit[8].textContent).toContain(
expect(errorsAfterSubmit[7].textContent).toContain(
'Please enter a GitHub repository url https://github.com/user-name/repo-name'
)

Expand All @@ -264,7 +253,6 @@ describe('<ApplyForm />', () => {
fireEvent.input(branchOfService, { target: { value: 'USMC' } })
fireEvent.input(yearJoined, { target: { value: 2000 } })
fireEvent.input(yearSeparated, { target: { value: 2004 } })
fireEvent.input(twitterAccountName, { target: { value: 'https://twitter.com/fake-user' } })
fireEvent.input(linkedInAccountName, {
target: { value: 'https://linkedin.com/in/fake-user' },
})
Expand Down

0 comments on commit f3343cf

Please sign in to comment.