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

added in alert notifications #343

Merged
merged 31 commits into from
Jul 15, 2024
Merged

Conversation

alexappleget
Copy link
Contributor

@alexappleget alexappleget commented Jun 27, 2024

Fix: #337

Integrate toast notifications into our site's user interface to enhance user experience by providing clear and timely feedback for important actions and events.

Acceptance Criteria:

  • Toast notifications appear in a non-intrusive manner somewhere on the screen.
  • Notifications display relevant information such as success messages, error alerts, and action confirmations.
  • Users can interact with notifications, including dismissing them and clicking through to relevant pages.
  • Design ensures responsiveness across different devices and adheres to our site's existing UI/UX guidelines.
  • Notifications are tested thoroughly in development and staging environments for functionality and user acceptance.

Copy link

appwrite bot commented Jun 27, 2024

Gridiron Survivor Application 6616ea581ef9f5521c7d

Function ID Status Action
Your function deployment has failed. Please check the logs for more details and retry.

Project name: Gridiron Survivor Application
Project ID: 6616ea581ef9f5521c7d

Function ID Status Action
userAuth 6626fef885a9f630442b failed Failed View Logs

Only deployments on the production branch are activated automatically. If you'd like to activate this deployment, navigate to your deployments. Learn more about Appwrite Function deployments.

💡 Did you know?
Appwrite has a Discord community with over 16 000 members. Come join us!

Copy link

vercel bot commented Jun 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gridiron-survivor ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 15, 2024 1:38pm
gridiron-survivor-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 15, 2024 1:38pm

@@ -111,6 +114,9 @@ const Register = (): JSX.Element => {
router.push('/weeklyPicks');
} catch (error) {
console.error('Registration Failed', error);
toast.custom(
<Alert variant={AlertVariants.Error} message="Something went wrong." />,
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a toast for successfully registering?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add it in, but when you register successfully it just redirects you to /weeklyPicks. I can find a way to add it in so it pops up when you're on the /weeklyPicks page after registering

@@ -100,6 +100,9 @@ const WeeklyPicks = ({ NFLTeams, currentGameWeek }: Props): JSX.Element => {

if (!gameGroupData || !weeklyPicksData) {
console.error('Error getting game data');
toast.custom(
<Alert variant={AlertVariants.Error} message="Something went wrong." />,
);
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was curious in line 174, could we have You picked {currentUserPick[user.id].team} was successful => You picked Falcons was successful. Thoughts? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i definitely can! I'll give that a try so people know for sure that the system saw what they picked.

Copy link
Collaborator

@shashilo shashilo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to add unit test to ensure these notifications are firing when they should be.

toast.custom(
<Alert
variant={AlertVariants.Error}
message="You're missing information."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does this fire? It doesn't seem like the right message or even if it needs an alert.

@@ -60,7 +63,16 @@ export const AuthContextProvider = ({
await account.createEmailPasswordSession(user.email, user.password);
getUser();
router.push('/weeklyPicks');
toast.custom(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unit test for logging in to shoe the toast notification should go in this unit test file. There's none right now, so we'll need to create one. Only add test case for what you are touching though.

}

await mockLoginAccount(pretendUser);
expect(account.createEmailPasswordSession).toBeInstanceOf(Object);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no reason to test that this is an object. Also, createEmailPasswordSession is not a part of this file and doesn't need to be tested. Remove these test and test the alert logic in AuthContextProvider.

@@ -19,6 +22,8 @@ const mockUseAuthContext = {
isSignedIn: false,
};

account.create = jest.fn();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we mocking this function?

await mockLoginAccount(pretendUser);
expect(account.createEmailPasswordSession).toBeInstanceOf(Object);

render(<Alert variant={AlertVariants.Success} message="You've successfully logged in!" />)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this is not testing, this is executing the component. We want to test that the component is on the screen with the variant and message we expect. In line is executing the component onto the screen.

@@ -102,4 +107,40 @@ describe('Register', () => {

mockUseAuthContext.isSignedIn = false;
});

test('successfully registers and shows success notification', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with these test. This is incorrectly tested. OnSubmit, it's either going to pass or fail. You need to mock the response of a success or failure. Then, the alert will show up within the component. Check that the alert is in the component and we're expecting the correct variant and message.

Copy link
Member

@ryandotfurrer ryandotfurrer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of nit picks but if I don't call out the lack of alphabetically sorting props and such, Shashi will

app/login/page.test.tsx Show resolved Hide resolved
app/register/page.test.tsx Show resolved Hide resolved
expect(toast.custom).toHaveBeenCalledWith(
<Alert
variant={AlertVariants.Error}
message="Something went wrong!"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sort alphabetically

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel the need to not alphabetize this as I always define the type of variant first before providing a custom message. The message is always based on the variant type.

app/register/page.tsx Show resolved Hide resolved
);
});

test('should show error notification after a login attempt errors', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: change verbiage to "... after a login attempt errors fails"

@@ -19,7 +20,7 @@ type UserCredentials = {
type AuthContextType = {
isSignedIn: boolean;
setIsSignedIn: React.Dispatch<React.SetStateAction<boolean>>;
loginAccount: (user: UserCredentials) => Promise<void | Error>; // eslint-disable-line no-unused-vars
login: (user: UserCredentials) => Promise<void | Error>; // eslint-disable-line no-unused-vars
logoutAccount: () => Promise<void>;
getUser: () => Promise<IUser | undefined>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sort alphabetically

@@ -123,7 +122,7 @@ export const AuthContextProvider = ({
() => ({
isSignedIn,
setIsSignedIn,
loginAccount,
login,
logoutAccount,
getUser,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sort alphabetically

Copy link
Member

@ryandotfurrer ryandotfurrer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexappleget alexappleget merged commit af844dd into develop Jul 15, 2024
7 checks passed
@alexappleget alexappleget deleted the alex/integrate-alert-notifications branch July 15, 2024 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI/UX: Improve UI/UX with Toast Notifications Integration
4 participants