-
Notifications
You must be signed in to change notification settings - Fork 92
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
Add visual tests for KDropdownMenu (header, icons, multiple, single) and rename KDropdownMenu.vue to index.vue #933
base: develop
Are you sure you want to change the base?
Conversation
…and rename KDropdownMenu.vue to index.vue
Hello @AlexVelezLl , I have added the visual test for kdropdownmenu , it passed all 4 cases capturing the required snapshots. You can have a look and suggest me if anything further changes are required! |
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.
Hi @GautamBytes! Thanks a lot for this! I have left an initial review :). If there are any questions, please let us know 👐.
@@ -0,0 +1,30 @@ | |||
import { renderComponent, takeSnapshot, click } from '../../../jest.conf/visual.testUtils'; |
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.
Lets keep the test suite just as the example I linked in the issue. So lets just have one KDropdownMenu.specs.js file, where we have this structure:
describe.visual('KDropdownMenu', () => {
it(...visual test for test 1)
it(...visual test for test 2)
it(...visual test for test 3)
it(...visual test for test 4)
})
jest.conf/visual.testUtils.js
Outdated
// For KDropdownMenu, use a known selector from Keen's UI Menu. | ||
// Adjust the selector as needed (e.g., it might be '.ui-menu', '.keen-ui-menu', or a data attribute). | ||
const knownSelector = | ||
component === 'KDropdownMenu' |
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.
As linked previously, we should be able to able to render the dropdown menu with the current implementation of our visual.testUtils, please lets try not to modify this file too much as right now is pretty stable, and if we do need to modify it, we should try to avoid hardcoding specific components in it, because this is a general file with general methods.
This is the rendered example of the linked test:
jest.conf/visual.testUtils.js
Outdated
* Example: | ||
* { | ||
* default: { | ||
* element: "div", // or any Vue component like KIcon |
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.
Lets revert this change, please :). JsDocs are super super important for methods like this.
jest.conf/visual.testUtils.js
Outdated
const beforeRenderState = await page.evaluate(() => { | ||
const testing_playground = document.querySelector('#testing-playground'); | ||
return testing_playground ? testing_playground.innerHTML : ''; | ||
}); | ||
|
||
// Trigger rendering via postMessage. |
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.
Lets revert these comments too.
jest.conf/visual.testUtils.js
Outdated
); | ||
|
||
// Check if the component has been rendered by comparing the initial state with the current state. |
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.
Idem
jest.conf/visual.testUtils.js
Outdated
* | ||
* For a full list of available options, refer to the Percy documentation: |
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.
Idem. This is really really super important for other people to have a reference of the availabe option, its not here just because. :) Lets revert these changes, please 👐
}, | ||
}, | ||
}, | ||
dropdownSelector |
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.
We dont have a fourth argument for this method 😅
Hey @AlexVelezLl , did the suggested changes , can you please check now and suggest if any improvements are needed. Thanks! |
Hey @AlexVelezLl , I noticed there is a conflict in file -- lib/kdropdownmenu.vue , but i am unable to resolve the conflict and can't understand the cause , can you suggest me what to do? |
May be your branch is not up to date ..update it . Rest @AlexVelezLl could point out the accurate reason. |
Hey @GautamBytes! The conflict is because of an modify/rename file conflict, you can keep your current changes, and make sure that the changes introduced in https://github.com/learningequality/kolibri-design-system/pull/856/files are still available in the renamed file :). On a side note. I opened this PR that will properly fix the remount of the components, so you wont need to override the styles with the |
Sure @AlexVelezLl , will wait till your pr is merged and meanwhile i will check if the changes are kept in renamed file! |
Hey @AlexVelezLl , I have solved the conflict and also added the changes from your referenced pr to the renamed file . You can have a look and also suggest me what changes to do once your PR is merged. |
Description
This PR adds visual tests for the KDropdownMenu component, covering the following scenarios:
Additionally, the KDropdownMenu component file has been renamed from KDropdownMenu.vue to KDropdownMenu/index.vue to better organize the component structure.
Issue addressed
Closes #926
Before/after screenshots
NA
Changelog
Description: Added visual tests for KDropdownMenu (covering single, multiple, icons, and header slot scenarios) and renamed KDropdownMenu.vue to KDropdownMenu/index.vue.
Products impact: None
Addresses: [Visual testing]: Add visual tests for KDropdownMenu #926
Components: KDropdownMenu
Breaking: No
Impacts a11y: No
Guidance: Visual tests are implemented in separate test files following the approach used for KButton visual tests. This ensures that different configurations of KDropdownMenu render correctly and consistently.
Steps to test
(optional) Implementation notes
At a high level, how did you implement this?
The tests render KDropdownMenu via a KButton’s menu slot, simulating a user click to open the dropdown before taking snapshots.
The visual test utility was updated to accept an optional selector (knownSelector) to wait for an element (e.g., [data-test="dropdown-menu"]) indicating that the dropdown is rendered.
Renamed KDropdownMenu.vue to KDropdownMenu/index.vue for improved component organization.
Does this introduce any tech-debt items?
No, these changes follow the existing testing infrastructure and component guidelines.
Testing checklist
Reviewer guidance
Verify that the visual tests run as expected and that Percy snapshots accurately reflect the UI changes.
Confirm that renaming the component file to index.vue does not break any existing imports.
Ensure that the new tests follow the pattern used in the KButton visual tests.
[✅] Is the code clean and well-commented?
[✅] Are there tests for this change?
Comments
Please let me know if there are any questions or further adjustments needed.