updates on auth for the login creds and data linkage and updates on the deliveries page and queries section and updates on the test files
This commit is contained in:
@@ -270,6 +270,32 @@ describe('AuthContext', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('isClient role determination', () => {
|
||||
it('should detect client for info@dailygrubs.com', async () => {
|
||||
readStoredToken.mockReturnValue('jwt-abc');
|
||||
readStoredUser.mockReturnValue({ email: 'info@dailygrubs.com', tenantid: 12 });
|
||||
const { result } = renderAuth();
|
||||
await waitFor(() => expect(result.current.authChecked).toBe(true));
|
||||
expect(result.current.isClient).toBe(true);
|
||||
});
|
||||
|
||||
it('should detect client for user with tenantid', async () => {
|
||||
readStoredToken.mockReturnValue('jwt-abc');
|
||||
readStoredUser.mockReturnValue({ email: 'client@partner.com', tenantid: 5 });
|
||||
const { result } = renderAuth();
|
||||
await waitFor(() => expect(result.current.authChecked).toBe(true));
|
||||
expect(result.current.isClient).toBe(true);
|
||||
});
|
||||
|
||||
it('should not mark super admin / staff with tenantid 0 as client', async () => {
|
||||
readStoredToken.mockReturnValue('jwt-abc');
|
||||
readStoredUser.mockReturnValue({ email: 'admin@doormile.com', tenantid: '0' });
|
||||
const { result } = renderAuth();
|
||||
await waitFor(() => expect(result.current.authChecked).toBe(true));
|
||||
expect(result.current.isClient).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('useAuth outside a provider', () => {
|
||||
it('should throw a named error rather than returning undefined', () => {
|
||||
// Silent undefined here would render an unauthenticated shell as if it
|
||||
|
||||
Reference in New Issue
Block a user