Skip to content
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
3 changes: 2 additions & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"@playwright/test": "catalog:",
"@react-native/jest-preset": "^0.86.2",
"@tailwindcss/postcss": "4.3.3",
"@testing-library/react-native": "13.3.3",
"@testing-library/react-native": "14.0.1",
"@types/jest": "30.0.0",
"@types/node": "catalog:",
"@types/react": "~19.2.18",
Expand All @@ -114,6 +114,7 @@
"postcss": "8.5.26",
"serve": "14.2.6",
"tailwindcss": "catalog:",
"test-renderer": "1.2.0",
"typescript": "catalog:"
},
"private": true
Expand Down
30 changes: 15 additions & 15 deletions app/src/app/(auth)/__tests__/forgot-password.integration.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ function createMockResponse(ok: boolean, body: Record<string, unknown> = {}): Re
} as unknown as Response;
}

function renderForgotPasswordScreen() {
renderWithProviders(<ForgotPasswordScreen />);
async function renderForgotPasswordScreen() {
await renderWithProviders(<ForgotPasswordScreen />);
}

async function submitForgotPasswordEmail(email: string) {
fireEvent.changeText(screen.getByLabelText('Email'), email);
await fireEvent.changeText(screen.getByLabelText('Email'), email);
await waitFor(() => {
expect(screen.getByText('Send reset link')).not.toBeDisabled();
});
fireEvent.press(screen.getByText('Send reset link'));
await fireEvent.press(screen.getByText('Send reset link'));
}

beforeEach(() => {
Expand All @@ -55,16 +55,16 @@ beforeEach(() => {
});

describe('ForgotPasswordScreen rendering', () => {
it('renders the forgot password form', () => {
renderForgotPasswordScreen();
it('renders the forgot password form', async () => {
await renderForgotPasswordScreen();
expect(screen.getByText('Forgot password')).toBeOnTheScreen();
expect(screen.getAllByText('Send reset link')).not.toHaveLength(0);
expect(screen.getByText(FORGOT_PASSWORD_INSTRUCTIONS_PATTERN)).toBeOnTheScreen();
});

it('shows a validation error for an invalid email address', async () => {
renderForgotPasswordScreen();
fireEvent.changeText(screen.getByLabelText('Email'), 'not-an-email');
await renderForgotPasswordScreen();
await fireEvent.changeText(screen.getByLabelText('Email'), 'not-an-email');

await waitFor(() => {
expect(screen.getByText(VALID_EMAIL_PATTERN)).toBeOnTheScreen();
Expand All @@ -74,7 +74,7 @@ describe('ForgotPasswordScreen rendering', () => {

describe('ForgotPasswordScreen submission', () => {
it('submits the email and shows the success state', async () => {
renderForgotPasswordScreen();
await renderForgotPasswordScreen();
await submitForgotPasswordEmail('user@example.com');

await waitFor(() => {
Expand All @@ -92,7 +92,7 @@ describe('ForgotPasswordScreen submission', () => {
it('shows the API error message when the request fails', async () => {
mockedApiFetch.mockResolvedValue(createMockResponse(false, { detail: 'No matching account' }));

renderForgotPasswordScreen();
await renderForgotPasswordScreen();
await submitForgotPasswordEmail('user@example.com');

await waitFor(() => {
Expand All @@ -104,7 +104,7 @@ describe('ForgotPasswordScreen submission', () => {
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
mockedApiFetch.mockRejectedValue(new Error('network down'));

renderForgotPasswordScreen();
await renderForgotPasswordScreen();
await submitForgotPasswordEmail('user@example.com');

await waitFor(() => {
Expand All @@ -117,7 +117,7 @@ describe('ForgotPasswordScreen submission', () => {

describe('ForgotPasswordScreen navigation', () => {
it('redirects to login after a successful request delay', async () => {
renderForgotPasswordScreen();
await renderForgotPasswordScreen();
await submitForgotPasswordEmail('user@example.com');

await screen.findByText(ACCOUNT_EXISTS_MESSAGE_PATTERN);
Expand All @@ -130,16 +130,16 @@ describe('ForgotPasswordScreen navigation', () => {
});

it('navigates to login from both states (not history back, which may be invalid)', async () => {
renderForgotPasswordScreen();
await renderForgotPasswordScreen();

fireEvent.press(screen.getByText('Back to login'));
await fireEvent.press(screen.getByText('Back to login'));
expect(mockReplace).toHaveBeenCalledWith('/login');
expect(mockBack).not.toHaveBeenCalled();

await submitForgotPasswordEmail('user@example.com');
await screen.findByText(ACCOUNT_EXISTS_MESSAGE_PATTERN);

fireEvent.press(screen.getByText('Back to login'));
await fireEvent.press(screen.getByText('Back to login'));
expect(mockReplace).toHaveBeenCalledWith('/login');
});
});
Loading
Loading