@@ -4,7 +4,21 @@ import { afterEach, expect, test, vi } from 'vitest';
|
||||
import Invoices from '@/pages/invoices/index';
|
||||
|
||||
afterEach(() => vi.restoreAllMocks());
|
||||
function render(actorId = 7) {
|
||||
test.each([true, false])(
|
||||
'invoice consultation has a focusable document destination and separates registration (%s)',
|
||||
(canManage) => {
|
||||
const html = render(7, canManage);
|
||||
expect(html).toContain('href="#invoice-documents"');
|
||||
expect(html).toContain('id="invoice-documents" tabindex="-1"');
|
||||
expect(html).toContain('lg:scroll-mt-72');
|
||||
expect(html.includes('href="#invoice-registration"')).toBe(canManage);
|
||||
expect(html.includes('id="invoice-registration"')).toBe(canManage);
|
||||
expect(html).toContain('Sem facturas disponíveis para esta ordem.');
|
||||
expect(html).not.toContain('Sem facturas registadas nesta empresa.');
|
||||
},
|
||||
);
|
||||
|
||||
function render(actorId = 7, canManage = true) {
|
||||
return renderToStaticMarkup(
|
||||
<App
|
||||
initialComponent={Invoices}
|
||||
@@ -18,7 +32,7 @@ function render(actorId = 7) {
|
||||
errors: {},
|
||||
auth: { user: { id: actorId, tenant_id: 3 } },
|
||||
focusOrderId: 2,
|
||||
canManage: true,
|
||||
canManage,
|
||||
invoices: {
|
||||
data: [],
|
||||
current_page: 1,
|
||||
|
||||
Reference in New Issue
Block a user