fix test and update fixtures #9153

This commit is contained in:
Bernat 2019-01-15 12:28:13 +01:00
parent 3bdc202732
commit bb8a9e2035
5 changed files with 43 additions and 28 deletions

View File

@ -415,11 +415,12 @@ export default {
ticketService: {
serviceButton: 'vn-left-menu a[ui-sref="ticket.card.service"]',
addServiceButton: 'vn-ticket-service > form > vn-card > div > vn-one:nth-child(3) > vn-icon-button > button > vn-icon',
descriptionInput: 'vn-ticket-service vn-textfield[label="Description"] input',
quantityInput: 'vn-ticket-service vn-textfield[label="Quantity"] input',
priceInput: 'vn-ticket-service vn-textfield[label="Price"] input',
vatTypeAutocomplete: 'vn-ticket-service vn-autocomplete[label="Tax class"]',
firstDescriptionInput: 'vn-ticket-service vn-textfield[label="Description"] input',
firstQuantityInput: 'vn-ticket-service vn-textfield[label="Quantity"] input',
firstPriceInput: 'vn-ticket-service vn-textfield[label="Price"] input',
firstVatTypeAutocomplete: 'vn-ticket-service vn-autocomplete[label="Tax class"]',
fistDeleteServiceButton: 'vn-ticket-service > form > vn-card > div > vn-one:nth-child(2) > vn-horizontal > vn-auto > vn-icon',
serviceLine: 'vn-ticket-service > form > vn-card > div > vn-one:nth-child(2) > vn-horizontal',
saveServiceButton: `${components.vnSubmit}`
},
createStateView: {

View File

@ -11,47 +11,49 @@ describe('Ticket services path', () => {
.accessToSection('ticket.card.service');
});
it('should create a new service', async() => {
it('should edit the first service', async() => {
const result = await nightmare
.waitToClick(selectors.ticketService.addServiceButton)
.write(selectors.ticketService.descriptionInput, 'my service')
.clearInput(selectors.ticketService.quantityInput)
.write(selectors.ticketService.quantityInput, 99)
.write(selectors.ticketService.priceInput, 999)
.autocompleteSearch(selectors.ticketService.vatTypeAutocomplete, 'Reduced VAT')
.clearInput(selectors.ticketService.firstDescriptionInput)
.write(selectors.ticketService.firstDescriptionInput, 'my service')
.clearInput(selectors.ticketService.firstQuantityInput)
.write(selectors.ticketService.firstQuantityInput, 99)
.clearInput(selectors.ticketService.firstPriceInput)
.write(selectors.ticketService.firstPriceInput, 999)
.autocompleteSearch(selectors.ticketService.firstVatTypeAutocomplete, 'Reduced VAT')
.waitForTextInInput(`${selectors.ticketService.firstVatTypeAutocomplete} Input`, 'Reduced VAT')
.waitToClick(selectors.ticketService.saveServiceButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm the service description was created correctly', async() => {
it('should confirm the service description was edited correctly', async() => {
const result = await nightmare
.waitToClick(selectors.ticketBasicData.basicDataButton)
.wait(selectors.ticketBasicData.clientAutocomplete)
.click(selectors.ticketService.serviceButton)
.waitToGetProperty(selectors.ticketService.descriptionInput, 'value');
.waitToGetProperty(selectors.ticketService.firstDescriptionInput, 'value');
expect(result).toEqual('my service');
});
it('should confirm the service quantity was created correctly', async() => {
it('should confirm the service quantity was edited correctly', async() => {
const result = await nightmare
.waitToGetProperty(selectors.ticketService.quantityInput, 'value');
.waitToGetProperty(selectors.ticketService.firstQuantityInput, 'value');
expect(result).toEqual('99');
});
it('should confirm the service price was created correctly', async() => {
it('should confirm the service price was edited correctly', async() => {
const result = await nightmare
.waitToGetProperty(selectors.ticketService.priceInput, 'value');
.waitToGetProperty(selectors.ticketService.firstPriceInput, 'value');
expect(result).toEqual('999');
});
it('should confirm the service VAT was created correctly', async() => {
it('should confirm the service VAT was edited correctly', async() => {
const result = await nightmare
.waitToGetProperty(`${selectors.ticketService.vatTypeAutocomplete} input`, 'value');
.waitToGetProperty(`${selectors.ticketService.firstVatTypeAutocomplete} input`, 'value');
expect(result).toEqual('Reduced VAT');
});
@ -70,9 +72,9 @@ describe('Ticket services path', () => {
.waitToClick(selectors.ticketBasicData.basicDataButton)
.wait(selectors.ticketBasicData.clientAutocomplete)
.click(selectors.ticketService.serviceButton)
.waitForNumberOfElements(selectors.ticketService.descriptionInput, 0)
.countElement(selectors.ticketService.descriptionInput);
.waitForNumberOfElements(selectors.ticketService.serviceLine, 2)
.countElement(selectors.ticketService.serviceLine);
expect(result).toEqual(0);
expect(result).toEqual(2);
});
});

View File

@ -17,7 +17,7 @@ describe('Client activeWorkersWithRole', () => {
let isBuyer = await app.models.Account.hasRole(result[0].id, 'buyer');
expect(result.length).toEqual(9);
expect(result.length).toEqual(10);
expect(isBuyer).toBeTruthy();
});
});

View File

@ -0,0 +1,12 @@
ALTER TABLE `vn`.`ticketService`
ADD COLUMN `ticketFk` INT(11) NOT NULL AFTER `taxClassFk`;
ALTER TABLE `vn`.`ticketService`
ADD INDEX `fgn_ticketFk_idx` (`ticketFk` ASC);
ALTER TABLE `vn`.`ticketService`
ADD CONSTRAINT `fgn_ticketFk`
FOREIGN KEY (`ticketFk`)
REFERENCES `vn2008`.`Tickets` (`Id_Ticket`)
ON DELETE CASCADE
ON UPDATE CASCADE;

View File

@ -1037,8 +1037,8 @@ INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requesterFk`, `atenderFk`
(3, 'Object4 Armor2 2', 18, 35, 20, 3.06, 0, NULL, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)),
(4, 'Object2 Gem2 3', 18, 35, 15, 1.30, NULL, NULL, 11, CURDATE());
delete from `account`.`roleRole` where role =52 and inheritsFrom = 35;
delete from `account`.`roleInherit` where role =52 and inheritsFrom = 35;
INSERT INTO `vn`.`ticketService`(`id`, `description`, `quantity`, `price`, `taxClassFk`, `ticketFk`)
VALUES
(1, 'delivery charge', 1, 2.00, 1, 1),
(2, 'training course', 1, 10.00, 1, 2),
(3, 'delivery charge', 1, 5.50, 1, 11);