import { render, screen } from '@testing-library/react'; import { beforeEach, describe, expect, it, vi } from 'vitest'; import api from '../services/api'; import ApprovalsPage from './ApprovalsPage'; vi.mock('../services/api', () => ({ default: { get: vi.fn(), post: vi.fn(), put: vi.fn() } })); vi.mock('react-hot-toast', () => ({ default: { success: vi.fn(), error: vi.fn() } })); const item = (id: string, category: string, status = 'PENDING') => ({ id, category, status, department: category === 'SEO' ? 'SEO' : 'B2B', title: id, payload: {}, createdAt: '2026-10-19T10:00:00Z', }); describe('operational authorization boundary', () => { beforeEach(() => { vi.clearAllMocks(); vi.mocked(api.get).mockResolvedValue({ data: { success: true, data: [item('supplier-action', 'B2B_SUPPLIER_STRATEGY'), item('seo-approval', 'SEO')], meta: { pendingCount: 2 }, } }); }); it('does not expose a supplier manager action as authorization while SEO remains', async () => { render(); expect(await screen.findByText('seo-approval')).toBeInTheDocument(); expect(screen.queryByText('supplier-action')).not.toBeInTheDocument(); expect(screen.getAllByRole('button', { name: /تایید و صدور مجوز اجرا/ })).toHaveLength(1); expect(screen.getByText(/1 پیشنهاد منتظر تصمیم شما/)).toBeInTheDocument(); }); });