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

Added dropdown for Applanguage in UserUpdation form #498

Merged
merged 2 commits into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 5 additions & 7 deletions src/components/UserUpdate/UserUpdate.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Testing User Update', () => {
lastName: 'Doe',
email: 'johndoe@gmail.com',
password: 'qwerty',
applangcode: '2',
applangcode: 'en',
selectedOption: 'selectadmin',
displayImage: new File(['hello'], 'hello.png', { type: 'image/png' }),
};
Expand All @@ -75,8 +75,8 @@ describe('Testing User Update', () => {
);
userEvent.type(screen.getByPlaceholderText(/Email/i), formData.email);
userEvent.type(screen.getByPlaceholderText(/Password/i), formData.password);
userEvent.type(
screen.getByPlaceholderText(/App Language Code/i),
userEvent.selectOptions(
screen.getByTestId(/applangcode/i),
formData.applangcode
);
userEvent.click(screen.getByLabelText('Admin'));
Expand All @@ -100,7 +100,7 @@ describe('Testing User Update', () => {
expect(screen.getByPlaceholderText(/Password/i)).toHaveValue(
formData.password
);
expect(screen.getByPlaceholderText(/App Language Code/i)).toHaveValue(
expect(screen.getByTestId(/applangcode/i)).toHaveValue(
formData.applangcode
);
expect(screen.getByLabelText('Admin')).not.toBeChecked();
Expand All @@ -112,9 +112,7 @@ describe('Testing User Update', () => {
expect(screen.getByPlaceholderText(/Last Name/i)).toBeInTheDocument();
expect(screen.getByPlaceholderText(/Email/i)).toBeInTheDocument();
expect(screen.getByPlaceholderText(/Password/i)).toBeInTheDocument();
expect(
screen.getByPlaceholderText(/App Language Code/i)
).toBeInTheDocument();
expect(screen.getByTestId(/applangcode/i)).toBeInTheDocument();
expect(screen.getByText('User Type')).toBeInTheDocument();
expect(screen.getByText('Admin')).toBeInTheDocument();
expect(screen.getByText('Superadmin')).toBeInTheDocument();
Expand Down
19 changes: 12 additions & 7 deletions src/components/UserUpdate/UserUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useMutation } from '@apollo/client';
import { UPDATE_USER_MUTATION } from 'GraphQl/Mutations/mutations';
import { useTranslation } from 'react-i18next';

import { languages } from 'utils/languages';
import styles from './UserUpdate.module.css';

interface UserUpdateProps {
Expand Down Expand Up @@ -130,19 +131,23 @@ function UserUpdate(props: UserUpdateProps): JSX.Element {
<div className={styles.dispflex}>
<div>
<label>{t('appLanguageCode')}</label>
<input
type="input"
id="applangcode"
placeholder={t('appLanguageCode')}
required
value={formState.applangcode}
<select
className="form-control"
data-testid="applangcode"
onChange={(e) => {
setFormState({
...formState,
applangcode: e.target.value,
});
}}
/>
>
<option value="">-</option>
{languages.map((language, index: number) => (
<option key={index} value={language.code}>
{language.name}
</option>
))}
</select>
</div>
<div>
<label>{t('userType')}</label>
Expand Down