refactor: refs #8422 add testDmsAction command for streamlined DMS operations in Cypress tests
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
This commit is contained in:
parent
b45c97e3c1
commit
be877fa2b8
|
@ -306,6 +306,7 @@ defineExpose({
|
|||
:data-key="$props.model"
|
||||
:url="$props.model"
|
||||
:user-filter="dmsFilter"
|
||||
search-url="dmsFilter"
|
||||
:order="['dmsFk DESC']"
|
||||
:filter="{ where: { [$props.filter]: route.params.id } }"
|
||||
auto-load
|
||||
|
|
|
@ -21,8 +21,8 @@ describe('Vehicle DMS', () => {
|
|||
warehouseSelect: 'Warehouse_select',
|
||||
typeSelect: 'Type_select',
|
||||
fileInput: 'VnDms_inputFile',
|
||||
importBtn: 'importBtn',
|
||||
addBtn: 'addButton',
|
||||
importBtn: '[data-cy="importBtn"]',
|
||||
addBtn: '[data-cy="addButton"]',
|
||||
saveFormBtn: 'FormModelPopup_save',
|
||||
};
|
||||
|
||||
|
@ -61,46 +61,65 @@ describe('Vehicle DMS', () => {
|
|||
cy.get(selectors.lastRowDownloadBtn).click();
|
||||
|
||||
cy.wait('@download').then((interception) => {
|
||||
cy.log('RESPUESTA: ', JSON.stringify(interception.response));
|
||||
expect(interception.response.statusCode).to.equal(200);
|
||||
expect(interception.response.headers['content-disposition']).to.contain(fileName);
|
||||
expect(interception.response.headers['content-disposition']).to.contain(
|
||||
fileName,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should create new DMS', () => {
|
||||
cy.dataCy(selectors.addBtn).click();
|
||||
cy.fillInForm(data);
|
||||
cy.dataCy(selectors.fileInput).selectFile('test/cypress/fixtures/image.jpg', {
|
||||
force: true,
|
||||
});
|
||||
cy.dataCy(selectors.saveFormBtn).click();
|
||||
cy.checkNotification('Data saved');
|
||||
const formSelectors = {
|
||||
actionBtn: selectors.addBtn,
|
||||
fileInput: selectors.fileInput,
|
||||
saveFormBtn: selectors.saveFormBtn,
|
||||
};
|
||||
|
||||
cy.testDmsAction('create', formSelectors, data, 'Data saved');
|
||||
});
|
||||
|
||||
it('Should import DMS', () => {
|
||||
const data = {
|
||||
Document: { val: '10', type: 'select' },
|
||||
};
|
||||
cy.dataCy(selectors.importBtn).click();
|
||||
cy.fillInForm(data);
|
||||
cy.dataCy(selectors.saveFormBtn).click();
|
||||
cy.checkNotification('Data saved');
|
||||
cy.validateContent(selectors.lastRowReference, '1');
|
||||
const formSelectors = {
|
||||
actionBtn: selectors.importBtn,
|
||||
selectorContentToCheck: selectors.lastRowReference,
|
||||
saveFormBtn: selectors.saveFormBtn,
|
||||
};
|
||||
|
||||
cy.testDmsAction('import', formSelectors, data, 'Data saved', '1');
|
||||
});
|
||||
|
||||
it('Should edit DMS', () => {
|
||||
cy.get(selectors.lastRowEditBtn).click();
|
||||
cy.fillInForm(updateData);
|
||||
cy.dataCy(selectors.saveFormBtn).click();
|
||||
cy.checkNotification('Data saved');
|
||||
cy.validateContent(selectors.lastRowReference, updateData.Reference.val);
|
||||
const formSelectors = {
|
||||
actionBtn: selectors.lastRowEditBtn,
|
||||
selectorContentToCheck: selectors.lastRowReference,
|
||||
saveFormBtn: selectors.saveFormBtn,
|
||||
};
|
||||
|
||||
cy.testDmsAction(
|
||||
'edit',
|
||||
formSelectors,
|
||||
updateData,
|
||||
'Data saved',
|
||||
updateData.Reference.val,
|
||||
);
|
||||
});
|
||||
|
||||
it('Should delete DMS', () => {
|
||||
cy.get(selectors.lastRowDeleteBtn).click();
|
||||
cy.clickConfirm();
|
||||
cy.checkNotification('Data deleted');
|
||||
cy.containContent(selectors.lastRowReference, 'Vehicle:3333-BAT');
|
||||
const formSelectors = {
|
||||
actionBtn: selectors.lastRowDeleteBtn,
|
||||
selectorContentToCheck: selectors.lastRowReference,
|
||||
};
|
||||
|
||||
cy.testDmsAction(
|
||||
'delete',
|
||||
formSelectors,
|
||||
null,
|
||||
'Data deleted',
|
||||
'Vehicle:3333-BAT',
|
||||
);
|
||||
});
|
||||
|
||||
describe('Worker pop-ups', () => {
|
||||
|
|
|
@ -638,3 +638,16 @@ Cypress.Commands.add(
|
|||
});
|
||||
},
|
||||
);
|
||||
|
||||
Cypress.Commands.add('testDmsAction', (action, selectors, data, message, content) => {
|
||||
cy.get(selectors.actionBtn).click();
|
||||
if (action !== 'delete') cy.fillInForm(data);
|
||||
if (action === 'create')
|
||||
cy.dataCy(selectors.fileInput).selectFile('test/cypress/fixtures/image.jpg', {
|
||||
force: true,
|
||||
});
|
||||
if (action === 'delete') cy.clickConfirm();
|
||||
if (action !== 'delete') cy.dataCy(selectors.saveFormBtn).click();
|
||||
cy.checkNotification(message);
|
||||
if (action !== 'create') cy.containContent(selectors.selectorContentToCheck, content);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue