updates on the logic on the skills and settings tab

This commit is contained in:
2026-10-06 20:58:15 +05:30
parent 21775fe6f9
commit 8dca169b83
5 changed files with 74 additions and 5 deletions

View File

@@ -12,6 +12,9 @@ jest.mock('lucide-react', () =>
);
jest.mock('@/lib/assistant/scan');
jest.mock('@/lib/assistant/agent/AgentFactory');
// The "Configure skills" button is the owner login's only.
let mockAuth = { user: { email: 'admin@doormile.com', role: 'admin' }, isClient: false };
jest.mock('@/lib/AuthContext', () => ({ useAuth: () => mockAuth }));
const createTestQueryClient = () => new QueryClient({ defaultOptions: { queries: { retry: false } } });
@@ -112,6 +115,26 @@ describe('AgentOperationsBanner', () => {
expect(screen.getByTestId('where')).toHaveTextContent('/doormile/settings?tab=skills');
});
it('offers "Configure skills" to nobody but the owner login', async () => {
scanModule.scanBookings.mockResolvedValue({ rows: [], truncated: false });
AgentFactory.synthesizeDefaultAgent.mockReturnValue({ evaluateTelemetry: () => [] });
const owner = mockAuth;
try {
for (const who of [
{ user: { email: 'ops@doormile.com', role: 'admin' }, isClient: false },
{ user: { email: 'ops@client.test', role: 'manager', tenantid: 4 }, isClient: true },
]) {
mockAuth = who;
const { unmount } = renderBanner();
await screen.findAllByText(/./);
expect(screen.queryByRole('button', { name: /Configure skills/i })).toBeNull();
unmount();
}
} finally {
mockAuth = owner;
}
});
it('says when it is running on default thresholds, and stops once the registry answers', async () => {
scanModule.scanBookings.mockResolvedValue({ rows: [], truncated: false });
AgentFactory.synthesizeDefaultAgent.mockReturnValue({ evaluateTelemetry: () => [] });

View File

@@ -36,6 +36,8 @@ jest.mock('@/api/doormile', () => {
});
jest.mock('@/api/doormile/notify', () => ({ OpenToast: jest.fn() }));
const mockAuth = { user: { email: 'admin@doormile.com', role: 'admin' }, isClient: false };
jest.mock('@/lib/AuthContext', () => ({ useAuth: () => mockAuth }));
const api = require('@/api/doormile');
const { OpenToast } = require('@/api/doormile/notify');

View File

@@ -0,0 +1,23 @@
jest.mock('lucide-react', () => new Proxy({}, { get: (_t, prop) => (prop === '__esModule' ? true : () => null) }));
jest.mock('@/pages/doormile/customers/Customers', () => () => null);
jest.mock('@/pages/doormile/reports/Profitability', () => () => null);
jest.mock('@/pages/doormile/settings/agentStudio/AgentStudio', () => () => null);
jest.mock('@/lib/AuthContext', () => ({ useAuth: () => ({}) }));
import { settingsTabsFor } from '@/pages/doormile/settings/Settings';
import { canOnboardClients } from '@/lib/clientOnboarding';
const ids = (isOwner) => settingsTabsFor(isOwner).map((t) => t.id);
describe('Settings tabs per login', () => {
test('admin@doormile.com sees Skills & Tools', () => {
expect(ids(canOnboardClients({ email: 'admin@doormile.com', role: 'admin' }, false))).toEqual([
'profitability', 'customers', 'skills',
]);
});
test('other Doormile staff and clients do not', () => {
expect(ids(canOnboardClients({ email: 'ops@doormile.com', role: 'admin' }, false))).toEqual(['profitability', 'customers']);
expect(ids(canOnboardClients({ email: 'admin@doormile.com', role: 'admin' }, true))).toEqual(['profitability', 'customers']);
});
});