@@ -28,6 +28,13 @@ function render(
|
||||
context = 'finance',
|
||||
canCorrect = true,
|
||||
sourceId = 3,
|
||||
canAuthoriseRelease = false,
|
||||
release: {
|
||||
id: number;
|
||||
authorised_by: number;
|
||||
authorised_at: string;
|
||||
reason: string;
|
||||
} | null = null,
|
||||
) {
|
||||
return renderToStaticMarkup(
|
||||
<App
|
||||
@@ -51,6 +58,8 @@ function render(
|
||||
organizationAccess: { permissions: ['finance'] },
|
||||
history: [{ ...declaration, id: sourceId }],
|
||||
canCorrect,
|
||||
canAuthoriseRelease,
|
||||
release,
|
||||
declarations: {
|
||||
data: [],
|
||||
prev_page_url: null,
|
||||
@@ -63,6 +72,42 @@ function render(
|
||||
/>,
|
||||
);
|
||||
}
|
||||
test('direction release preparation requires explicit capability and never submits on recovery', () => {
|
||||
vi.spyOn(router, 'restore').mockImplementation((key) =>
|
||||
key ===
|
||||
`${identity}:correction:3:${declaration.declared_at}:false:release:data`
|
||||
? {
|
||||
reason: 'DIRECTION-RELEASE-DRAFT',
|
||||
operation_key: 'synthetic-operation',
|
||||
}
|
||||
: undefined,
|
||||
);
|
||||
const post = vi.spyOn(router, 'post');
|
||||
const html = render(true, 7, 4, 'finance', false, 3, true);
|
||||
expect(html).toContain('DIRECTION-RELEASE-DRAFT');
|
||||
expect(html).toContain('Autorizar levantamento');
|
||||
expect(html).toContain('data-preparation-dirty="true"');
|
||||
expect(render(true, 8, 4, 'finance', false, 3, true)).not.toContain(
|
||||
'DIRECTION-RELEASE-DRAFT',
|
||||
);
|
||||
expect(render(true, 7, 4, 'finance', false, 3, false)).not.toContain(
|
||||
'Autorizar levantamento',
|
||||
);
|
||||
expect(post).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('released declaration retains its history and shows the direction decision', () => {
|
||||
const html = render(true, 7, 4, 'finance', false, 3, false, {
|
||||
id: 1,
|
||||
authorised_by: 9,
|
||||
authorised_at: '2026-11-28T09:00:00Z',
|
||||
reason: 'DIRECTION-AUTHORISED-QA',
|
||||
});
|
||||
expect(html).toContain('Impedimento levantado pela direcção');
|
||||
expect(html).toContain('Original synthetic conflict');
|
||||
expect(html).toContain('DIRECTION-AUTHORISED-QA');
|
||||
expect(html).not.toContain('Autorizar levantamento</button>');
|
||||
});
|
||||
test('personal declaration preparation remains private to its actor company and context without submitting', () => {
|
||||
vi.spyOn(router, 'restore').mockImplementation((key) =>
|
||||
key === `${identity}:new:data`
|
||||
|
||||
Reference in New Issue
Block a user