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

Catalog from wanda #960

Merged
merged 6 commits into from
Nov 8, 2022
Merged

Catalog from wanda #960

merged 6 commits into from
Nov 8, 2022

Conversation

arbulu89
Copy link
Contributor

@arbulu89 arbulu89 commented Nov 7, 2022

Description

Load catalog data from wanda. The same functionality as before, except there is no provider selection. The new view is available through http://localhost:4000/catalog_new

image

PD: I have included a pair of dummy checks to show the groups in the result

How was this tested?

Tests on jest added

@arbulu89 arbulu89 added the enhancement New feature or request label Nov 7, 2022
@arbulu89 arbulu89 marked this pull request as ready for review November 7, 2022 15:51
Copy link
Contributor

@dottorblaster dottorblaster left a comment

Choose a reason for hiding this comment

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

Nice! Some tweaks and I think we can merge this 👍

assets/js/components/ChecksCatalog/ChecksCatalogNew.jsx Outdated Show resolved Hide resolved
assets/js/components/ChecksCatalog/ChecksCatalogNew.jsx Outdated Show resolved Hide resolved
Comment on lines 40 to 75
<div
key={idx}
className="check-group bg-white shadow overflow-hidden sm:rounded-md mb-8"
>
<div className="bg-white px-4 py-5 border-b border-gray-200 sm:px-6">
<h3 className="text-lg leading-6 font-medium text-gray-900">
{group}
</h3>
</div>
<ul role="list" className="divide-y divide-gray-200">
{checks.map((check) => (
<li key={check.id}>
<Disclosure>
<Disclosure.Button
as="div"
className="flex justify-between w-full cursor-pointer hover:bg-gray-100"
>
<div className="check-row px-4 py-4 sm:px-6">
<div className="flex items-center">
<p className="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
{check.id}
</p>
{check.premium > 0 && (
<p className="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
Premium
</p>
)}
</div>
<div className="mt-2 sm:flex sm:justify-between">
<div className="sm:flex">
<ReactMarkdown
className="markdown text-sm"
remarkPlugins={[remarkGfm]}
>
{check.description}
</ReactMarkdown>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we wanna extract all this markup in some more granular components?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean to create our own markdown component with those defaults?
In this case text-sm would be an additional style.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we do the next? Let me merge this as it is about this topic, and I will create other PR with a new markdown component and use it all around the code. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not the markdown, I mean the whole HTML body of this component 😅

In a similar way to https://github.com/trento-project/web/blob/main/assets/js/components/ChecksResults/ChecksResults.jsx, we can make this code more readable just having a wrapper component for the divs and the ul and another component for the li

Copy link
Contributor

Choose a reason for hiding this comment

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

Anyway if you wanna do that in a subsequent PR, feel free.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dottorblaster CheckItem extracted to an individual component. Going further looks like an overkill to me

@arbulu89 arbulu89 force-pushed the catalog-from-wanda branch 2 times, most recently from 85aab9e to f3271e2 Compare November 8, 2022 09:50
Copy link
Contributor

@dottorblaster dottorblaster left a comment

Choose a reason for hiding this comment

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

Sorry, really. Last thing then we can merge 👍

Comment on lines 26 to 27
import ChecksCatalog from '@components/ChecksCatalog';
import { ChecksCatalogNew } from '@components/ChecksCatalog';
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry ❤️ last thing 😄 could you group these imports? You can do that just by doing import ChecksCatalog, { ChecksCatalogNew } from...

@CDimonaco
Copy link
Member

Looks good to me, I'm with @dottorblaster on all the other comments, I think that we could add some data-testid attributes/props on component to better test them even in the future, like we already done other jest tests.

For reference: https://testing-library.com/docs/queries/bytestid/

It's a nice to have btw, @arbulu89 good job!

@arbulu89
Copy link
Contributor Author

arbulu89 commented Nov 8, 2022

Looks good to me, I'm with @dottorblaster on all the other comments, I think that we could add some data-testid attributes/props on component to better test them even in the future, like we already done other jest tests.

For reference: https://testing-library.com/docs/queries/bytestid/

It's a nice to have btw, @arbulu89 good job!

Hey @CDimonaco ,
I see the point of using the test-ids. In this case, finding the elements was fairly simple and the tests look pretty easy to understand, that's why I didn't include them. But I agree that once you have difficult dom findings etc they are super useful

@CDimonaco
Copy link
Member

Looks good to me, I'm with @dottorblaster on all the other comments, I think that we could add some data-testid attributes/props on component to better test them even in the future, like we already done other jest tests.
For reference: https://testing-library.com/docs/queries/bytestid/
It's a nice to have btw, @arbulu89 good job!

Hey @CDimonaco , I see the point of using the test-ids. In this case, finding the elements was fairly simple and the tests look pretty easy to understand, that's why I didn't include them. But I agree that once you have difficult dom findings etc they are super useful

Perfect! LGTM

Copy link
Member

@CDimonaco CDimonaco left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@dottorblaster dottorblaster left a comment

Choose a reason for hiding this comment

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

LGTM

export const catalogCheckFactory = Factory.define(() => ({
id: faker.datatype.uuid(),
name: faker.animal.cat(),
group: faker.animal.cat(),
Copy link
Member

Choose a reason for hiding this comment

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

meow

@fabriziosestito
Copy link
Member

Looks good to me, I'm with @dottorblaster on all the other comments, I think that we could add some data-testid attributes/props on component to better test them even in the future, like we already done other jest tests.
For reference: https://testing-library.com/docs/queries/bytestid/
It's a nice to have btw, @arbulu89 good job!

Hey @CDimonaco , I see the point of using the test-ids. In this case, finding the elements was fairly simple and the tests look pretty easy to understand, that's why I didn't include them. But I agree that once you have difficult dom findings etc they are super useful

Perfect! LGTM

FYI
In the spirit of the guiding principles, it is recommended to use this only after the other queries don't work for your use case. Using data-testid attributes do not resemble how your software is used and should be avoided if possible.

@arbulu89 arbulu89 merged commit ff8d820 into main Nov 8, 2022
@arbulu89 arbulu89 deleted the catalog-from-wanda branch November 8, 2022 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

4 participants