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

fix: [M3-8686] - fix Buttons data-qa attributes #11035

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe('displays kubernetes plans panel based on availability', () => {
cy.get('[data-qa-plan-row="dedicated-3"]').within(() => {
cy.get('[data-testid="decrement-button"]').should('be.disabled');
cy.get('[data-testid="increment-button"]').should('be.disabled');
cy.get('[data-testid="Button"]')
cy.get('[data-testid="button"]')
.should(
'have.attr',
'aria-label',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ describe('longview', () => {
mockUpdateLongviewClient(newClient.id, newClient).as('updateLongview');

// Confirms that Cloud Manager UI can rename longview client.
cy.get(`[data-testid="editable-text"] > [data-testid="Button"]`)
cy.get(`[data-testid="editable-text"] > [data-testid="button"]`)
.should('be.visible')
.click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('create NodeBalancer to test the submission of multiple nodes and multi
.type('50');

// Add a backend node
cy.get('[data-testid="Button"]').contains('Add a Node').click();
cy.get('[data-testid="button"]').contains('Add a Node').click();
cy.findAllByText('Label').last().click().type(randomLabel());
cy.findAllByText('IP Address')
.last()
Expand Down Expand Up @@ -179,7 +179,7 @@ describe('create NodeBalancer to test the submission of multiple nodes and multi
.click();

// Add another configuration
cy.get('[data-testid="Button"]')
cy.get('[data-testid="button"]')
.contains('Add another Configuration')
.click();
cy.get('[data-qa-panel="Configuration - Port "]').within(() => {
Expand Down Expand Up @@ -260,7 +260,7 @@ describe('create NodeBalancer to test the submission of multiple nodes and multi
.click();

// Add another configuration
cy.get('[data-testid="Button"]')
cy.get('[data-testid="button"]')
.contains('Add another Configuration')
.click();
cy.get('[data-qa-panel="Configuration - Port "]').within(() => {
Expand Down
6 changes: 3 additions & 3 deletions packages/manager/src/components/Button/Button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ describe('Button', () => {

it('should be disabled if loading', () => {
const { getByTestId } = renderWithTheme(<Button loading>Test</Button>);
const button = getByTestId('Button');
const button = getByTestId('button');
expect(button).toBeDisabled();
});

it('should have the aria-disabled attribute, instead of disabled attribute', () => {
const { getByTestId } = renderWithTheme(<Button disabled>Test</Button>);
const button = getByTestId('Button');
const button = getByTestId('button');
expect(button).not.toHaveAttribute('disabled');
expect(button).toHaveAttribute('aria-disabled', 'true');
});
Expand All @@ -49,7 +49,7 @@ describe('Button', () => {
</Button>
);

const button = getByTestId('Button');
const button = getByTestId('button');
expect(button).toHaveAttribute('aria-describedby', 'button-tooltip');

fireEvent.mouseOver(button);
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
color={color}
compactX={compactX}
compactY={compactY}
data-testid={rest['data-testid'] || 'Button'}
data-testid={rest['data-testid'] || 'button'}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is 1/2 of the main changes

disableRipple={disabled}
disabled={loading}
loading={loading}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ describe('CheckoutBar', () => {
);

expect(getByText('Checkout')).toBeVisible();
expect(getByTestId('Button')).toBeInTheDocument();
expect(getByTestId('Button')).toHaveTextContent('Submit');
expect(getByTestId('button')).toBeInTheDocument();
expect(getByTestId('button')).toHaveTextContent('Submit');
expect(getByText('Child items can go here!')).toBeInTheDocument();
});

Expand Down Expand Up @@ -54,7 +54,7 @@ describe('CheckoutBar', () => {
<CheckoutBar {...defaultArgs} isMakingRequest={true} />
);

expect(getByTestId('Button')).toBeDisabled();
expect(getByTestId('button')).toBeDisabled();
expect(getByTestId('loadingIcon')).toBeInTheDocument();
});

Expand All @@ -63,7 +63,7 @@ describe('CheckoutBar', () => {
<CheckoutBar {...defaultArgs} disabled />
);

const button = getByTestId('Button');
const button = getByTestId('button');
expect(button).toBeDisabled();
expect(button).toHaveTextContent('Submit');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const SingleTextFieldForm = React.memo((props: Props) => {
/>
<ActionsPanel
primaryButtonProps={{
'data-testid': 'Button',
'data-testid': 'button',
Copy link
Contributor Author

@abailly-akamai abailly-akamai Oct 2, 2024

Choose a reason for hiding this comment

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

This is 2/2 of the main changes

disabled: disabled || value === initialValue,
label: `Update ${label}`,
loading: submitting,
Expand Down
4 changes: 2 additions & 2 deletions packages/manager/src/components/TagCell/TagCell.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ describe('TagCell Component', () => {
const { getByTestId } = renderWithTheme(
<TagCell disabled tags={tags} updateTags={updateTags} view="panel" />
);
const disabledButton = getByTestId('Button');
const disabledButton = getByTestId('button');
expect(disabledButton).toHaveAttribute('aria-disabled', 'true');
});

it('should display the tooltip if disabled and tooltipText is true', async () => {
const { getByTestId } = renderWithTheme(
<TagCell disabled tags={tags} updateTags={updateTags} view="panel" />
);
const disabledButton = getByTestId('Button');
const disabledButton = getByTestId('button');
expect(disabledButton).toBeInTheDocument();

fireEvent.mouseOver(disabledButton);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('NodeBalancerFirewallsRow', () => {
<NodeBalancerFirewallsRow {...props} />
);

const unassignButton = getByTestId('Button');
const unassignButton = getByTestId('button');
expect(unassignButton).toBeDisabled();
await userEvent.click(unassignButton);
expect(props.onClickUnassign).not.toHaveBeenCalled();
Expand Down