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

Updated test ids to follow convention #446

Merged
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -36,12 +36,12 @@ describe('ErrorManager Test', () => {

it('should display error dialog as default mode', () => {
renderer();
expect(screen.getByTestId('basic-dialog')).toBeOnTheScreen();
expect(screen.getByTestId('blui-error-manager-basic-dialog')).toBeOnTheScreen();
});
it('should display error dialog as default mode', () => {
const props = defaultProps;
props.mode = 'message-box';
renderer(props);
expect(screen.getByTestId('error-message-box-close')).toBeOnTheScreen();
expect(screen.getByTestId('blui-error-message-box-close-icon')).toBeOnTheScreen();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe('ErrorMessageBox Test', () => {

it('should call onDismiss prop, when button is pressed', () => {
renderer();
expect(screen.getByTestId('error-message-box-close')).toBeOnTheScreen();
fireEvent.press(screen.getByTestId('error-message-box-close'));
expect(screen.getByTestId('blui-error-message-box-close-icon')).toBeOnTheScreen();
fireEvent.press(screen.getByTestId('blui-error-message-box-close-icon'));
expect(onClose).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe('RegistrationWorkflow', () => {
</RegistrationContextProvider>
</PaperProvider>
);
const verifyEmailInput = getByTestId('email-textinput');
const verifyEmailInput = getByTestId('blui-create-account-email-text-input');
fireEvent.changeText(verifyEmailInput, '[email protected]');
const nextButton = getByText('Next');
fireEvent.press(nextButton);
Expand Down Expand Up @@ -278,13 +278,13 @@ describe('RegistrationWorkflow', () => {
<PaperProvider>
<RegistrationContextProvider {...registrationContextProviderProps}>
<RegistrationWorkflow>
<TextInput testID="test-input" />
<TextInput testID="blui-registration-workflow-text-input" />
</RegistrationWorkflow>
</RegistrationContextProvider>
</PaperProvider>
);

expect(screen.getByTestId('test-input')).toBeOnTheScreen();
expect(screen.getByTestId('blui-registration-workflow-text-input')).toBeOnTheScreen();
});

it('should display single screen', () => {
Expand All @@ -298,6 +298,6 @@ describe('RegistrationWorkflow', () => {
</PaperProvider>
);

expect(screen.getByTestId('email-textinput')).toBeOnTheScreen();
expect(screen.getByTestId('blui-create-account-email-text-input')).toBeOnTheScreen();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ describe('Set Password Test', () => {
/>
);

const passwordInput = getByTestId('password');
const confirmInput = getByTestId('confirm');
const passwordInput = getByTestId('blui-set-password-password-text-field');
const confirmInput = getByTestId('blui-set-password-confirm-password-text-field');
fireEvent.changeText(passwordInput, 'Password@123');
fireEvent.changeText(confirmInput, 'Password@123');
expect(render).toBeTruthy();
Expand All @@ -49,8 +49,8 @@ describe('Set Password Test', () => {
/>
);

const passwordInput = getByTestId('password');
const confirmInput = getByTestId('confirm');
const passwordInput = getByTestId('blui-set-password-password-text-field');
const confirmInput = getByTestId('blui-set-password-confirm-password-text-field');
fireEvent.changeText(passwordInput, 'Pass');
fireEvent.changeText(confirmInput, 'Pass');
expect(render).toBeTruthy();
Expand All @@ -67,8 +67,8 @@ describe('Set Password Test', () => {

it('PasswordtextField toggles visibility', () => {
const { getByTestId } = render(<PasswordTextField />);
const toggleButton = getByTestId('toggle-button');
const textfield = getByTestId('textfield');
const toggleButton = getByTestId('blui-password-text-field-toggle-button');
const textfield = getByTestId('blui-password-text-field');
fireEvent.press(toggleButton);
expect(textfield.props.secureTextEntry).toBe(false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('WorkflowCardActions Test', () => {
const { getByTestId } = render(
<WorkflowCardActions previousLabel={'Back'} nextLabel="Next" showPrevious showNext onNext={onNext} />
);
const nextButton = getByTestId('workflow-card-next-button');
const nextButton = getByTestId('blui-workflow-card-actions-next-button');
fireEvent.press(nextButton);
expect(onNext).toHaveBeenCalledTimes(1);
});
Expand All @@ -45,7 +45,7 @@ describe('WorkflowCardActions Test', () => {
onPrevious={onPrevious}
/>
);
const previousButton = getByTestId('workflow-card-previous-button');
const previousButton = getByTestId('blui-workflow-card-actions-previous-button');
fireEvent.press(previousButton);
expect(onPrevious).toHaveBeenCalledTimes(1);
});
Expand All @@ -61,7 +61,7 @@ describe('WorkflowCardActions Test', () => {
canGoPrevious={() => false}
/>
);
const previousButton = getByTestId('workflow-card-previous-button');
const previousButton = getByTestId('blui-workflow-card-actions-previous-button');
fireEvent.press(previousButton);
expect(onPrevious).toHaveBeenCalledTimes(0);
});
Expand All @@ -77,7 +77,7 @@ describe('WorkflowCardActions Test', () => {
canGoNext={() => false}
/>
);
const nextButton = getByTestId('workflow-card-next-button');
const nextButton = getByTestId('blui-workflow-card-actions-next-button');
fireEvent.press(nextButton);
expect(onNext).toHaveBeenCalledTimes(0);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('WorkflowCardHeader', () => {
<WorkflowCardHeader title="Test Title" onIconPress={onIconPress} />
</SafeAreaProvider>
);
const icon = getByTestId('workflow-card-icon');
const icon = getByTestId('blui-workflow-card-header-icon');
fireEvent.press(icon);
expect(onIconPress).toHaveBeenCalledTimes(1);
});
Expand Down
24 changes: 12 additions & 12 deletions login-workflow/src/__tests__/screens/AccountDetailsScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ describe('Account Details Screen', () => {
},
});

const firstNameInput = screen.getByTestId('firstName');
const firstNameInput = screen.getByTestId('blui-account-details-first-name');
expect(firstNameInput.props.value).toBe('');

const lastNameInput = screen.getByTestId('lastName');
const lastNameInput = screen.getByTestId('blui-account-details-last-name');
expect(lastNameInput.props.value).toBe('');

const nextButton = screen.getByText('Next');
Expand All @@ -80,7 +80,7 @@ describe('Account Details Screen', () => {

fireEvent.press(nextButton);
expect(mockOnNext).toHaveBeenCalled();
await waitFor(() => expect(screen.getByTestId('spinner')).toBeOnTheScreen());
await waitFor(() => expect(screen.getByTestId('blui-spinner')).toBeOnTheScreen());
});

it('should call onPrevious, when Back button clicked', () => {
Expand All @@ -101,32 +101,32 @@ describe('Account Details Screen', () => {
it('should enable Next button, when both the inputs are valid', () => {
renderer();

const firstNameInput = screen.getByTestId('firstName');
const firstNameInput = screen.getByTestId('blui-account-details-first-name');
fireEvent.changeText(firstNameInput, 'Test First Name');

const lastNameInput = screen.getByTestId('lastName');
const lastNameInput = screen.getByTestId('blui-account-details-last-name');
fireEvent.changeText(lastNameInput, 'Test Last Name');
expect(screen.getByText('Next')).toBeEnabled();
});

it('should disable Next button, when the first name input is invalid', () => {
renderer();

const firstNameInput = screen.getByTestId('firstName');
const firstNameInput = screen.getByTestId('blui-account-details-first-name');
fireEvent.changeText(firstNameInput, '');

const lastNameInput = screen.getByTestId('lastName');
const lastNameInput = screen.getByTestId('blui-account-details-last-name');
fireEvent.changeText(lastNameInput, 'Test Last Name');
expect(screen.getByText('Next')).toBeDisabled();
});

it('should disable Next button, when the last name input is invalid', () => {
renderer();

const firstNameInput = screen.getByTestId('firstName');
const firstNameInput = screen.getByTestId('blui-account-details-first-name');
fireEvent.changeText(firstNameInput, 'Test First Name');

const lastNameInput = screen.getByTestId('lastName');
const lastNameInput = screen.getByTestId('blui-account-details-last-name');
fireEvent.changeText(lastNameInput, '');
expect(screen.getByText('Next')).toBeDisabled();
});
Expand All @@ -141,15 +141,15 @@ describe('Account Details Screen', () => {
it('should display loader, when next button is pressed', async () => {
renderer();

const firstNameInput = screen.getByTestId('firstName');
const firstNameInput = screen.getByTestId('blui-account-details-first-name');
fireEvent.changeText(firstNameInput, 'Test First Name');

const lastNameInput = screen.getByTestId('lastName');
const lastNameInput = screen.getByTestId('blui-account-details-last-name');
fireEvent.changeText(lastNameInput, 'Test Last Name');

const nextButton = screen.getByText('Next');
expect(nextButton).toBeOnTheScreen();
fireEvent.press(nextButton);
await waitFor(() => expect(screen.getByTestId('spinner')).toBeOnTheScreen());
await waitFor(() => expect(screen.getByTestId('blui-spinner')).toBeOnTheScreen());
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('AccountDetailsScreenBase Tests', () => {
initialLastName: 'Test Last Name',
});

expect(screen.getByTestId('firstName')).toHaveDisplayValue('Test First Name');
expect(screen.getByTestId('lastName')).toHaveDisplayValue('Test Last Name');
expect(screen.getByTestId('blui-account-details-first-name')).toHaveDisplayValue('Test First Name');
expect(screen.getByTestId('blui-account-details-last-name')).toHaveDisplayValue('Test Last Name');
});
});
34 changes: 17 additions & 17 deletions login-workflow/src/__tests__/screens/ChangePasswordScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Change Password tests', () => {

it('should display input field with passed prop', () => {
renderer();
const currentPasswordInput = screen.getByTestId('current-password');
const currentPasswordInput = screen.getByTestId('blui-change-password-current-password-text-field');
expect(currentPasswordInput).toHaveDisplayValue('');
fireEvent.changeText(currentPasswordInput, 'Abc@2023');
expect(currentPasswordInput).toHaveDisplayValue('Abc@2023');
Expand All @@ -67,9 +67,9 @@ describe('Change Password tests', () => {
},
});

const newPasswordInput = screen.getByTestId('password');
const newPasswordInput = screen.getByTestId('blui-set-password-password-text-field');
expect(newPasswordInput).toHaveDisplayValue('');
const confirmPasswordInput = screen.getByTestId('confirm');
const confirmPasswordInput = screen.getByTestId('blui-set-password-confirm-password-text-field');
expect(confirmPasswordInput).toHaveDisplayValue('');
fireEvent.changeText(newPasswordInput, 'Abc@1234');
expect(newPasswordInput).toHaveDisplayValue('Abc@1234');
Expand All @@ -88,10 +88,10 @@ describe('Change Password tests', () => {
},
});

const currentPasswordInput = screen.getByTestId('current-password');
const currentPasswordInput = screen.getByTestId('blui-change-password-current-password-text-field');
fireEvent.changeText(currentPasswordInput, 'Abc@1234');
const newPasswordInput = screen.getByTestId('password');
const confirmPasswordInput = screen.getByTestId('confirm');
const newPasswordInput = screen.getByTestId('blui-set-password-password-text-field');
const confirmPasswordInput = screen.getByTestId('blui-set-password-confirm-password-text-field');
fireEvent.changeText(newPasswordInput, 'Abc@1234');
expect(newPasswordInput).toHaveDisplayValue('Abc@1234');
fireEvent.changeText(confirmPasswordInput, 'Abc@1234');
Expand All @@ -118,8 +118,8 @@ describe('Change Password tests', () => {
},
});

const passwordField = screen.getByTestId('password');
const confirmPasswordField = screen.getByTestId('confirm');
const passwordField = screen.getByTestId('blui-set-password-password-text-field');
const confirmPasswordField = screen.getByTestId('blui-set-password-confirm-password-text-field');

fireEvent.changeText(passwordField, 'A');
fireEvent.changeText(confirmPasswordField, 'A');
Expand All @@ -144,9 +144,9 @@ describe('Change Password tests', () => {
currentPasswordLabel: 'Current Label',
});

const currentPasswordField = screen.getByTestId('current-password');
const passwordField = screen.getByTestId('password');
const confirmPasswordField = screen.getByTestId('confirm');
const currentPasswordField = screen.getByTestId('blui-change-password-current-password-text-field');
const passwordField = screen.getByTestId('blui-set-password-password-text-field');
const confirmPasswordField = screen.getByTestId('blui-set-password-confirm-password-text-field');
const nextButton = screen.getByText('Next');
expect(nextButton).toBeDisabled();

Expand Down Expand Up @@ -174,8 +174,8 @@ describe('Change Password tests', () => {
currentPasswordLabel: 'Current Label',
});

const passwordField = screen.getByTestId('password');
const confirmPasswordField = screen.getByTestId('confirm');
const passwordField = screen.getByTestId('blui-set-password-password-text-field');
const confirmPasswordField = screen.getByTestId('blui-set-password-confirm-password-text-field');
const nextButton = screen.getByText('Next');

fireEvent.changeText(passwordField, 'Password@123A');
Expand All @@ -192,9 +192,9 @@ describe('Change Password tests', () => {
onFinish: mockOnFinish(),
});

const currentPasswordField = getByTestId('current-password');
const passwordField = getByTestId('password');
const confirmPasswordField = getByTestId('confirm');
const currentPasswordField = getByTestId('blui-change-password-current-password-text-field');
const passwordField = getByTestId('blui-set-password-password-text-field');
const confirmPasswordField = getByTestId('blui-set-password-confirm-password-text-field');
const nextButton = screen.getByText('Submit');

fireEvent.changeText(currentPasswordField, 'Password');
Expand All @@ -213,7 +213,7 @@ describe('Change Password tests', () => {
},
});

const crossButton = screen.getByTestId('workflow-card-icon');
const crossButton = screen.getByTestId('blui-workflow-card-header-icon');
fireEvent.press(crossButton);
expect(mockOnIconPress).toHaveBeenCalled();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ describe('Change Password Screen Base', () => {
renderer();

const currentPasswordInput = screen.getAllByText('Current Password')[0];
const passwordInput = screen.getByTestId('password');
const confirmInput = screen.getByTestId('confirm');
const passwordInput = screen.getByTestId('blui-set-password-password-text-field');
const confirmInput = screen.getByTestId('blui-set-password-confirm-password-text-field');

expect(currentPasswordInput).toBeOnTheScreen();
expect(passwordInput).toBeOnTheScreen();
Expand All @@ -51,7 +51,7 @@ describe('Change Password Screen Base', () => {
it('input onChange callBack', () => {
renderer();

const currentPasswordInput = screen.getByTestId('current-password');
const currentPasswordInput = screen.getByTestId('blui-change-password-current-password-text-field');
fireEvent.changeText(currentPasswordInput, 'Password@123A');
expect(currentPasswordInput).toHaveDisplayValue('Password@123A');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Create Account Base', () => {
</RegistrationContextProvider>
</PaperProvider>
);
expect(screen.getByTestId('email-textinput')).toBeOnTheScreen();
expect(screen.getByTestId('blui-create-account-email-text-input')).toBeOnTheScreen();
});

it('should call onNext, when Next button clicked', () => {
Expand All @@ -42,7 +42,7 @@ describe('Create Account Base', () => {
</RegistrationContextProvider>
</PaperProvider>
);
const emailInput = screen.getByTestId('email-textinput');
const emailInput = screen.getByTestId('blui-create-account-email-text-input');
fireEvent.changeText(emailInput, '[email protected]');
fireEvent.press(screen.getByText('NextButton'));
expect(nextfn).toHaveBeenCalled();
Expand All @@ -65,7 +65,7 @@ describe('Create Account Base', () => {
</RegistrationContextProvider>
</PaperProvider>
);
const emailInput = screen.getByTestId('email-textinput');
const emailInput = screen.getByTestId('blui-create-account-email-text-input');
fireEvent.changeText(emailInput, '[email protected]');
fireEvent.press(screen.getByText('Back'));
expect(prevFn).toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Create Account Base', () => {
<CreateAccountScreenBase />
</SafeAreaProvider>
);
expect(screen.getByTestId('email-textinput')).toBeOnTheScreen();
expect(screen.getByTestId('blui-create-account-email-text-input')).toBeOnTheScreen();
});

it('renders correctly with props', () => {
Expand Down Expand Up @@ -53,7 +53,7 @@ describe('Create Account Base', () => {
</SafeAreaProvider>
);

const Input = getByTestId('email-textinput');
const Input = getByTestId('blui-create-account-email-text-input');
fireEvent.changeText(Input, '[email protected]');
expect(updateInput).toHaveBeenCalledTimes(1);
});
Expand Down
Loading
Loading