-
Notifications
You must be signed in to change notification settings - Fork 0
fix: adjust recommendation designation visibility #110
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,5 +35,25 @@ describe('RecommendationPartial', () => { | |
| expect(renderMarkdown).toHaveBeenCalledWith('**great**'); | ||
| expect(wrapper.html()).toContain('<strong>great</strong>'); | ||
| expect(wrapper.text()).toContain('now'); | ||
| expect(wrapper.text()).toContain(data[0].person.designation); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While This change assumes you've added const designationEl = wrapper.find('[data-testid="recommendation-designation"]');
expect(designationEl.exists()).toBe(true);
expect(designationEl.text()).toBe(data[0].person.designation); |
||
| }); | ||
|
|
||
| it('does not render designation markup when missing', () => { | ||
| const wrapper = mount(RecommendationPartial, { | ||
| props: { | ||
| recommendations: [ | ||
| { | ||
| ...data[0], | ||
| person: { | ||
| ...data[0].person, | ||
| designation: '', | ||
| }, | ||
| }, | ||
| ], | ||
| backToTopTarget: '#top', | ||
| }, | ||
| }); | ||
|
|
||
| expect(wrapper.html()).not.toContain('text-sm text-slate-600 dark:text-slate-300'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assertion is brittle because it's tied to the CSS classes. If the styling changes, this test will break even if the component's logic is still correct. It's better to use a This change assumes you've added expect(wrapper.find('[data-testid="recommendation-designation"]').exists()).toBe(false); |
||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple of improvements for this line:
Robustness of
v-if: The current conditionv-if="item.person.designation"will be true for a string containing only whitespace (e.g.," "). This would render an emptydiv, which could create unwanted vertical space because of thespace-y-1on the parent element. It's better to trim the string before checking for its truthiness.Testability: To make testing more robust and less coupled to implementation details like CSS classes, it's a good practice to add a
data-testidattribute. This allows tests to select this element without relying on fragile selectors like CSS classes.I've combined both improvements in the suggestion below. You may also consider adding a test case for a designation containing only whitespace to ensure it's handled correctly.