-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add props for error message, update styling and tests, add Newsletter…
…SignupViewType to component export
- Loading branch information
1 parent
a4460e1
commit 2b15b97
Showing
6 changed files
with
456 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,17 @@ const meta: Meta<typeof NewsletterSignup> = { | |
}, | ||
}, | ||
}, | ||
errorHeading: { | ||
control: "text", | ||
table: { | ||
defaultValue: { | ||
summary: "Oops! Something went wrong.", | ||
}, | ||
}, | ||
}, | ||
errorText: { | ||
control: "text", | ||
}, | ||
formHelperText: { | ||
control: "text", | ||
}, | ||
|
@@ -203,7 +214,20 @@ export const ComponentStates: Story = { | |
</Box> | ||
<Box> | ||
<Heading level="h3" size="heading6"> | ||
Error View | ||
Deafult Error View | ||
</Heading> | ||
<NewsletterSignup | ||
id="error-view" | ||
view="error" | ||
onChange={() => {}} | ||
onSubmit={() => {}} | ||
confirmationHeading="Thank you for signing up!" | ||
confirmationText="You can update your email subscription preferences at any time using the links at the bottom of the email." | ||
/> | ||
</Box> | ||
<Box> | ||
<Heading level="h3" size="heading6"> | ||
Error View with Custom Error Message | ||
</Heading> | ||
<NewsletterSignup | ||
id="error-view" | ||
|
@@ -212,6 +236,16 @@ export const ComponentStates: Story = { | |
onSubmit={() => {}} | ||
confirmationHeading="Thank you for signing up!" | ||
confirmationText="You can update your email subscription preferences at any time using the links at the bottom of the email." | ||
errorHeading="An error has occurred." | ||
errorText={ | ||
<div> | ||
Please refresh this page and try again. If this error persists, | ||
<a href="mailto:[email protected]?subject=Please re-activate my e-mail address"> | ||
contact our e-mail team | ||
</a> | ||
. | ||
</div> | ||
} | ||
/> | ||
</Box> | ||
</VStack> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,6 +149,7 @@ describe("NewsletterSignup Unit Tests", () => { | |
it("Renders the Optional descriptionText and formHelperText HTML Values for the Form", () => { | ||
const testNewsletterSignup = ( | ||
<NewsletterSignup | ||
// This link is safe and fun - If you have a moment check it out ;) | ||
descriptionText={ | ||
<div> | ||
Do not send <a href="https://chias.website/">cash</a>. | ||
|
@@ -364,7 +365,7 @@ describe("NewsletterSignup Snapshots", () => { | |
expect(view).toMatchSnapshot(); | ||
}); | ||
|
||
it("Renders the error state snapshot correctly", () => { | ||
it("Renders the default error state snapshot correctly", () => { | ||
const view = renderer | ||
.create( | ||
<NewsletterSignup | ||
|
@@ -380,6 +381,31 @@ describe("NewsletterSignup Snapshots", () => { | |
expect(view).toMatchSnapshot(); | ||
}); | ||
|
||
it("Renders the custom error state snapshot correctly", () => { | ||
const view = renderer | ||
.create( | ||
<NewsletterSignup | ||
onSubmit={onSubmit} | ||
onChange={onChange} | ||
valueEmail={valueEmail} | ||
view="error" | ||
confirmationHeading="Thank you for signing up!" | ||
confirmationText="You can update your email subscription preferences at any time using the links at the bottom of the email." | ||
errorHeading="Oh no! Something went wrong." | ||
errorText={ | ||
<div> | ||
If the error persists, | ||
<a href="mailto:[email protected]?subject=Please re-activate my e-mail address"> | ||
contact our e-mail team | ||
</a> | ||
</div> | ||
} | ||
/> | ||
) | ||
.toJSON(); | ||
expect(view).toMatchSnapshot(); | ||
}); | ||
|
||
it("Renders the default confirmation state snapshot correctly", () => { | ||
const view = renderer | ||
.create( | ||
|
@@ -411,7 +437,7 @@ describe("NewsletterSignup Snapshots", () => { | |
.toJSON(); | ||
expect(view).toMatchSnapshot(); | ||
}); | ||
|
||
// @TODO I don't think these test are working as intended as the colors are now set in the theme file. | ||
describe("Renders each color for each newsletterSignupType correctly", () => { | ||
// The newsletterSignupType values are determined by the types contained in the sectionDataMap. | ||
// So it is safe to use the map directly. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.