0
0
Fork 0

test: 5926: imrpove

This commit is contained in:
Javier Segarra 2024-06-03 14:13:02 +02:00
parent c3d08c94d1
commit 3eaefe8701
2 changed files with 39 additions and 36 deletions

View File

@ -65,16 +65,16 @@ const handleSendToTablet = async (row) => {
console.error('Error removing department');
}
};
function checkFileFocuware({ deviceProductionFk }) {
function checkFileFocuware({ deviceProductionFk }, signed) {
return axios.post(`Docuwares/${deviceProductionFk}/checkFile`, {
fileCabinet: 'hr',
signed: true,
signed,
});
}
const handleRefreshDocuware = async (row) => {
try {
if (isProduction()) {
await checkFileFocuware(row);
await checkFileFocuware(row, true);
}
notify(t('PDA Signed'), 'positive');
row.isSigned = true;
@ -98,16 +98,29 @@ const handleDownloadDocuware = async (row) => {
};
async function fetchDocuware(deviceProductions) {
let promises = deviceProductions.map((device) => checkFileFocuware(device));
promises = await Promise.all(promises);
promises.forEach((promise) => {
let promisesIsDocuware = deviceProductions.map((device) =>
checkFileFocuware(device, false)
);
let promisesIsSigned = [];
promisesIsDocuware = await Promise.all(promisesIsDocuware);
promisesIsDocuware.forEach((promise) => {
const id = +promise.config.url.match(/\d+/)[0];
const deviceProduction = deviceProductions.find(
({ deviceProductionFk }) => deviceProductionFk === id
);
if (!deviceProduction) return;
if (promise.data) deviceProduction.isSigned = promise.data;
deviceProduction.isDocuware = promise.data;
if (promise.data)
promisesIsSigned.push(checkFileFocuware(deviceProduction, true));
});
promisesIsSigned = await Promise.all(promisesIsSigned);
promisesIsSigned.forEach((promise) => {
const id = +promise.config.url.match(/\d+/)[0];
const deviceProduction = deviceProductions.find(
({ deviceProductionFk }) => deviceProductionFk === id
);
if (!deviceProduction) return;
deviceProduction.isSigned = !!promise.data.id;
});
loadingDocuware.value = false;

View File

@ -1,11 +1,11 @@
describe.only('WorkerPda', () => {
describe('WorkerPda', () => {
const deviceProductionField =
'.vn-row > .q-field > .q-field__inner > .q-field__control > .q-field__control-container';
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/worker/1110/pda`);
cy.waitForElement('.q-page', { timeout: 7000 });
cy.waitForElement('.q-page');
});
it('assign pda', () => {
@ -14,24 +14,11 @@ describe.only('WorkerPda', () => {
cy.get('.vn-row > #simSerialNumber').type('123{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created');
});
describe.only(' Row Actions', () => {
it.skip('delete pda', () => {
cy.get(
':nth-child(1) > .vn-row > :nth-child(5) > .q-btn__content > .q-icon'
).click();
cy.get(
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block'
).click();
cy.get('.q-notification__message').should('have.text', 'PDA deallocated');
});
describe.only(' Docuware Flow ', () => {
describe.skip(' NOT Signed ', () => {
describe(' Row Actions', () => {
describe(' Docuware Flow ', () => {
describe(' NOT Signed ', () => {
beforeEach(() => {
cy.intercept(
'POST',
'**/checkFile',
'false' // and force the response to be: []
).as('not_signed'); // and assign an alias
cy.intercept('POST', '**/checkFile', 'false').as('not_signed');
});
it('docuware', () => {
// Btn icon-client is present
@ -54,10 +41,6 @@ describe.only('WorkerPda', () => {
cy.get(
':nth-child(1) > .vn-row > :nth-child(6) > .q-btn__content > .q-icon'
).click();
// Btn confirm is clicked
// cy.get(
// '.q-card__actions > .q-btn--unelevated > .q-btn__content > .block'
// ).click();
// Btn cloud_download is present
cy.get(
':nth-child(1) > .vn-row > :nth-child(6) > .q-btn__content > .q-icon'
@ -68,13 +51,9 @@ describe.only('WorkerPda', () => {
).click();
});
});
describe.only(' Is Signed ', () => {
describe(' Is Signed ', () => {
beforeEach(() => {
cy.intercept(
'POST',
'**/checkFile',
'true' // and force the response to be: []
).as('signed'); // and assign an alias
cy.intercept('POST', '**/checkFile', { id: 1 }).as('not_docuware');
});
it('docuware', () => {
// Btn cloud_download is present
@ -88,5 +67,16 @@ describe.only('WorkerPda', () => {
});
});
});
describe(' Other actions ', () => {
it('delete pda', () => {
cy.get(
':nth-child(1) > .vn-row > :nth-child(5) > .q-btn__content > .q-icon'
).click();
cy.get(
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block'
).click();
cy.get('.q-notification__message').should('have.text', 'PDA deallocated');
});
});
});
});