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:
@@ -193,6 +193,16 @@ describe('deriveDeliveryStatus', () => {
|
||||
it('should still return picked for a Collected_By_Miler booking with no consignment', () => {
|
||||
expect(deriveDeliveryStatus({ status: 'Collected_By_Miler' })).toBe('picked');
|
||||
});
|
||||
|
||||
it('should keep Converted_To_Consignment as picked when joined consignment only has generic status: Active', () => {
|
||||
const map = new Map([['40', { status: 'Active' }]]);
|
||||
expect(deriveDeliveryStatus({ status: 'Converted_To_Consignment', consignmentid: 40 }, map)).toBe('picked');
|
||||
});
|
||||
|
||||
it('should bump Converted_To_Consignment to active when joined consignment has consignmentstatus: Out_for_Delivery', () => {
|
||||
const map = new Map([['40', { status: 'Active', consignmentstatus: 'Out_for_Delivery' }]]);
|
||||
expect(deriveDeliveryStatus({ status: 'Converted_To_Consignment', consignmentid: 40 }, map)).toBe('active');
|
||||
});
|
||||
});
|
||||
|
||||
describe('mapBookingStatusToDeliveryStatus', () => {
|
||||
|
||||
@@ -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