#1087 Implementar clickIfVisible
This commit is contained in:
parent
7986405a72
commit
ef27606047
|
@ -190,6 +190,19 @@ let actions = {
|
|||
}, done, selector);
|
||||
},
|
||||
|
||||
clickIfVisible: function(selector, done) {
|
||||
this.wait(selector)
|
||||
.isVisible(selector)
|
||||
.then(visible => {
|
||||
if (visible)
|
||||
return this.click(selector);
|
||||
|
||||
throw new Error(`invisible selector: ${selector}`);
|
||||
})
|
||||
.then(done)
|
||||
.catch(done);
|
||||
},
|
||||
|
||||
countElement: function(selector, done) {
|
||||
this.evaluate_now(selector => {
|
||||
return document.querySelectorAll(selector).length;
|
||||
|
|
|
@ -192,6 +192,7 @@ export default {
|
|||
moreMenuRegularizeButton: `vn-item-descriptor vn-icon-menu > div > vn-drop-down > vn-popover ul > li:nth-child(1)`,
|
||||
regularizeQuantityInput: `vn-item-descriptor > vn-dialog > div > form > div.body > tpl-body > div > vn-textfield > div > div > div.infix > input`,
|
||||
regularizeWarehouseAutocomplete: 'vn-item-descriptor > vn-dialog vn-autocomplete[field="$ctrl.warehouseFk"]',
|
||||
editButton: 'vn-item-card vn-item-descriptor vn-float-button[icon="edit"]',
|
||||
regularizeSaveButton: `vn-item-descriptor > vn-dialog > div > form > div.buttons > tpl-buttons > button`
|
||||
},
|
||||
itemBasicData: {
|
||||
|
@ -335,7 +336,7 @@ export default {
|
|||
descriptorItemDiaryButton: `vn-item-descriptor .quicklinks.ng-scope > vn-horizontal > a > vn-icon > i`,
|
||||
newItemButton: 'vn-float-button[icon="add"]',
|
||||
firstSaleText: `vn-table div > vn-tbody > vn-tr:nth-child(1)`,
|
||||
firstSaleThumbnailImage: 'vn-ticket-sale:nth-child(1) vn-td:nth-child(3) > img',
|
||||
firstSaleThumbnailImage: 'vn-ticket-sale:nth-child(1) vn-tr:nth-child(1) vn-td:nth-child(3) > img',
|
||||
firstSaleZoomedImage: 'body > div > div > img',
|
||||
firstSaleQuantity: `vn-textfield[model="sale.quantity"]:nth-child(1) input`,
|
||||
firstSaleQuantityClearInput: `vn-textfield[model="sale.quantity"] div.suffix > i`,
|
||||
|
|
|
@ -163,6 +163,13 @@ describe('Item summary path', () => {
|
|||
expect(url.hash).toContain('summary');
|
||||
});
|
||||
|
||||
it(`should check the descritor edit button is not visible for employee`, async() => {
|
||||
const visibleButton = await nightmare
|
||||
.isVisible(selectors.itemDescriptor.editButton);
|
||||
|
||||
expect(visibleButton).toBeFalsy();
|
||||
});
|
||||
|
||||
it(`should check the item summary shows fields from basic data section`, async() => {
|
||||
const result = await nightmare
|
||||
.waitForTextInElement(selectors.itemSummary.basicData, 'Object2 Gem2 3')
|
||||
|
|
|
@ -11,6 +11,13 @@ describe('Item Edit basic data path', () => {
|
|||
.accessToSection('item.card.data');
|
||||
});
|
||||
|
||||
it(`should check the descritor edit button is visible for buyer`, async() => {
|
||||
const visibleButton = await nightmare
|
||||
.isVisible(selectors.itemDescriptor.editButton);
|
||||
|
||||
expect(visibleButton).toBeTruthy();
|
||||
});
|
||||
|
||||
it(`should edit the item basic data`, async() => {
|
||||
const result = await nightmare
|
||||
.clearInput(selectors.itemBasicData.nameInput)
|
||||
|
|
|
@ -14,10 +14,11 @@ describe('Ticket Create new tracking state path', () => {
|
|||
|
||||
it('should access to the create state view by clicking the create floating button', async() => {
|
||||
let url = await nightmare
|
||||
.waitToClick(selectors.ticketTracking.createStateButton)
|
||||
.clickIfVisible(selectors.ticketTracking.createStateButton)
|
||||
.wait(selectors.createStateView.stateAutocomplete)
|
||||
.parsedUrl();
|
||||
|
||||
|
||||
expect(url.hash).toContain('tracking/edit');
|
||||
});
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ describe('Ticket Edit sale path', () => {
|
|||
|
||||
it(`should click on the thumbnail image of the 1st sale and see the zoomed image`, async() => {
|
||||
const result = await nightmare
|
||||
.waitToClick(selectors.ticketSales.firstSaleThumbnailImage)
|
||||
.clickIfVisible(selectors.ticketSales.firstSaleThumbnailImage)
|
||||
.countElement(selectors.ticketSales.firstSaleZoomedImage);
|
||||
|
||||
expect(result).toEqual(1);
|
||||
|
@ -70,7 +70,7 @@ describe('Ticket Edit sale path', () => {
|
|||
|
||||
it(`should click on the zoomed image to close it`, async() => {
|
||||
const result = await nightmare
|
||||
.waitToClick(selectors.ticketSales.firstSaleZoomedImage)
|
||||
.clickIfVisible(selectors.ticketSales.firstSaleZoomedImage)
|
||||
.countElement(selectors.ticketSales.firstSaleZoomedImage);
|
||||
|
||||
expect(result).toEqual(0);
|
||||
|
@ -94,7 +94,7 @@ describe('Ticket Edit sale path', () => {
|
|||
|
||||
it(`should click on the descriptor image of the 1st sale and see the zoomed image`, async() => {
|
||||
const result = await nightmare
|
||||
.waitToClick('vn-item-descriptor img')
|
||||
.clickIfVisible('vn-item-descriptor img')
|
||||
.countElement(selectors.ticketSales.firstSaleZoomedImage);
|
||||
|
||||
expect(result).toEqual(1);
|
||||
|
@ -102,7 +102,7 @@ describe('Ticket Edit sale path', () => {
|
|||
|
||||
it(`should click on the zoomed image to close it`, async() => {
|
||||
const result = await nightmare
|
||||
.waitToClick(selectors.ticketSales.firstSaleZoomedImage)
|
||||
.clickIfVisible(selectors.ticketSales.firstSaleZoomedImage)
|
||||
.countElement(selectors.ticketSales.firstSaleZoomedImage);
|
||||
|
||||
expect(result).toEqual(0);
|
||||
|
|
Loading…
Reference in New Issue