forked from verdnatura/salix-front
test: #5926 Mock API REquest
This commit is contained in:
parent
035a3cd0ae
commit
6c91fee139
|
@ -17,7 +17,7 @@ import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
const loadingDocuware = ref(true);
|
||||||
const paginate = ref();
|
const paginate = ref();
|
||||||
const dialog = ref();
|
const dialog = ref();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
@ -94,6 +94,27 @@ const handleDownloadDocuware = async (row) => {
|
||||||
console.error('Error removing department');
|
console.error('Error removing department');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function fetchDocuware(deviceProductions) {
|
||||||
|
let promises = deviceProductions.map(({ deviceProductionFk }) =>
|
||||||
|
axios.post(`Docuwares/${deviceProductionFk}/checkFile`, {
|
||||||
|
fileCabinet: 'hr',
|
||||||
|
signed: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
promises = await Promise.all(promises);
|
||||||
|
promises.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;
|
||||||
|
});
|
||||||
|
|
||||||
|
loadingDocuware.value = false;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -103,11 +124,7 @@ const handleDownloadDocuware = async (row) => {
|
||||||
@on-fetch="(data) => (deviceProductions = data)"
|
@on-fetch="(data) => (deviceProductions = data)"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<FetchData
|
|
||||||
:url="`docuwares/checkFile`"
|
|
||||||
@on-fetch="(data) => (deviceProductions = data)"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
ref="paginate"
|
ref="paginate"
|
||||||
data-key="WorkerPda"
|
data-key="WorkerPda"
|
||||||
|
@ -115,6 +132,7 @@ const handleDownloadDocuware = async (row) => {
|
||||||
:filter="{ where: { userFk: routeId } }"
|
:filter="{ where: { userFk: routeId } }"
|
||||||
order="id"
|
order="id"
|
||||||
auto-load
|
auto-load
|
||||||
|
@on-fetch="fetchDocuware"
|
||||||
>
|
>
|
||||||
<template #body="{ rows }">
|
<template #body="{ rows }">
|
||||||
<QCard
|
<QCard
|
||||||
|
@ -163,19 +181,30 @@ const handleDownloadDocuware = async (row) => {
|
||||||
{{ t('worker.pda.removePDA') }}
|
{{ t('worker.pda.removePDA') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QBtn>
|
</QBtn>
|
||||||
|
|
||||||
<QBtn
|
<QBtn
|
||||||
v-if="row.isSigned"
|
:loading="loadingDocuware"
|
||||||
icon="cloud_download"
|
v-if="!row.isDocuware"
|
||||||
|
icon="vn:client"
|
||||||
flat
|
flat
|
||||||
class="btn-delete"
|
class="btn-delete"
|
||||||
color="primary"
|
color="primary"
|
||||||
@click="handleDownloadDocuware(row)"
|
@click="
|
||||||
|
openConfirmationModal(
|
||||||
|
t('Sign PDA'),
|
||||||
|
t('Are you sure you want to send it?'),
|
||||||
|
|
||||||
|
() => handleSendToTablet(row)
|
||||||
|
)
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ t('worker.pda.download') }}
|
{{ t('worker.pda.sendToTablet') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QBtn>
|
</QBtn>
|
||||||
|
|
||||||
<QBtn
|
<QBtn
|
||||||
|
:loading="loadingDocuware"
|
||||||
v-if="row.isDocuware && !row.isSigned"
|
v-if="row.isDocuware && !row.isSigned"
|
||||||
icon="refresh"
|
icon="refresh"
|
||||||
flat
|
flat
|
||||||
|
@ -185,25 +214,18 @@ const handleDownloadDocuware = async (row) => {
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ t('worker.pda.refresh') }}
|
{{ t('worker.pda.refresh') }}
|
||||||
</QTooltip>
|
</QTooltip> </QBtn
|
||||||
</QBtn>
|
><QBtn
|
||||||
<QBtn
|
:loading="loadingDocuware"
|
||||||
v-if="!row.isDocuware"
|
v-if="row.isSigned"
|
||||||
icon="vn:client"
|
icon="cloud_download"
|
||||||
flat
|
flat
|
||||||
class="btn-delete"
|
class="btn-delete"
|
||||||
color="primary"
|
color="primary"
|
||||||
@click="
|
@click="handleDownloadDocuware(row)"
|
||||||
openConfirmationModal(
|
|
||||||
t('Are you sure you want to send it?'),
|
|
||||||
t('Sign PDA'),
|
|
||||||
|
|
||||||
() => handleSendToTablet(row)
|
|
||||||
)
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ t('worker.pda.sendToTablet') }}
|
{{ t('worker.pda.download') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QBtn>
|
</QBtn>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
describe('WorkerPda', () => {
|
describe.only('WorkerPda', () => {
|
||||||
const deviceProductionField =
|
const deviceProductionField =
|
||||||
'.vn-row > .q-field > .q-field__inner > .q-field__control > .q-field__control-container';
|
'.vn-row > .q-field > .q-field__inner > .q-field__control > .q-field__control-container';
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.viewport(1920, 1080);
|
cy.viewport(1920, 1080);
|
||||||
cy.login('developer');
|
cy.login('developer');
|
||||||
cy.visit(`/#/worker/1110/pda`);
|
cy.visit(`/#/worker/1110/pda`);
|
||||||
|
cy.waitForElement('.q-page', { timeout: 7000 });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('assign pda', () => {
|
it('assign pda', () => {
|
||||||
|
@ -13,12 +14,79 @@ describe('WorkerPda', () => {
|
||||||
cy.get('.vn-row > #simSerialNumber').type('123{enter}');
|
cy.get('.vn-row > #simSerialNumber').type('123{enter}');
|
||||||
cy.get('.q-notification__message').should('have.text', 'Data created');
|
cy.get('.q-notification__message').should('have.text', 'Data created');
|
||||||
});
|
});
|
||||||
|
describe.only(' Row Actions', () => {
|
||||||
it('delete pda', () => {
|
it.skip('delete pda', () => {
|
||||||
cy.get('.btn-delete').click();
|
cy.get(
|
||||||
|
':nth-child(1) > .vn-row > :nth-child(5) > .q-btn__content > .q-icon'
|
||||||
|
).click();
|
||||||
cy.get(
|
cy.get(
|
||||||
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block'
|
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block'
|
||||||
).click();
|
).click();
|
||||||
cy.get('.q-notification__message').should('have.text', 'PDA deallocated');
|
cy.get('.q-notification__message').should('have.text', 'PDA deallocated');
|
||||||
});
|
});
|
||||||
|
describe.only(' Docuware Flow ', () => {
|
||||||
|
describe.skip(' NOT Signed ', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.intercept(
|
||||||
|
'POST',
|
||||||
|
'**/checkFile',
|
||||||
|
'false' // and force the response to be: []
|
||||||
|
).as('not_signed'); // and assign an alias
|
||||||
|
});
|
||||||
|
it('docuware', () => {
|
||||||
|
// Btn icon-client is present
|
||||||
|
cy.get(
|
||||||
|
':nth-child(1) > .vn-row > :nth-child(6) > .q-btn__content > .q-icon'
|
||||||
|
).should('have.class', 'icon-client');
|
||||||
|
// Btn icon-client is clicked
|
||||||
|
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 refresh is present
|
||||||
|
cy.get(
|
||||||
|
':nth-child(1) > .vn-row > :nth-child(6) > .q-btn__content > .q-icon'
|
||||||
|
).should('have.text', 'refresh');
|
||||||
|
// Btn refresh is clicked
|
||||||
|
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'
|
||||||
|
).should('have.text', 'cloud_download');
|
||||||
|
// Btn cloud_download is clicked
|
||||||
|
cy.get(
|
||||||
|
':nth-child(1) > .vn-row > :nth-child(6) > .q-btn__content > .q-icon'
|
||||||
|
).click();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe.only(' Is Signed ', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.intercept(
|
||||||
|
'POST',
|
||||||
|
'**/checkFile',
|
||||||
|
'true' // and force the response to be: []
|
||||||
|
).as('signed'); // and assign an alias
|
||||||
|
});
|
||||||
|
it('docuware', () => {
|
||||||
|
// Btn cloud_download is present
|
||||||
|
cy.get(
|
||||||
|
':nth-child(1) > .vn-row > :nth-child(6) > .q-btn__content > .q-icon'
|
||||||
|
).should('have.text', 'cloud_download');
|
||||||
|
// Btn cloud_download is clicked
|
||||||
|
cy.get(
|
||||||
|
':nth-child(1) > .vn-row > :nth-child(6) > .q-btn__content > .q-icon'
|
||||||
|
).click();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue