test: refs #5926 simplify test

This commit is contained in:
Alex Moreno 2025-03-21 13:54:56 +01:00
parent 63cf602ab2
commit 7e0ca4ce6d
2 changed files with 8 additions and 6 deletions
src
composables/__tests__
pages/Worker/Card

View File

@ -6,10 +6,12 @@ const session = useSession();
const token = session.getToken();
describe('downloadFile', () => {
const baseUrl = 'http://localhost:9000';
let defaulCreateObjectURL;
beforeAll(() => {
vi.mock('src/composables/getUrl', () => ({
getUrl: vi.fn().mockResolvedValue(''),
}));
defaulCreateObjectURL = window.URL.createObjectURL;
window.URL.createObjectURL = vi.fn(() => 'blob:http://localhost:9000/blob-id');
});
@ -22,15 +24,14 @@ describe('downloadFile', () => {
headers: { 'content-disposition': 'attachment; filename="test-file.txt"' },
};
vi.spyOn(axios, 'get').mockImplementation((url) => {
if (url == 'Urls/getUrl') return Promise.resolve({ data: baseUrl });
else if (url.includes('downloadFile')) return Promise.resolve(res);
if (url.includes('downloadFile')) return Promise.resolve(res);
});
await downloadFile(1);
expect(axios.get).toHaveBeenCalledWith(
`${baseUrl}/api/dms/1/downloadFile?access_token=${token}`,
{ responseType: 'blob' }
`/api/dms/1/downloadFile?access_token=${token}`,
{ responseType: 'blob' },
);
});
});

View File

@ -210,7 +210,6 @@ function isSigned(row) {
openConfirmationModal(
t('Sign PDA'),
t('Are you sure you want to send it?'),
() => sendToTablet([row]),
)
"
@ -306,4 +305,6 @@ es:
Do you want to remove this PDA?: ¿Desea eliminar este PDA?
You can only have one PDA: Solo puedes tener un PDA si no eres autonomo
This PDA is already assigned to another user: Este PDA ya está asignado a otro usuario
Are you sure you want to send it?: ¿Seguro que quieres enviarlo?
Sign PDA: Firmar PDA
</i18n>