mirror of https://github.com/grafana/grafana
Login: Improve accessibility of Login form (#78652)
* Chore: Fix a11y debt in Login form * fix tests * token styles * more styles * pa11y * fix pa11ypull/78734/head
parent
7dbbdc16a3
commit
eea35b9eb7
@ -1,23 +1,31 @@ |
|||||||
import { fireEvent, render, screen } from '@testing-library/react'; |
import { fireEvent, render, screen } from '@testing-library/react'; |
||||||
import React from 'react'; |
import React from 'react'; |
||||||
|
|
||||||
|
import { Field } from '@grafana/ui'; |
||||||
|
|
||||||
import { PasswordField } from './PasswordField'; |
import { PasswordField } from './PasswordField'; |
||||||
|
|
||||||
describe('PasswordField', () => { |
describe('PasswordField', () => { |
||||||
const props = { |
|
||||||
id: 'password', |
|
||||||
placeholder: 'enter password', |
|
||||||
'data-testid': 'password-field', |
|
||||||
}; |
|
||||||
it('should render correctly', () => { |
it('should render correctly', () => { |
||||||
render(<PasswordField {...props} />); |
render( |
||||||
expect(screen.getByTestId('password-field')).toBeInTheDocument(); |
<Field label="Password"> |
||||||
|
<PasswordField id="password" /> |
||||||
|
</Field> |
||||||
|
); |
||||||
|
|
||||||
|
expect(screen.getByLabelText('Password')).toBeInTheDocument(); |
||||||
expect(screen.getByRole('switch', { name: 'Show password' })).toBeInTheDocument(); |
expect(screen.getByRole('switch', { name: 'Show password' })).toBeInTheDocument(); |
||||||
}); |
}); |
||||||
|
|
||||||
it('should able to show password value if clicked on password-reveal icon', () => { |
it('should able to show password value if clicked on password-reveal icon', () => { |
||||||
render(<PasswordField {...props} />); |
render( |
||||||
expect(screen.getByTestId('password-field')).toHaveProperty('type', 'password'); |
<Field label="Password"> |
||||||
|
<PasswordField id="password" /> |
||||||
|
</Field> |
||||||
|
); |
||||||
|
|
||||||
|
expect(screen.getByLabelText('Password')).toHaveProperty('type', 'password'); |
||||||
fireEvent.click(screen.getByRole('switch', { name: 'Show password' })); |
fireEvent.click(screen.getByRole('switch', { name: 'Show password' })); |
||||||
expect(screen.getByTestId('password-field')).toHaveProperty('type', 'text'); |
expect(screen.getByLabelText('Password')).toHaveProperty('type', 'text'); |
||||||
}); |
}); |
||||||
}); |
}); |
||||||
|
Loading…
Reference in new issue