@@ -0,0 +1,101 @@
|
||||
import { App, router } from '@inertiajs/react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { afterEach, expect, test, vi } from 'vitest';
|
||||
import Invoices from '@/pages/invoices/index';
|
||||
|
||||
afterEach(() => vi.restoreAllMocks());
|
||||
function render(actorId = 7) {
|
||||
return renderToStaticMarkup(
|
||||
<App
|
||||
initialComponent={Invoices}
|
||||
initialPage={{
|
||||
component: 'invoices/index',
|
||||
url: '/facturas?purchase_order_id=2',
|
||||
version: null,
|
||||
clearHistory: false,
|
||||
encryptHistory: true,
|
||||
props: {
|
||||
errors: {},
|
||||
auth: { user: { id: actorId, tenant_id: 3 } },
|
||||
focusOrderId: 2,
|
||||
canManage: true,
|
||||
invoices: {
|
||||
data: [],
|
||||
current_page: 1,
|
||||
last_page: 1,
|
||||
prev_page_url: null,
|
||||
next_page_url: null,
|
||||
total: 0,
|
||||
},
|
||||
orders: [
|
||||
{
|
||||
id: 2,
|
||||
number: 'QA-OC',
|
||||
currency: 'USD',
|
||||
supplier: 'Fornecedor sintético',
|
||||
items: [
|
||||
{
|
||||
id: 5,
|
||||
requisition_item_id: 12,
|
||||
description: 'Material sintético',
|
||||
unit: 'cx',
|
||||
unit_price_minor: 10000,
|
||||
tax_rate: '0',
|
||||
},
|
||||
],
|
||||
budgetDistributionOptions: [
|
||||
{
|
||||
allocation_key: 'qa-a',
|
||||
line_id: 12,
|
||||
centre_id: 4,
|
||||
subtotal: '50.00',
|
||||
total: '50.00',
|
||||
line_label: 'Material sintético',
|
||||
centre_label: 'Centro sintético',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
}
|
||||
test('returning from explicit commitment amendment restores invoice fields and MZN parcels within the same actor context', () => {
|
||||
vi.spyOn(router, 'restore').mockImplementation((key) =>
|
||||
key === 'invoice-preparation:3:7:2:data'
|
||||
? {
|
||||
number: 'QA-UNSAVED',
|
||||
issued_on: '2026-11-22',
|
||||
subtotal: '60.00',
|
||||
tax: '0.00',
|
||||
total: '60.00',
|
||||
reason: 'Imputação sintética ainda em preparação.',
|
||||
items: [
|
||||
{
|
||||
purchase_order_item_id: 5,
|
||||
quantity: '0.600',
|
||||
unit: 'cx',
|
||||
unit_price: '100.00',
|
||||
tax_rate: '0',
|
||||
},
|
||||
],
|
||||
budget_distribution_preparation: [
|
||||
{
|
||||
allocation_key: 'qa-a',
|
||||
line_id: 12,
|
||||
centre_id: 4,
|
||||
subtotal: '30.00',
|
||||
total: '30.00',
|
||||
},
|
||||
],
|
||||
}
|
||||
: undefined,
|
||||
);
|
||||
const html = render();
|
||||
expect(html).toContain('value="QA-UNSAVED"');
|
||||
expect(html).toContain('value="0.600"');
|
||||
expect(html).toContain('value="30.00"');
|
||||
expect(html).toContain('/ordens/2/reafectacao');
|
||||
expect(render(8)).not.toContain('value="QA-UNSAVED"');
|
||||
});
|
||||
Reference in New Issue
Block a user