@@ -0,0 +1,113 @@
|
||||
import { App } from '@inertiajs/react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { expect, test } from 'vitest';
|
||||
import ImportEstimate from '@/pages/supply/import-estimate';
|
||||
|
||||
function renderPlan(linked = false) {
|
||||
const page = { data: [], prev_page_url: null, next_page_url: null };
|
||||
const source = {
|
||||
id: 4,
|
||||
version: 2,
|
||||
snapshot: {
|
||||
item: { description: 'Synthetic valued item' },
|
||||
legal_rule: {
|
||||
data: { official_reference: 'Preserved official source' },
|
||||
},
|
||||
result: {
|
||||
lines: [
|
||||
{
|
||||
key: 'duty-line',
|
||||
kind: 'duty',
|
||||
label: 'Synthetic documented duty',
|
||||
method: 'ad_valorem',
|
||||
amount_minor: 750,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
return renderToStaticMarkup(
|
||||
<App
|
||||
initialComponent={ImportEstimate}
|
||||
initialPage={{
|
||||
component: 'supply/import-estimate',
|
||||
url: '/qa',
|
||||
version: null,
|
||||
clearHistory: false,
|
||||
encryptHistory: true,
|
||||
props: {
|
||||
errors: {},
|
||||
requisition: {
|
||||
id: 1,
|
||||
number: 'QA',
|
||||
status: 'draft',
|
||||
total_minor: 10000,
|
||||
},
|
||||
actorId: 2,
|
||||
tenantId: 3,
|
||||
canPrepare: true,
|
||||
nativeChanged: false,
|
||||
budgets: page,
|
||||
history: page,
|
||||
legalAmounts: [source],
|
||||
latest: linked
|
||||
? {
|
||||
id: 5,
|
||||
version: 1,
|
||||
state: 'prepared',
|
||||
reason: 'Synthetic scenario',
|
||||
data: {
|
||||
budget_id: 1,
|
||||
components: [
|
||||
{
|
||||
key: 'duty',
|
||||
kind: 'duty',
|
||||
status: 'known',
|
||||
basis: 'Preserved selected calculation',
|
||||
subtotal_minor: 750,
|
||||
tax_minor: 0,
|
||||
total_minor: 750,
|
||||
},
|
||||
],
|
||||
},
|
||||
snapshot: {
|
||||
plan: {
|
||||
complete: true,
|
||||
budget_amount_minor: 10750,
|
||||
known_total_minor: 10750,
|
||||
unknown: [],
|
||||
},
|
||||
legal_sources: {
|
||||
duty: {
|
||||
estimate_id: 4,
|
||||
estimate_version: 2,
|
||||
charge_key: 'duty-line',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
: null,
|
||||
},
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
}
|
||||
|
||||
test('native import preparation offers legal source reuse and additional parcels without silently selecting a value', () => {
|
||||
const html = renderPlan();
|
||||
expect(html).toContain('Reutilizar uma imposição calculada');
|
||||
expect(html).toContain('Synthetic valued item');
|
||||
expect(html).toContain('7.50 MZN');
|
||||
expect(html).toContain('Acrescentar parcela desta família');
|
||||
expect(html).not.toContain('O total conserva a fonte seleccionada');
|
||||
});
|
||||
|
||||
test('a preserved legal amount retains explicit budget tax treatment and a deliberate manual-detach action', () => {
|
||||
const html = renderPlan(true);
|
||||
expect(html).toContain('O total conserva a fonte seleccionada');
|
||||
expect(html).toContain('divisão entre base e imposto');
|
||||
expect(html).toContain('retirar ligação e conservar os valores');
|
||||
expect(html.match(/<option[^>]*value="4:duty-line"[^>]*>/)?.[0]).toContain(
|
||||
'selected=""',
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user