@openmrs/esm-login-app 8.0.1-pre.3549 → 8.0.1-pre.3552

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -172,7 +172,7 @@ describe('Login', () => {
172
172
  expect(loginButton).toBeInTheDocument();
173
173
  });
174
174
 
175
- it('should not render the password field when the showPasswordOnSeparateScreen config is true (default)', async () => {
175
+ it('should render password field hidden but present for autofill when showPasswordOnSeparateScreen config is true (default)', async () => {
176
176
  mockUseConfig.mockReturnValue({
177
177
  ...mockConfig,
178
178
  });
@@ -187,12 +187,14 @@ describe('Login', () => {
187
187
 
188
188
  const usernameInput = screen.queryByRole('textbox', { name: /username/i });
189
189
  const continueButton = screen.queryByRole('button', { name: /Continue/i });
190
- const passwordInput = screen.queryByLabelText(/password/i);
190
+ const passwordInput = screen.queryByLabelText(/^password$/i);
191
191
  const loginButton = screen.queryByRole('button', { name: /log in/i });
192
192
 
193
193
  expect(usernameInput).toBeInTheDocument();
194
194
  expect(continueButton).toBeInTheDocument();
195
- expect(passwordInput).not.toBeInTheDocument();
195
+ expect(passwordInput).toBeInTheDocument();
196
+ expect(passwordInput).toHaveAttribute('aria-hidden', 'true');
197
+ expect(passwordInput).toHaveAttribute('tabIndex', '-1');
196
198
  expect(loginButton).not.toBeInTheDocument();
197
199
  });
198
200
 
@@ -283,4 +285,31 @@ describe('Login', () => {
283
285
 
284
286
  expect(usernameInput).toHaveFocus();
285
287
  });
288
+
289
+ it('should make password input visible and accessible after continuing from username step', async () => {
290
+ const user = userEvent.setup();
291
+ mockUseConfig.mockReturnValue({
292
+ ...mockConfig,
293
+ });
294
+
295
+ renderWithRouter(
296
+ Login,
297
+ {},
298
+ {
299
+ route: '/login',
300
+ },
301
+ );
302
+
303
+ const usernameInput = screen.getByRole('textbox', { name: /username/i });
304
+ const continueButton = screen.getByRole('button', { name: /Continue/i });
305
+
306
+ await user.type(usernameInput, 'testuser');
307
+ await user.click(continueButton);
308
+
309
+ const passwordInput = screen.getByLabelText(/^password$/i);
310
+
311
+ // Password should now be visible and accessible
312
+ expect(passwordInput).toHaveAttribute('aria-hidden', 'false');
313
+ expect(passwordInput).toHaveAttribute('tabIndex', '0');
314
+ });
286
315
  });