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

Table Component Rounded Corners Fix #3010

Merged
merged 2 commits into from
Sep 26, 2024
Merged

Conversation

jagabomb
Copy link
Contributor

@jagabomb jagabomb commented Sep 23, 2024

Description

This PR attempts to fix a visual issue where tables were not displaying the rounded corners correctly even though that had the correct corner rounding classes. An overflow-hidden class was added since nested elements (th and td items) have background colours.

Changes (Before and After)

Frame 79

How was this tested?

Describe the tests that have been added/changed for this new behaviour.

  • DONE Test written to check for the existence of the both the rounded class and overflow-hidden class. (Might be overkill but I am open to feedback)
  • DONE Visually in Storybook across other components that use tables like Overview pages and the Dashboard.

@jagabomb jagabomb added bug Something isn't working chore ux labels Sep 23, 2024
Copy link
Member

@janvhs janvhs left a comment

Choose a reason for hiding this comment

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

Minor nitpick, but otherwise good :D


const wrapperDiv = screen.getByRole('table').closest('div');

expect(wrapperDiv).toHaveClass(/rounded/, 'overflow-hidden');
Copy link
Member

Choose a reason for hiding this comment

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

Generally, it's not the best idea to test for the presence of static CSS classes - the overflow in this case -, since changing CSS would imply changing a lot of test cases as well.

If the class is dynamic, it's okay, but I prefer not to, because it makes changing CSS cumbersome. Furthermore, does the presence of a CSS class not really tell the whole story of if the CSS acts according to the expectations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@janvhs, so I'm not too sure how to propose a change in the test here 😅... the condition that the test is checking for is the existence of both the rounded* and overflow-hidden classes which are required for the rounded corner effect. I could just check for the overflow*class but it won't yield the same result in the UI unless it is specially the overflow-hidden class. Please let me know if this what you were referring to.

Copy link
Member

Choose a reason for hiding this comment

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

No, wat I wanted to get at is, that you usually don't need a test case for something like this, because you didn't touch "actual" logic ^^

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, I agree. I did raise it in the Test Section that the test might be too much work for such a little change. But at the same time I felt like it just helpful to try use a test to try safeguard a Design System aesthetic. 😅

Copy link
Member

@janvhs janvhs Sep 26, 2024

Choose a reason for hiding this comment

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

Yeah but you'd be better of safeguarding it via some kind of visual test... be it done via screenshots and regression testing or manually via storybook, like we do. If one wants to automate this, there are tools for spotting diffs like https://github.com/dmtrKovalenko/odiff or our openQA. Otherwise you try to break down the cascading nature of CSS to isolated units, which just doesn't work reliably

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah we also have visual tests in our pipeline because Chromatic does them, I just disabled them because they cost additional money and due to the nature of our stories using fixtures the always changing data was conflicting with snapshot tests.

Feel free to merge, @jagabomb!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@janvhs thanks for the suggestion... I will definitely look into it for next time.

@jagabomb jagabomb merged commit 64c1928 into main Sep 26, 2024
114 checks passed
@jagabomb jagabomb deleted the table-component-rounded-corners-fix branch September 26, 2024 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working chore ux
Development

Successfully merging this pull request may close these issues.

3 participants