updates on the logic on the skills and settings tab
This commit is contained in:
@@ -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: () => [] });
|
||||
|
||||
Reference in New Issue
Block a user