fix both admin and company login
Build & Push / Pipeline Tests (push) Failing after 1m27s
Build & Push / Build & Push Docker Image (push) Has been skipped
Test / Type Check (all packages) (push) Successful in 55s
Test / API Unit Tests (push) Successful in 1m9s
Test / Homepage Unit Tests (push) Successful in 50s
Test / Carplace Unit Tests (push) Has been cancelled
Test / Admin Unit Tests (push) Has been cancelled
Test / Dashboard Unit Tests (push) Has been cancelled
Test / API Integration Tests (push) Has been cancelled
Build & Push / Pipeline Tests (push) Failing after 1m27s
Build & Push / Build & Push Docker Image (push) Has been skipped
Test / Type Check (all packages) (push) Successful in 55s
Test / API Unit Tests (push) Successful in 1m9s
Test / Homepage Unit Tests (push) Successful in 50s
Test / Carplace Unit Tests (push) Has been cancelled
Test / Admin Unit Tests (push) Has been cancelled
Test / Dashboard Unit Tests (push) Has been cancelled
Test / API Integration Tests (push) Has been cancelled
This commit is contained in:
@@ -40,7 +40,7 @@ describe('SignInForm auth routing', () => {
|
||||
));
|
||||
});
|
||||
|
||||
it('uses employee login only on the default sign-in page', async () => {
|
||||
it('uses unified login on the default sign-in page', async () => {
|
||||
vi.mocked(fetch).mockResolvedValueOnce(
|
||||
jsonResponse(200, { data: { employee: { id: 'employee_1' } } }),
|
||||
);
|
||||
@@ -50,7 +50,7 @@ describe('SignInForm auth routing', () => {
|
||||
|
||||
await waitFor(() => expect(fetch).toHaveBeenCalledTimes(1));
|
||||
expect(fetch).toHaveBeenCalledWith(
|
||||
`${API_BASE}/auth/employee/login`,
|
||||
`${API_BASE}/auth/login`,
|
||||
expect.objectContaining({ method: 'POST' }),
|
||||
);
|
||||
expect(fetch).not.toHaveBeenCalledWith(
|
||||
@@ -59,30 +59,25 @@ describe('SignInForm auth routing', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('falls back to admin login when default employee login rejects the credentials', async () => {
|
||||
vi.mocked(fetch)
|
||||
.mockResolvedValueOnce(jsonResponse(401, { error: 'invalid_credentials' }))
|
||||
.mockResolvedValueOnce(jsonResponse(401, { error: 'totp_required' }));
|
||||
|
||||
it('shows invalid credentials when unified login rejects the credentials', async () => {
|
||||
render(<SignInForm locale="en" />);
|
||||
|
||||
await submitForm();
|
||||
|
||||
await waitFor(() => expect(fetch).toHaveBeenCalledTimes(2));
|
||||
await waitFor(() => expect(fetch).toHaveBeenCalledTimes(1));
|
||||
expect(fetch).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
`${API_BASE}/auth/employee/login`,
|
||||
`${API_BASE}/auth/login`,
|
||||
expect.objectContaining({ method: 'POST' }),
|
||||
);
|
||||
expect(fetch).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
expect(fetch).not.toHaveBeenCalledWith(
|
||||
`${API_BASE}/admin/auth/login`,
|
||||
expect.objectContaining({ method: 'POST' }),
|
||||
expect.anything(),
|
||||
);
|
||||
expect(await screen.findByText('Authentication code')).toBeInTheDocument();
|
||||
expect(await screen.findByText('Invalid email or password.')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('uses employee login only when the requested destination is a dashboard path', async () => {
|
||||
it('uses unified login when the requested destination is a dashboard path', async () => {
|
||||
vi.mocked(fetch).mockResolvedValueOnce(
|
||||
jsonResponse(200, { data: { employee: { id: 'employee_1' } } }),
|
||||
);
|
||||
@@ -93,7 +88,7 @@ describe('SignInForm auth routing', () => {
|
||||
|
||||
await waitFor(() => expect(fetch).toHaveBeenCalledTimes(1));
|
||||
expect(fetch).toHaveBeenCalledWith(
|
||||
`${API_BASE}/auth/employee/login`,
|
||||
`${API_BASE}/auth/login`,
|
||||
expect.objectContaining({ method: 'POST' }),
|
||||
);
|
||||
expect(fetch).not.toHaveBeenCalledWith(
|
||||
@@ -102,7 +97,7 @@ describe('SignInForm auth routing', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('uses admin login only when the admin portal is requested', async () => {
|
||||
it('uses unified login when the admin portal is requested', async () => {
|
||||
searchParams = new URLSearchParams('portal=admin');
|
||||
render(<SignInForm locale="en" />);
|
||||
|
||||
@@ -110,7 +105,7 @@ describe('SignInForm auth routing', () => {
|
||||
|
||||
await waitFor(() => expect(fetch).toHaveBeenCalledTimes(1));
|
||||
expect(fetch).toHaveBeenCalledWith(
|
||||
`${API_BASE}/admin/auth/login`,
|
||||
`${API_BASE}/auth/login`,
|
||||
expect.objectContaining({ method: 'POST' }),
|
||||
);
|
||||
expect(fetch).not.toHaveBeenCalledWith(
|
||||
@@ -119,7 +114,7 @@ describe('SignInForm auth routing', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('uses admin login when the requested destination is an admin path', async () => {
|
||||
it('uses unified login when the requested destination is an admin path', async () => {
|
||||
searchParams = new URLSearchParams('next=/admin/dashboard');
|
||||
render(<SignInForm locale="en" />);
|
||||
|
||||
@@ -127,12 +122,12 @@ describe('SignInForm auth routing', () => {
|
||||
|
||||
await waitFor(() => expect(fetch).toHaveBeenCalledTimes(1));
|
||||
expect(fetch).toHaveBeenCalledWith(
|
||||
`${API_BASE}/admin/auth/login`,
|
||||
`${API_BASE}/auth/login`,
|
||||
expect.objectContaining({ method: 'POST' }),
|
||||
);
|
||||
});
|
||||
|
||||
it('uses admin login when the requested destination is an absolute admin URL', async () => {
|
||||
it('uses unified login when the requested destination is an absolute admin URL', async () => {
|
||||
searchParams = new URLSearchParams('redirect=http://localhost:3000/admin/dashboard');
|
||||
render(<SignInForm locale="en" />);
|
||||
|
||||
@@ -140,7 +135,7 @@ describe('SignInForm auth routing', () => {
|
||||
|
||||
await waitFor(() => expect(fetch).toHaveBeenCalledTimes(1));
|
||||
expect(fetch).toHaveBeenCalledWith(
|
||||
`${API_BASE}/admin/auth/login`,
|
||||
`${API_BASE}/auth/login`,
|
||||
expect.objectContaining({ method: 'POST' }),
|
||||
);
|
||||
expect(fetch).not.toHaveBeenCalledWith(
|
||||
@@ -149,14 +144,14 @@ describe('SignInForm auth routing', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('uses admin login when the page forces admin auth mode', async () => {
|
||||
it('uses unified login when the page forces admin auth mode', async () => {
|
||||
render(<SignInForm locale="en" authMode="admin" />);
|
||||
|
||||
await submitForm();
|
||||
|
||||
await waitFor(() => expect(fetch).toHaveBeenCalledTimes(1));
|
||||
expect(fetch).toHaveBeenCalledWith(
|
||||
`${API_BASE}/admin/auth/login`,
|
||||
`${API_BASE}/auth/login`,
|
||||
expect.objectContaining({ method: 'POST' }),
|
||||
);
|
||||
expect(fetch).not.toHaveBeenCalledWith(
|
||||
@@ -165,7 +160,7 @@ describe('SignInForm auth routing', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('uses admin login on the admin sign-in path', async () => {
|
||||
it('uses unified login on the admin sign-in path', async () => {
|
||||
pathname = '/en/light/admin-sign-in';
|
||||
render(<SignInForm locale="en" />);
|
||||
|
||||
@@ -173,7 +168,7 @@ describe('SignInForm auth routing', () => {
|
||||
|
||||
await waitFor(() => expect(fetch).toHaveBeenCalledTimes(1));
|
||||
expect(fetch).toHaveBeenCalledWith(
|
||||
`${API_BASE}/admin/auth/login`,
|
||||
`${API_BASE}/auth/login`,
|
||||
expect.objectContaining({ method: 'POST' }),
|
||||
);
|
||||
expect(fetch).not.toHaveBeenCalledWith(
|
||||
|
||||
Reference in New Issue
Block a user