Merge branch '2178_ticket_index_payout' of verdnatura/salix into dev
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-03-27 09:50:51 +00:00 committed by Gitea
commit 0b168fa7ee
4 changed files with 71 additions and 4 deletions

View File

@ -367,6 +367,13 @@ export default {
advancedSearchInvoiceOut: 'vn-ticket-search-panel vn-textfield[ng-model="filter.refFk"]',
newTicketButton: 'vn-ticket-index a',
searchResult: 'vn-ticket-index vn-card > vn-table > div > vn-tbody > a.vn-tr',
secondTicketCheckbox: 'vn-ticket-index vn-tbody > a:nth-child(2) > vn-td:nth-child(1) > vn-check',
thirdTicketCheckbox: 'vn-ticket-index vn-tbody > a:nth-child(3) > vn-td:nth-child(1) > vn-check',
sixthTicketCheckbox: 'vn-ticket-index vn-tbody > a:nth-child(6) > vn-td:nth-child(1) > vn-check',
payoutButton: 'vn-ticket-index vn-button[icon="icon-recovery"]',
payoutCompany: '.vn-dialog vn-autocomplete[ng-model="$ctrl.receipt.companyFk"]',
payoutBank: '.vn-dialog vn-autocomplete[ng-model="$ctrl.receipt.bankFk"]',
submitPayout: '.vn-dialog vn-button[label="Save"]',
searchWeeklyResult: 'vn-ticket-weekly-index vn-table vn-tbody > vn-tr',
searchResultDate: 'vn-ticket-summary [label=Landed] span',
topbarSearch: 'vn-searchbar',

View File

@ -0,0 +1,60 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket index payout path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
});
afterAll(async() => {
await browser.close();
});
it('should navigate to the ticket index', async() => {
await page.loginAndModule('administrative', 'ticket');
let url = await page.expectURL('#!/ticket/index');
expect(url).toBe(true);
});
it('should check three tickets 2 of a clinet and 1 of another', async() => {
await page.keyboard.press('Enter');
await page.waitToClick(selectors.ticketsIndex.secondTicketCheckbox);
await page.waitToClick(selectors.ticketsIndex.sixthTicketCheckbox);
await page.waitToClick(selectors.ticketsIndex.payoutButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('You cannot make a payment on account from multiple clients');
});
it('should uncheck the sixth ticket result and check the third which is from the same client then open the payout form', async() => {
await page.waitToClick(selectors.ticketsIndex.sixthTicketCheckbox);
await page.waitToClick(selectors.ticketsIndex.thirdTicketCheckbox);
await page.waitToClick(selectors.ticketsIndex.payoutButton);
await page.waitForSelector(selectors.ticketsIndex.payoutCompany);
});
it('should fill the company and bank to perform a payout', async() => {
await page.autocompleteSearch(selectors.ticketsIndex.payoutBank, 'cash');
await page.waitToClick(selectors.ticketsIndex.submitPayout);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should navigate to the client balance section and check a new balance line was entered', async() => {
await page.waitToClick(selectors.globalItems.homeButton);
await page.selectModule('client');
await page.accessToSearchResult('101');
await page.accessToSection('client.card.balance.index');
await page.waitForSelector('vn-client-balance-index vn-tbody > vn-tr');
let result = await page.countElement('vn-client-balance-index vn-tbody > vn-tr');
expect(result).toEqual(4);
});
});

View File

@ -29,7 +29,7 @@ export default class Controller extends Section {
}
get checked() {
const tickets = this.$.tickets || [];
const tickets = this.$.model.data || [];
const checkedLines = [];
for (let ticket of tickets) {
if (ticket.checked)

View File

@ -88,7 +88,7 @@ describe('Component vnTicketIndex', () => {
controller.$.balanceCreateDialog = {show: () => {}};
jest.spyOn(controller.$.balanceCreateDialog, 'show').mockReturnThis();
controller.$.tickets = tickets;
controller.$.model = {data: tickets};
controller.$.balanceCreateDialog.amountPaid = 0;
controller.openBalanceDialog();
@ -102,7 +102,7 @@ describe('Component vnTicketIndex', () => {
describe('checked()', () => {
it('should return an array of checked tickets', () => {
controller.$.tickets = tickets;
controller.$.model = {data: tickets};
const result = controller.checked;
const firstRow = result[0];
const secondRow = result[1];
@ -115,7 +115,7 @@ describe('Component vnTicketIndex', () => {
describe('totalChecked()', () => {
it('should return the total number of checked tickets', () => {
controller.$.tickets = tickets;
controller.$.model = {data: tickets};
const result = controller.checked;
expect(result.length).toEqual(2);