-
Notifications
You must be signed in to change notification settings - Fork 383
change: [UIE-8743] - Replaced Button component in DBAAS with Akamai CDS button Web Component #12148
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
Conversation
mockMatchMedia, | ||
renderWithTheme, | ||
getShadowRootButton, | ||
} from 'src/utilities/testHelpers'; // Import the utility |
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.
Comment not needed
|
||
expect(createClusterButton).toBeInTheDocument(); | ||
const buttonHost = getByTestId('create-database-cluster'); // Query the host element |
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 long as the getShadowRootButton
function has JS docs and comments explaining usage, we don't need the comments in the .test.tsx
getByTestId
is common so everyone knows what it's doing.
@@ -34,3 +34,9 @@ export const GroupItems = styled('ul')(({ theme }) => ({ | |||
}, | |||
padding: 0, | |||
})); | |||
|
|||
export const StyledButtonWrapper = styled('div')(({ theme }) => ({ |
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.
Comments are redundant.
@@ -58,6 +59,10 @@ interface Props { | |||
interface FormValues { | |||
configs: ConfigurationOption[]; | |||
} | |||
const StyledAddButtonWrapper = styled('div')(({ theme }) => ({ | |||
minWidth: 'auto', // Ensure no default minimum width |
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.
Department of Redundancy Department :)
|
||
await userEvent.click(resizeButton); | ||
await userEvent.click(resizeButton as HTMLButtonElement); |
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.
Just curious if something was complaining without the cast?
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.
yeah was getting Argument of type 'HTMLButtonElement | null' is not assignable to parameter of type 'Element'.
data-qa-settings-button={buttonText} | ||
disabled={disabled} | ||
onClick={onClick} | ||
title={buttonText} | ||
title={buttonText} // Title will be passed automatically to dom since it is standard HTML attribute |
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.
Comment not needed, those are internal impl. details.
hour_of_day: database.updates?.hour_of_day ?? 20, | ||
week_of_month: getInitialWeekOfMonth(), | ||
}, | ||
// validationSchema: updateDatabaseSchema, |
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.
I see this was already commented. Not sure why though.
* @param host - The web component host element. | ||
* @returns A promise that resolves to the button element inside the Shadow DOM, or null if not found. | ||
*/ | ||
export const getShadowRootButton = ( |
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.
Can we make this function generic getShadowRoot
and then you pass in the type you're looking for? Also this needs 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.
Besides making this more generic, I'd like to find a better approach to test these components in Cloud Manager. setTimeOut
feels hacky at best and this requires to make all those tests async for just rendering DOM elements. I am hoping there's better support out there for Web Components which i'd hope could be explored before signing up on this.
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.
I’ve generalized the utility and found a solution to eliminate the use of setTimeout. However, we still need to rely on async handling, as there’s a possibility that the Shadow DOM may not be rendered yet when attempting to access shadowRoot.
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.
This new component needs to adhere to basic Accessibility standards and to be consistent with its Cloud Manager counterpart. It appears to do it right overall, but I am noticing some discrepancies and lacking a couple needed improvements:
- the focus state is barely visible when its variant is primary
- there is no active state
* @param host - The web component host element. | ||
* @returns A promise that resolves to the button element inside the Shadow DOM, or null if not found. | ||
*/ | ||
export const getShadowRootButton = ( |
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.
Besides making this more generic, I'd like to find a better approach to test these components in Cloud Manager. setTimeOut
feels hacky at best and this requires to make all those tests async for just rendering DOM elements. I am hoping there's better support out there for Web Components which i'd hope could be explored before signing up on this.
disabled={!formTouched || isSubmitting || disabled} | ||
loading={isSubmitting} | ||
processing={isSubmitting} |
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.
This isn't pertinent to this PR as much as the component itself, but I'd argue that if the goal is to show a loading pattern, the processing
naming convention is rather unintuitive. Also, considering these components are going to live side by side with Cloud Manager components for a long time, aiming for prop consistency when possible (for which i believe it to be the case here) would go a long way. CC @jaalah-akamai
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.
+1
> | ||
Add | ||
</Button> | ||
</StyledAddButtonWrapper> |
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.
I am a bit confused here, why using a container to set en element's width? This points to a stylistic limitation of the component itself
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.
@tvijay-akamai is this still needed with the changes you made to the components?
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.
Yeah this is not needed now after core component change. I have removed it.
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.
Missing changeset.
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.
Overall, LGTM! I left a few nitpicks, nothing blocking, but worth considering. Also, I strongly agree with Alban's feedback. In addition, this PR needs a changeset and conflicts should be resolved before merging.
|
||
expect(createClusterButton).toBeInTheDocument(); | ||
const buttonHost = getByTestId('create-database-cluster'); // Query the host element |
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.
Nit: Consider replacing getByTestId
with getByRole
for improved accessibility and alignment with React Testing Library best practices.
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.
Thank you for the suggestion to use getByRole for improved accessibility and alignment with React Testing Library best practices. I completely agree that getByRole is generally preferred as it aligns with accessibility standards and ensures that elements are queried based on their semantic roles.
However, in this specific case, the element we are trying to access resides inside a Shadow DOM. Unfortunately, getByRole does not penetrate the Shadow DOM or have access to elements within the Shadow Root. As a result, we need to rely on getByTestId to query the wrapper element or host element that contains the Shadow DOM. Once we have access to the wrapper, we can use a utility function like getShadowRootElement to query elements inside the Shadow DOM.
This approach ensures that we can still test Shadow DOM elements effectively while working within the constraints of the React Testing Library and the Shadow DOM API.
If there are any alternative suggestions or tools that better support Shadow DOM testing while adhering to accessibility best practices, I’d be happy to explore them further.
d3aaa19
to
bd3b76f
Compare
@abailly-akamai , please send me where i can find basic accessibility standards for cloud manager. |
@tvijay-akamai to recap, here's what we should aim to get this PR merged (spoke to Ellen about it)
|
bd3b76f
to
76e0e37
Compare
… fix the button focus styles
@abailly-akamai I have upgraded the web component library version which has the fix for the button focus styles. Please check and approve if looks good. |
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.
@tvijay-akamai let's revisit the e2e tests
@corya-akamai @tvijay-akamai @stayal712 what is the status of this PR? We think the e2e issues we were seeing could be related to the button implementation itself, not necessarily warranting attempts to find the perfect workaround in Cypress. Once we confirm or rule that out (we could be quite wrong), we can move forward with either an upstream solution or the proposed implementation. Let us know how you want to proceed! |
@abailly-akamai Tarun is currently evaluating the most effective path forward and is exploring several potential approaches. We will keep the group informed once a final decision has been made. |
Stupid question: what does 'CDS' stand for? and i can't see any difference in the button(s) between the before and after screenshots; is that how it's intended to be? |
Not a stupid question at all! 'CDS' stands for Akamai Core Design System. It's a comprehensive design framework that provides standardized UI components and design guidelines to ensure consistency and efficiency across Akamai's applications and services. Yes, no difference is intentional. While the visual appearance of the buttons remains the same, the underlying implementation has been updated. Goal is to transition to using a new, framework-agnostic component. This change doesn't affect the look or behavior of the buttons but enhances their flexibility and maintainability across different Akamai platforms. |
@abailly-akamai We explored multiple approaches including the one you previously suggested to address the Cypress implementation preference specifically related to buttons of type "submit" in our web component. There are only 2 button type submit. (For other button types there is no concern as discussed with Sakshi.) While we did identify one solution that resolves the issue, the team decided not to proceed with it. The team's consensus is that introducing code changes solely to accommodate Cypress’s implementation preferences is not optimal, especially since there is an alternative way to simulate and test submit-type button behavior in our e2e test cases. For all other button types, our current approach works as expected. Let us know if you’d like more details on the alternatives we considered. we can separately sync-up on the same. |
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.
Thanks for looking into the alternatives @tvijay-akamai
const button2 = getByTitle('Save Changes'); | ||
const button3 = getByRole('button', { name: 'Manage Access' }); | ||
|
||
const resetPasswordButtonHost = getByTestId( |
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.
Thanks for making the variable names more explicit.
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.
Cloud Manager UI test results🎉 666 passing tests on test run #22 ↗︎
|
Description 📝
This PR is to Replaced CM Button component in DBAAS with Akamai CDS button Web Component
Changes 🔄
Target release date 🗓️
July 15th Release
Preview 📷
Include a screenshot or screen recording of the change.
🔒 Use the Mask Sensitive Data setting for security.
💡 Use
<video src="" />
tag when including recordings in table.How to test 🧪
Verification steps
(How to verify changes)
As an Author, to speed up the review process, I considered 🤔
👀 Doing a self review
❔ Our contribution guidelines
🤏 Splitting feature into small PRs
➕ Adding a changeset
🧪 Providing/improving test coverage
🔐 Removing all sensitive information from the code and PR description
🚩 Using a feature flag to protect the release
👣 Providing comprehensive reproduction steps
📑 Providing or updating our documentation
🕛 Scheduling a pair reviewing session
📱 Providing mobile support
♿ Providing accessibility support
As an Author, before moving this PR from Draft to Open, I confirmed ✅
Commit message and pull request title format standards
<commit type>: [JIRA-ticket-number] - <description>
Commit Types:
feat
: New feature for the user (not a part of the code, or ci, ...).fix
: Bugfix for the user (not a fix to build something, ...).change
: Modifying an existing visual UI instance. Such as a component or a feature.refactor
: Restructuring existing code without changing its external behavior or visual UI. Typically to improve readability, maintainability, and performance.test
: New tests or changes to existing tests. Does not change the production code.upcoming
: A new feature that is in progress, not visible to users yet, and usually behind a feature flag.Example:
feat: [M3-1234] - Allow user to view their login history