-
Notifications
You must be signed in to change notification settings - Fork 2
Refactor cypress tests with commands and data tags #144
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
base: develop
Are you sure you want to change the base?
Conversation
…als' into 137-refactor-cypress-tests
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.
Pull Request Overview
This PR refactors Cypress tests by introducing data-cy attributes and custom commands to improve test selector reliability and simplify test flows.
- Added consistent data-cy attributes across UI components
- Updated custom Cypress commands to leverage these new selectors
- Refactored test specs to use the new commands and selectors
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/src/pages/admin_page/UsersAdmin.tsx | Added data-cy attributes for delete, create, and edit user buttons |
| ui/src/components/TopBar.tsx | Added data-cy attributes for login and register buttons (including mobile variants) |
| ui/src/components/ProfileMenu.tsx | Added data-cy attributes for profile menu elements |
| ui/src/components/LoginModal.tsx | Integrated data-cy attributes for form fields and error alerts |
| ui/src/components/Button.tsx | Introduced a new dataCy prop that maps to the data-cy attribute in the rendered button |
| ui/src/components/Alert.tsx | Updated Alert to accept additional HTML attributes via a spread of props |
| ui/cypress/support/commands.js | Added custom Cypress commands leveraging the new data-cy attributes |
| ui/cypress/e2e/admin.cy.js | Refactored admin e2e tests to use the new custom commands |
| setOpenRegisterModal(true) | ||
| setSidebarOpen(false) | ||
| }} | ||
| data-cy="open-login-modal-mobile" |
Copilot
AI
Apr 1, 2025
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.
The same data-cy value 'open-login-modal-mobile' is used for both the login and register mobile buttons, which may cause ambiguity in tests. Consider using a unique identifier for each button.
| data-cy="open-login-modal-mobile" | |
| data-cy="open-register-modal-mobile" |
| cy.get('[data-cy="login-button"]').click(); | ||
| }, | ||
| logout() { | ||
| cy.get('[data-cy="toggle-profile-menu-dropdown"').click(); |
Copilot
AI
Apr 1, 2025
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.
The selector is missing a closing bracket. It should be corrected to: cy.get('[data-cy="toggle-profile-menu-dropdown"]').click();
| cy.get('[data-cy="toggle-profile-menu-dropdown"').click(); | |
| cy.get('[data-cy="toggle-profile-menu-dropdown"]').click(); |
| class={clsx('alert my-4', types[props.type].alert, props?.class)} | ||
| {...props} |
Copilot
AI
Apr 1, 2025
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.
[nitpick] Spreading {...props} after setting the 'class' attribute may override the computed class names. Consider reordering the props spread or merging the classes to preserve the intended styling.
| class={clsx('alert my-4', types[props.type].alert, props?.class)} | |
| {...props} | |
| {...props} | |
| class={clsx('alert my-4', types[props.type].alert, props?.class)} |
Closes #137