From 61977ae1ca2959676f58fee4c399b701374cd7b6 Mon Sep 17 00:00:00 2001 From: "Mr. Singleton" Date: Fri, 13 Oct 2023 08:58:10 -0400 Subject: [PATCH] removed duplicate submit email component and added source to props update tests --- src/components/BusinessCard.tsx | 2 +- .../ResumeBioSection.test.jsx | 23 +++++ .../my-digital-resume/ResumeBioSection.tsx | 6 +- .../my-digital-resume/ResumeSocialMedia.tsx | 4 +- .../pages/BusinessCardSubmitEmail.test.jsx | 4 +- .../pages/BusinessCardSubmitEmail.tsx | 5 +- .../transform-hw/pages/SubmitEmail.tsx | 96 ------------------- .../UnderConstruction.tsx | 4 +- .../digital-resume/SubmitEmail.stories.tsx | 2 +- 9 files changed, 38 insertions(+), 108 deletions(-) create mode 100644 src/components/my-digital-resume/ResumeBioSection.test.jsx delete mode 100644 src/components/transform-hw/pages/SubmitEmail.tsx diff --git a/src/components/BusinessCard.tsx b/src/components/BusinessCard.tsx index 4e056d4f..d0a92d09 100644 --- a/src/components/BusinessCard.tsx +++ b/src/components/BusinessCard.tsx @@ -266,7 +266,7 @@ const BusinessCard: FunctionComponent = ({anchor, homePage}) => { - diff --git a/src/components/my-digital-resume/ResumeBioSection.test.jsx b/src/components/my-digital-resume/ResumeBioSection.test.jsx new file mode 100644 index 00000000..a996fcdd --- /dev/null +++ b/src/components/my-digital-resume/ResumeBioSection.test.jsx @@ -0,0 +1,23 @@ +import {render, screen} from '@testing-library/react'; +import expect from "expect"; +import {ResumeBioSectionComplete} from "../../stories/digital-resume/ResumeBio.stories"; + +describe('Resume Bio Section', () => { + test('renders all components of bio', async () => { + render() + + expect(await screen.findAllByRole('button')).toHaveLength(1) + expect(await screen.findAllByRole('link')).toHaveLength(8) + expect(screen.getByTestId('bio-image')).toBeInTheDocument() + expect(screen.getByTestId('social-media-block')).toBeInTheDocument() + expect(screen.getByTestId('submit-email-block')).toBeInTheDocument() + expect((await screen.findByText('Contact Me'))).toBeInTheDocument() + expect((await screen.findByText('Meet with Me'))).toBeInTheDocument() + expect((await screen.findByText('Download Resume'))).toBeInTheDocument() + expect(await screen.findByText('James Terrell Singleton')).toBeInTheDocument() + expect(await screen.findByText('I am a Web Developer located in the Maryand, District of Columbia, and Virginia Metropolitan area. I currently work as a remote fullstack software engineer for Assembled Financial, located in Los Angeles, CA. I am looking to take on more work, to increase my skills as a Web Developer, and to make things that are great. I am open to relocation.')).toBeInTheDocument() + expect(await screen.findByText('443.992.2191')).toBeInTheDocument() + expect(await screen.findByText('terrell.singleton@gmail.com')).toBeInTheDocument() + expect(await screen.findByText('7300 Roselynn Lane, Clinton, MD 20735')).toBeInTheDocument() + }); +}) diff --git a/src/components/my-digital-resume/ResumeBioSection.tsx b/src/components/my-digital-resume/ResumeBioSection.tsx index 031b619e..ef4b0301 100644 --- a/src/components/my-digital-resume/ResumeBioSection.tsx +++ b/src/components/my-digital-resume/ResumeBioSection.tsx @@ -24,7 +24,9 @@ const ResumeBioSection: FunctionComponent = (props: IProps) => { - @@ -65,7 +67,7 @@ const ResumeBioSection: FunctionComponent = (props: IProps) => { /> - = (props: IProps) => { const classes = useStyles() return ( - - + {props.facebook && diff --git a/src/components/transform-hw/pages/BusinessCardSubmitEmail.test.jsx b/src/components/transform-hw/pages/BusinessCardSubmitEmail.test.jsx index 30bd3bb6..19473e14 100644 --- a/src/components/transform-hw/pages/BusinessCardSubmitEmail.test.jsx +++ b/src/components/transform-hw/pages/BusinessCardSubmitEmail.test.jsx @@ -56,7 +56,7 @@ describe('Business Card Submit Email', () => { expect(leadClient.sendBusinessCardEmail).toHaveBeenCalledTimes(1) expect(leadClient.sendBusinessCardEmail).toHaveBeenCalledWith({ "email": 'terrell@gmail.com', - source: "Business Card" + source: "storybook" }) expect(screen.getByText('Thank you for your submission!')).toBeInTheDocument() }); @@ -126,7 +126,7 @@ describe('Business Card Submit Email', () => { expect(leadClient.sendBusinessCardEmail).toHaveBeenCalledTimes(1) expect(leadClient.sendBusinessCardEmail).toHaveBeenCalledWith({ "email": 'terrell@gmail.com', - source: "Business Card" + source: "storybook" }) expect(screen.queryByText('Thank you for your submission!')).not.toBeInTheDocument() expect(screen.getByText('Please Try your submission again later or contact hello@thehandsomestnerd.com.')).toBeInTheDocument() diff --git a/src/components/transform-hw/pages/BusinessCardSubmitEmail.tsx b/src/components/transform-hw/pages/BusinessCardSubmitEmail.tsx index c1a318c0..729191e6 100644 --- a/src/components/transform-hw/pages/BusinessCardSubmitEmail.tsx +++ b/src/components/transform-hw/pages/BusinessCardSubmitEmail.tsx @@ -41,6 +41,7 @@ export interface SubmitEmailIProps { emailFieldText: string emailButtonText: string subscribeText: string + source: string } const BusinessCardSubmitEmail: FunctionComponent = (props: SubmitEmailIProps) => { @@ -57,7 +58,7 @@ const BusinessCardSubmitEmail: FunctionComponent = (props: Su setIsLoading(true) setIsError(false) - const response = await leadClient.sendBusinessCardEmail({email, source: "Business Card"}); + const response = await leadClient.sendBusinessCardEmail({email, source: props.source}); console.log(response) if (response.status === "400") { @@ -99,7 +100,7 @@ const BusinessCardSubmitEmail: FunctionComponent = (props: Su } - return ( + return ( ({ - root: {}, -})) - -interface IProps { - emailFieldText: string - emailButtonText: string - subscribeText: string -} - -const SubmitEmail: FunctionComponent = (props: IProps) => { - const theme = useTheme() - const classes = useCustomStyles(TheWebsiteTheme -) - const [email, setEmail] = useState("") - - const {isLoading, isError, data, refetch} = useQuery( - ['createLead'], - () => { - if ((!data && !isError) && email && email.length > 0) { - return leadClient.createLead({email, source: "Coming Soon Page"}); - } - return undefined - } - ); - - const createLead = async (e: any): Promise => { - return refetch() - } - - const getHelperText = () => { - if ((data || isError) && !isEmail(email)) { - return This is not a - valid email address. - } - - if (data) { - return Thank you for - your submission! - } - if (isError) { - return Please Try your - submission again later or contact jgreene@transformHW.org. - } - - return   - } - - - return ( - - {props.subscribeText} - - - ) => { - setEmail(event.target.value) - }} - className={classes.endAdornedInput} - InputProps={{ - endAdornment: - 0) && !isEmail(email)))} - clickHandler={createLead} - color='primary' - variant='contained'>{props.emailButtonText} - , - }}/> - - - {getHelperText()} - ) -} - -export default SubmitEmail \ No newline at end of file diff --git a/src/components/transform-hw/pages/under-construction-page/UnderConstruction.tsx b/src/components/transform-hw/pages/under-construction-page/UnderConstruction.tsx index 440a538a..dcfb05bf 100644 --- a/src/components/transform-hw/pages/under-construction-page/UnderConstruction.tsx +++ b/src/components/transform-hw/pages/under-construction-page/UnderConstruction.tsx @@ -6,12 +6,12 @@ import clsx from "clsx"; import CssFadeToColor from "../../../css-fade-to-color/CssFadeToColor"; import {SanityRef, SanityUnderConstructionPageType} from "../../../../common/sanityIo/Types"; import cmsClient from "../../../block-content-ui/cmsClient"; -import SubmitEmail from "../SubmitEmail"; import Logo from "../../../logo/Logo"; import {urlFor} from "../../../block-content-ui/static-pages/cmsStaticPagesClient"; import MailTo from "../../../mail-to/MailTo"; import {COLORS} from "../../../../theme/common/ColorPalette"; import CustomizedThemeContext from "../../../customized-theme-provider/CustomizedThemeContext"; +import BusinessCardSubmitEmail from "../BusinessCardSubmitEmail"; interface IProps { email?: string @@ -84,7 +84,7 @@ const UnderConstruction: FunctionComponent = (props) => { - diff --git a/src/stories/digital-resume/SubmitEmail.stories.tsx b/src/stories/digital-resume/SubmitEmail.stories.tsx index 6a633ff5..060cabaa 100644 --- a/src/stories/digital-resume/SubmitEmail.stories.tsx +++ b/src/stories/digital-resume/SubmitEmail.stories.tsx @@ -25,7 +25,7 @@ export const BusinessCardSubmitEmailStory: Story = { subscribeText: "Want a copy of my resume emailed to you?" }, render: ({emailFieldText, emailButtonText, subscribeText}: PropsWithChildren) => - , }; \ No newline at end of file