Skip to content

Conversation

narayand16
Copy link
Contributor

What does this PR do?

This PR adds support for having custom icon in the notification component. For reference to issue, please visit this

Where should the reviewer start?

Reviewer should start looking at changes made in NotificationProps and from there in Notification.js file

What testing has been done on this PR?

I have tested the changes by passing props to Notification component (part of storybook) which is under stories folder

How should this be manually tested?

You can pass the props manually to see if your custom icon is being reflected on the UI or not.

Do Jest tests follow these best practices?

Yes

  • screen is used for querying.
  • The correct query is used. (Refer to this list of queries)
  • userEvent is used in place of fireEvent.
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

What are the relevant issues?

Issue-6168

Screenshots (if appropriate)

Screenshot 2022-10-04 at 9 10 26 AM

Do the grommet docs need to be updated?

Yes

Should this PR be mentioned in the release notes?

Not sure

Is this change backwards compatible or is it a breaking change?

The change is backward compatible

@britt6612 britt6612 added the waiting Awaiting response to latest comments label Oct 4, 2022
Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

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

Looks like there are some merge conflicts. Can you update your branch with the latest version of master and resolve the conflicts?

@narayand16
Copy link
Contributor Author

narayand16 commented Oct 4, 2022 via email

@jcfilben
Copy link
Collaborator

jcfilben commented Oct 4, 2022

First check that your fork is setup so that 'upstream' points to the original grommet repo (instructions on how to do this here: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-for-a-fork)

Then while on your branch you can do git fetch upstream and then git merge upstream/master

@narayand16
Copy link
Contributor Author

@jcfilben Fixed merge conflicts.

Screenshot 2022-10-05 at 10 00 01 AM

@britt6612 britt6612 removed the waiting Awaiting response to latest comments label Oct 5, 2022
ericsoderberghp
ericsoderberghp previously approved these changes Oct 5, 2022
@ericsoderberghp ericsoderberghp dismissed their stale review October 5, 2022 16:50

forgot something

@ericsoderberghp
Copy link
Contributor

Can you please add a unit test to cover this scenario?

@narayand16
Copy link
Contributor Author

narayand16 commented Oct 5, 2022

Can you please add a unit test to cover this scenario?

Hi @ericsoderberghp I have added some test cases to verify the icon prop scenarios. Kindly review :)

@narayand16 narayand16 force-pushed the feat/custom-type-icon branch from 6040556 to b13c3d8 Compare October 5, 2022 20:25
Comment on lines 278 to 292
const theme = {
notification: {
unknown: {
icon: <Home />,
color: 'blue',
},
},
};
const Test = () => {
<Grommet theme={theme}>
<Notification data-testid="test" title="Test title" message="message" />
</Grommet>;
};
const { asFragment } = render(<Test />);
expect(asFragment()).toMatchSnapshot();
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like the snapshot isn't showing the notification as expected for this test. I think if we change this to the following the test will work

Suggested change
const theme = {
notification: {
unknown: {
icon: <Home />,
color: 'blue',
},
},
};
const Test = () => {
<Grommet theme={theme}>
<Notification data-testid="test" title="Test title" message="message" />
</Grommet>;
};
const { asFragment } = render(<Test />);
expect(asFragment()).toMatchSnapshot();
const theme = {
notification: {
unknown: {
icon: Home,
color: 'blue',
},
},
};
const { asFragment } = render
<Grommet theme={theme}>
<Notification title="Test title" message="message" />
</Grommet>;
};
expect(asFragment()).toMatchSnapshot();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @jcfilben , made the changes and tested on local. New Snapshot is being created. :)

Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

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

Looks good!

@ericsoderberghp ericsoderberghp merged commit e6da23f into grommet:master Oct 7, 2022
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.

4 participants