Skip to content

OBPIH-5231 Add front-end unit tests for Wizard and Menu components#3701

Merged
awalkowiak merged 8 commits intodevelopfrom
OBPIH-5231
Dec 13, 2022
Merged

OBPIH-5231 Add front-end unit tests for Wizard and Menu components#3701
awalkowiak merged 8 commits intodevelopfrom
OBPIH-5231

Conversation

@alannadolny
Copy link
Collaborator

No description provided.

@alannadolny alannadolny changed the title OBPIH 5231 Add front-end unit tests for Wizard and Menu components OBPIH-5231 Add front-end unit tests for Wizard and Menu components Dec 12, 2022
Copy link
Member

@jmiranda jmiranda left a comment

Choose a reason for hiding this comment

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

Great idea @awalkowiak

@alannadolny Can you explain why you deleted the jar file?

@awalkowiak
Copy link
Collaborator

@jmiranda my blind guess: this is some weird issue after IDE setup. I locally created a fresh branch from develop and cherry-picked these commits and this lib removal change is no longer there. Plus, as you can see currently this lib/something.jar does not exists in the develop branch. We will sort this out.

{
_.map(props.title, element => (
<span style={{ color: element.color }}>
<span key={element} style={{ color: element.color }}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would avoid using Objects as component keys since key should be a primitive value like number or string and should be unique.
Maybe use element.text instead.
Although in this case it shouldn't be a problem since these title element don't really change all that much but keep that in mind.

renderedLogo = renderer.create(<Router><Logo logoUrl="" store={store} /></Router>);
});

it('test if logo matches snapshot', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

When naming it(...) test lets use should naming convention like:
it('should match logo snapshot', () => { ... })
it('should render logo component correctly', () => { ... })
so that we know what should be the expected result of the test based on the title

import Logo from 'components/Layout/Logo';

let renderedLogo;
describe('test logo component', () => {
Copy link
Collaborator

@drodzewicz drodzewicz Dec 12, 2022

Choose a reason for hiding this comment

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

"test logo component" test is probably redundant in the title

});

it('test if collapseMenuItem and dropdownMenuItem are correctly rendering', () => {
expect(renderedMenuItem.root.findByProps({ className: 'collapse-nav-item nav-item justify-content-center align-items-center d-flex d-md-none' }))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure that checking if component is correctly rendered based on className props is a good idea.
I think a better solution would be to add a data-testid attribute to colapsable and drodown menu items and query them based on this id, and if you find it then it is rendered and if you don't then it is not

@awalkowiak awalkowiak merged commit 0c48a21 into develop Dec 13, 2022
@awalkowiak awalkowiak deleted the OBPIH-5231 branch December 13, 2022 10:19
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