fix(blogs): enforce atomic optimistic update concurrency
Deploy Canina / deploy (push) Successful in 52s

This commit is contained in:
Canina Automation committed 2026-10-27 08:20:33 +00:00
1 parent 0e952ef701
commit 0ad39bb92c
6 files changed
+202 -35

No files matched your search

@@ -1,31 +1,15 @@
import { render, screen } from '@testing-library/react';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import api from '../services/api';
import ApprovalsPage from './ApprovalsPage';
import { describe, expect, it } from 'vitest';
import routes from '../routes/adminRoutes.tsx?raw';
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',
});
const pages = import.meta.glob('./*.tsx');
// Approvals and manager actions were removed in effe30e. Keep this boundary
// covered without importing the deleted page or restoring its obsolete UI.
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(<ApprovalsPage />);
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();
it('does not register removed approvals or manager-action pages', () => {
expect(routes).not.toMatch(/ApprovalsPage|ManagerActionsPage/);
expect(routes).not.toMatch(/path:\s*['"](?:approvals|manager-actions)(?:\/\*)?['"]/);
expect(pages).not.toHaveProperty('./ApprovalsPage.tsx');
expect(pages).not.toHaveProperty('./ManagerActionsPage.tsx');
});
});