refs #4466 tests added
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alexandre Riera 2023-03-08 10:30:57 +01:00
parent a6894b88c1
commit 7568a5f47f
5 changed files with 80 additions and 75 deletions

View File

@ -1085,14 +1085,27 @@ export default {
},
invoiceInSummary: {
totalTaxableBase: 'vn-invoice-in-summary > vn-card > vn-horizontal > vn-auto > vn-horizontal > vn-one.taxes > span',
supplierRef: 'vn-invoice-in-summary vn-label-value:nth-child(2) > section > span'
supplierRef: 'vn-invoice-in-summary vn-label-value:nth-child(2) > section > span',
correction: 'vn-invoice-in-summary > vn-card > vn-horizontal > vn-one[ng-if="$ctrl.summary.invoiceInCorrecting"]'
},
invoiceInCorrection: {
add: 'vn-invoice-in-correction vn-icon-button[vn-tooltip="Add correction"]',
originInvoice: 'vn-invoice-in-correction vn-autocomplete[vn-id="originInvoice"]',
type: 'vn-invoice-in-correction vn-autocomplete[vn-id="type"]',
class: 'vn-invoice-in-correction vn-autocomplete[vn-id="class"]',
reason: 'vn-invoice-in-correction vn-autocomplete[vn-id="reason"]',
deleteButton: 'vn-invoice-in-correction vn-icon-button[icon="delete"]',
saveButton: 'vn-invoice-in-correction vn-submit',
},
invoiceInDescriptor: {
summaryIcon: 'vn-invoice-in-descriptor a[title="Go to module summary"]',
moreMenu: 'vn-invoice-in-descriptor vn-icon-button[icon=more_vert]',
moreMenuDeleteInvoiceIn: '.vn-menu [name="deleteInvoice"]',
moreMenuCloneInvoiceIn: '.vn-menu [name="cloneInvoice"]',
acceptButton: '.vn-confirm.shown button[response="accept"]'
acceptButton: '.vn-confirm.shown button[response="accept"]',
supplierRef: 'vn-invoice-in-descriptor h5',
correctedInvoice: 'vn-invoice-in-descriptor a[vn-tooltip="Corrected invoice"]',
originInvoice: 'vn-invoice-in-descriptor a[vn-tooltip="Origin invoice"]'
},
invoiceInBasicData: {
issued: 'vn-invoice-in-basic-data vn-date-picker[ng-model="$ctrl.invoiceIn.issued"]',

View File

@ -0,0 +1,56 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('InvoiceIn correction path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('administrative', 'invoiceIn');
await page.accessToSearchResult('1');
});
afterAll(async() => {
await browser.close();
});
it('should reach the summary section and check that contain a correction', async() => {
await page.waitForSelector(selectors.invoiceInSummary.correction);
await page.waitToClick(selectors.invoiceInDescriptor.correctedInvoice);
const result = await page.waitToGetProperty(selectors.invoiceInDescriptor.supplierRef, 'innerText');
expect(result).toContain('1235');
await page.waitToClick(selectors.invoiceInDescriptor.originInvoice);
});
it('should go to correction section, delete the correction and save', async() => {
await page.accessToSection('invoiceIn.card.correction');
await page.waitToClick(selectors.invoiceInCorrection.deleteButton);
await page.waitToClick(selectors.invoiceInCorrection.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it('should create a new correction', async() => {
await page.reloadSection('invoiceIn.card.correction');
await page.waitToClick(selectors.invoiceInCorrection.add);
await page.autocompleteSearch(selectors.invoiceInCorrection.originInvoice, '1238');
await page.autocompleteSearch(selectors.invoiceInCorrection.type, 'Sustitución');
await page.autocompleteSearch(selectors.invoiceInCorrection.class, 'Ticket');
await page.autocompleteSearch(selectors.invoiceInCorrection.reason, 'IVA');
await page.waitToClick(selectors.invoiceInCorrection.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it('should go to the new correction summary and check it has changed', async() => {
await page.waitToClick(selectors.invoiceInDescriptor.correctedInvoice);
const result = await page.waitToGetProperty(selectors.invoiceInDescriptor.supplierRef, 'innerText');
expect(result).toContain('1238');
});
});

View File

@ -150,5 +150,9 @@
"Tickets with associated refunds": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº {{id}}",
"It is not possible to modify tracked sales": "It is not possible to modify tracked sales",
"It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo",
"It is not possible to modify cloned sales": "It is not possible to modify cloned sales"
"It is not possible to modify cloned sales": "It is not possible to modify cloned sales",
"Origin invoice cannot be empty": "Origin invoice cannot be empty",
"Type cannot be empty": "Type cannot be empty",
"Class cannot be empty": "Class cannot be empty",
"Reason cannot be empty": "Reason cannot be empty"
}

View File

@ -7,12 +7,10 @@ describe('InvoiceIn', () => {
let controller;
let $scope;
let vnApp;
let $httpBackend;
beforeEach(ngModule('invoiceIn'));
beforeEach(inject(($componentController, $rootScope, _vnApp_, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
beforeEach(inject(($componentController, $rootScope, _vnApp_,) => {
vnApp = _vnApp_;
jest.spyOn(vnApp, 'showError');
$scope = $rootScope.$new();
@ -25,23 +23,8 @@ describe('InvoiceIn', () => {
controller.invoiceIn = {id: 1};
}));
describe('taxRate()', () => {
it('should set tax rate with the Sage tax type value', () => {
const taxRateSelection = {
rate: 21
};
const invoiceInTax = {
taxableBase: 200
};
const taxRate = controller.taxRate(invoiceInTax, taxRateSelection);
expect(taxRate).toEqual(42);
});
});
describe('onSubmit()', () => {
it('should make HTTP POST request to save tax values', () => {
it('should make HTTP POST request to save correction values', () => {
controller.card = {reload: () => {}};
jest.spyOn($scope.watcher, 'check');
jest.spyOn($scope.watcher, 'notifySaved');
@ -58,56 +41,6 @@ describe('InvoiceIn', () => {
expect(controller.card.reload).toHaveBeenCalledWith();
});
});
describe('onResponse()', () => {
it('should return success message', () => {
controller.expense = {
code: 7050000005,
isWithheld: 0,
description: 'Test'
};
const data = [{
id: controller.expense.code,
isWithheld: controller.expense.isWithheld,
name: controller.expense.description
}];
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expect('POST', `Expenses`, data).respond();
controller.onResponse();
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Expense saved!');
});
it('should return an error if code is empty', () => {
controller.expense = {
code: null,
isWithheld: 0,
description: 'Test'
};
jest.spyOn(controller.vnApp, 'showError');
controller.onResponse();
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The code can't be empty`);
});
it('should return an error if description is empty', () => {
controller.expense = {
code: 7050000005,
isWithheld: 0,
description: null
};
jest.spyOn(controller.vnApp, 'showError');
controller.onResponse();
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The description can't be empty`);
});
});
});
});

View File

@ -26,5 +26,4 @@ Correction: Rectificativa
Add correction: Añadir rectificativa
Remove correction: Borrar rectificativa
Origin invoice: Factura origen
Correction saved!: ¡Rectificativa guardada!
Corrected invoice: Factura rectificativa