🔒 fix: resolve session persistence post password reset (#5077)

*  feat: Implement session management with CRUD operations and integrate into user workflows

*  refactor: Update session model import paths and enhance session creation logic in AuthService

*  refactor: Validate session and user ID formats in session management functions

*  style: Enhance UI components with improved styling and accessibility features

* chore: Update login form tests to use getByTestId instead of getByRole, remove console.log()

* chore: Update login form tests to use getByTestId instead of getByRole

---------

Co-authored-by: Danny Avila <danny@librechat.ai>
This commit is contained in:
Marco Beretta 2024-12-23 11:12:07 +01:00 committed by GitHub
parent 9bca2ae953
commit bdb222d5f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 402 additions and 116 deletions

View file

@ -1,6 +1,6 @@
import reactRouter from 'react-router-dom';
import userEvent from '@testing-library/user-event';
import { render, waitFor } from 'test/layout-test-utils';
import { getByTestId, render, waitFor } from 'test/layout-test-utils';
import * as mockDataProvider from 'librechat-data-provider/react-query';
import type { TStartupConfig } from 'librechat-data-provider';
import AuthLayout from '~/components/Auth/AuthLayout';
@ -117,7 +117,7 @@ test('renders login form', () => {
const { getByLabelText, getByRole } = setup();
expect(getByLabelText(/email/i)).toBeInTheDocument();
expect(getByLabelText(/password/i)).toBeInTheDocument();
expect(getByRole('button', { name: /Sign in/i })).toBeInTheDocument();
expect(getByTestId(document.body, 'login-button')).toBeInTheDocument();
expect(getByRole('link', { name: /Sign up/i })).toBeInTheDocument();
expect(getByRole('link', { name: /Sign up/i })).toHaveAttribute('href', '/register');
expect(getByRole('link', { name: /Continue with Google/i })).toBeInTheDocument();
@ -144,7 +144,7 @@ test('renders login form', () => {
test('calls loginUser.mutate on login', async () => {
const mutate = jest.fn();
const { getByLabelText, getByRole } = setup({
const { getByLabelText } = setup({
// @ts-ignore - we don't need all parameters of the QueryObserverResult
useLoginUserReturnValue: {
isLoading: false,
@ -155,7 +155,7 @@ test('calls loginUser.mutate on login', async () => {
const emailInput = getByLabelText(/email/i);
const passwordInput = getByLabelText(/password/i);
const submitButton = getByRole('button', { name: /Sign in/i });
const submitButton = getByTestId(document.body, 'login-button');
await userEvent.type(emailInput, 'test@test.com');
await userEvent.type(passwordInput, 'password');
@ -165,7 +165,7 @@ test('calls loginUser.mutate on login', async () => {
});
test('Navigates to / on successful login', async () => {
const { getByLabelText, getByRole, history } = setup({
const { getByLabelText, history } = setup({
// @ts-ignore - we don't need all parameters of the QueryObserverResult
useLoginUserReturnValue: {
isLoading: false,
@ -185,7 +185,7 @@ test('Navigates to / on successful login', async () => {
const emailInput = getByLabelText(/email/i);
const passwordInput = getByLabelText(/password/i);
const submitButton = getByRole('button', { name: /Sign in/i });
const submitButton = getByTestId(document.body, 'login-button');
await userEvent.type(emailInput, 'test@test.com');
await userEvent.type(passwordInput, 'password');

View file

@ -1,4 +1,4 @@
import { render } from 'test/layout-test-utils';
import { render, getByTestId } from 'test/layout-test-utils';
import userEvent from '@testing-library/user-event';
import * as mockDataProvider from 'librechat-data-provider/react-query';
import type { TStartupConfig } from 'librechat-data-provider';
@ -112,7 +112,7 @@ test('submits login form', async () => {
);
const emailInput = getByLabelText(/email/i);
const passwordInput = getByLabelText(/password/i);
const submitButton = getByRole('button', { name: /Sign in/i });
const submitButton = getByTestId(document.body, 'login-button');
await userEvent.type(emailInput, 'test@example.com');
await userEvent.type(passwordInput, 'password');
@ -127,7 +127,7 @@ test('displays validation error messages', async () => {
);
const emailInput = getByLabelText(/email/i);
const passwordInput = getByLabelText(/password/i);
const submitButton = getByRole('button', { name: /Sign in/i });
const submitButton = getByTestId(document.body, 'login-button');
await userEvent.type(emailInput, 'test');
await userEvent.type(passwordInput, 'pass');