Skip to content

feat: [UEPR-56] Migrate to React 18 #139

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

Open
wants to merge 43 commits into
base: develop
Choose a base branch
from

Conversation

Bogomil-Stoyanov
Copy link
Contributor

@Bogomil-Stoyanov Bogomil-Stoyanov commented Feb 6, 2025

Ticket:
UEPR-56

This pull request includes an upgrade to the intl library and react 18.

MiroslavDionisiev and others added 29 commits January 17, 2025 13:53
expect(handleClick).toHaveBeenCalledTimes(1);
});

test('matches snapshot', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the component matches the snapshot it would be the same as the result of renders with all props correctly

Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather leave the snapshot test rather than renders with all props correctly. The second one will not fail if we add new props to the component and we may miss updating the test. Whereas if the snapshot is old it will fail

const component = renderer.create(
<ButtonComponent onClick={onClick} />
const { container } = render(
<ButtonComponent onClick={jest.fn()} />
Copy link
Contributor

Choose a reason for hiding this comment

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

At some places it is used const onClick = jest.fn(); and at others jest.fn() is passed directly to onClick. We should unify the syntax everywhere

);
expect(component.toJSON()).toMatchSnapshot();

expect(container.firstChild).toMatchSnapshot();
});

test('triggers callback when clicked', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add a test that the callback is not triggered if not clicked.

expect(imageStep.props().title).toEqual('id1 - name');
const divWithText = [...container.querySelectorAll('div')].find(el => el.textContent.includes('id1 - name'));
expect(divWithText).toBeTruthy();
expect(divWithText).toHaveTextContent('id1 - name');
Copy link
Contributor

Choose a reason for hiding this comment

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

if divWithText is truthy wouldn't that mean it has the text context, because we use it in the query selector. Same for the image

img={imgSrc}
title={title}
onClick={onClick}
test('triggers callback only once when clicked', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add a test that the callback is not triggered if not clicked.

Comment on lines 43 to 45
if (!button) {
throw new Error('Button not found');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if we need such error handling here

Copy link
Contributor Author

@Bogomil-Stoyanov Bogomil-Stoyanov left a comment

Choose a reason for hiding this comment

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

🤝

@cwillisf cwillisf requested a review from a team as a code owner March 4, 2025 16:13
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.

3 participants