E2E fixes
This commit is contained in:
parent
a52fcb587a
commit
8eb6590285
|
@ -545,7 +545,7 @@ let actions = {
|
||||||
return dialogs.length;
|
return dialogs.length;
|
||||||
}, response);
|
}, response);
|
||||||
|
|
||||||
this.waitForFunction(firstCount => {
|
await this.waitForFunction(firstCount => {
|
||||||
const dialogs = document.querySelectorAll('.vn-dialog');
|
const dialogs = document.querySelectorAll('.vn-dialog');
|
||||||
return dialogs.length < firstCount;
|
return dialogs.length < firstCount;
|
||||||
}, {}, firstCount);
|
}, {}, firstCount);
|
||||||
|
@ -559,7 +559,14 @@ let actions = {
|
||||||
export function extendPage(page) {
|
export function extendPage(page) {
|
||||||
for (let name in actions) {
|
for (let name in actions) {
|
||||||
page[name] = async(...args) => {
|
page[name] = async(...args) => {
|
||||||
return await actions[name].call(page, ...args);
|
try {
|
||||||
|
return await actions[name].apply(page, args);
|
||||||
|
} catch (err) {
|
||||||
|
let stringArgs = args
|
||||||
|
.map(i => typeof i == 'function' ? 'Function' : i)
|
||||||
|
.join(', ');
|
||||||
|
throw new Error(`.${name}(${stringArgs}): ${err.message}`);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ export async function getBrowser() {
|
||||||
if (process.env.DEBUG)
|
if (process.env.DEBUG)
|
||||||
args.push('--auto-open-devtools-for-tabs');
|
args.push('--auto-open-devtools-for-tabs');
|
||||||
|
|
||||||
const headless = !process.env.E2E_SHOW;
|
const headless = !(process.env.E2E_SHOW || process.env.DEBUG);
|
||||||
const browser = await Puppeteer.launch({
|
const browser = await Puppeteer.launch({
|
||||||
args,
|
args,
|
||||||
defaultViewport: null,
|
defaultViewport: null,
|
||||||
|
|
|
@ -260,7 +260,6 @@ export default {
|
||||||
secondRequestDecline: 'vn-item-request vn-tbody > vn-tr:nth-child(1) vn-icon-button[icon="thumb_down"]',
|
secondRequestDecline: 'vn-item-request vn-tbody > vn-tr:nth-child(1) vn-icon-button[icon="thumb_down"]',
|
||||||
declineReason: 'vn-textarea[ng-model="$ctrl.denyObservation"]',
|
declineReason: 'vn-textarea[ng-model="$ctrl.denyObservation"]',
|
||||||
acceptDeclineReason: 'button[response="accept"]',
|
acceptDeclineReason: 'button[response="accept"]',
|
||||||
|
|
||||||
},
|
},
|
||||||
itemBasicData: {
|
itemBasicData: {
|
||||||
basicDataButton: 'vn-left-menu a[ui-sref="item.card.basicData"]',
|
basicDataButton: 'vn-left-menu a[ui-sref="item.card.basicData"]',
|
||||||
|
|
|
@ -38,9 +38,8 @@ describe('Item request path', () => {
|
||||||
|
|
||||||
it('should now click on the second declain request icon then type the reason', async() => {
|
it('should now click on the second declain request icon then type the reason', async() => {
|
||||||
await page.waitToClick(selectors.itemRequest.secondRequestDecline);
|
await page.waitToClick(selectors.itemRequest.secondRequestDecline);
|
||||||
await page.write(selectors.itemRequest.declineReason, 'not quite as expected');
|
await page.write(selectors.itemRequest.declineReason, 'Not quite as expected');
|
||||||
await page.waitToClick(selectors.itemRequest.acceptDeclineReason);
|
await page.respondToDialog('accept');
|
||||||
await page.waitForContentLoaded();
|
|
||||||
let status = await page.waitToGetProperty(selectors.itemRequest.firstRequestStatus, 'innerText');
|
let status = await page.waitToGetProperty(selectors.itemRequest.firstRequestStatus, 'innerText');
|
||||||
|
|
||||||
expect(status).toContain('Denegada');
|
expect(status).toContain('Denegada');
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
<vn-icon-button
|
<vn-icon-button
|
||||||
ng-if="request.isOk != 0"
|
ng-if="request.isOk != 0"
|
||||||
icon="thumb_down"
|
icon="thumb_down"
|
||||||
ng-click="$ctrl.showDenyReason($event, request)"
|
ng-click="denyDialog.show(request)"
|
||||||
translate-attr="{title: 'Discard'}"
|
translate-attr="{title: 'Discard'}"
|
||||||
tabindex="-1">
|
tabindex="-1">
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
|
@ -111,8 +111,9 @@
|
||||||
vn-id="itemDescriptor">
|
vn-id="itemDescriptor">
|
||||||
</vn-item-descriptor-popover>
|
</vn-item-descriptor-popover>
|
||||||
<vn-dialog
|
<vn-dialog
|
||||||
vn-id="denyReason"
|
vn-id="deny-dialog"
|
||||||
on-response="$ctrl.denyRequest($response)">
|
on-accept="$ctrl.onDenyAccept($data)"
|
||||||
|
on-close="$ctrl.onDenyClose()">
|
||||||
<tpl-body>
|
<tpl-body>
|
||||||
<h5 class="vn-pa-md" translate>Specify the reasons to deny this request</h5>
|
<h5 class="vn-pa-md" translate>Specify the reasons to deny this request</h5>
|
||||||
<vn-horizontal class="vn-pa-md">
|
<vn-horizontal class="vn-pa-md">
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
import Component from 'core/lib/component';
|
import Section from 'salix/components/section';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
export default class Controller extends Component {
|
export default class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ export default class Controller extends Component {
|
||||||
getState(isOk) {
|
getState(isOk) {
|
||||||
if (isOk === null)
|
if (isOk === null)
|
||||||
return 'Nueva';
|
return 'Nueva';
|
||||||
else if (isOk === -1 || isOk)
|
else if (isOk)
|
||||||
return 'Aceptada';
|
return 'Aceptada';
|
||||||
else
|
else
|
||||||
return 'Denegada';
|
return 'Denegada';
|
||||||
|
@ -102,25 +102,26 @@ export default class Controller extends Component {
|
||||||
delete this.denyRequestId;
|
delete this.denyRequestId;
|
||||||
}
|
}
|
||||||
|
|
||||||
denyRequest(response) {
|
onDenyAccept(request) {
|
||||||
if (response !== 'accept') return;
|
|
||||||
|
|
||||||
let params = {
|
let params = {
|
||||||
observation: this.denyObservation
|
observation: this.denyObservation
|
||||||
};
|
};
|
||||||
|
|
||||||
let query = `TicketRequests/${this.selectedRequest.id}/deny`;
|
let query = `TicketRequests/${request.id}/deny`;
|
||||||
this.$http.post(query, params).then(res => {
|
return this.$http.post(query, params).then(res => {
|
||||||
const request = res.data;
|
const newRequest = res.data;
|
||||||
this.selectedRequest.isOk = request.isOk;
|
request.isOk = newRequest.isOk;
|
||||||
this.selectedRequest.attenderFk = request.attenderFk;
|
request.attenderFk = newRequest.attenderFk;
|
||||||
this.selectedRequest.response = request.response;
|
request.response = newRequest.response;
|
||||||
|
|
||||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||||
this.denyObservation = null;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onDenyClose() {
|
||||||
|
this.denyObservation = null;
|
||||||
|
}
|
||||||
|
|
||||||
showTicketDescriptor(event, ticketFk) {
|
showTicketDescriptor(event, ticketFk) {
|
||||||
this.$.ticketDescriptor.ticketFk = ticketFk;
|
this.$.ticketDescriptor.ticketFk = ticketFk;
|
||||||
this.$.ticketDescriptor.parent = event.target;
|
this.$.ticketDescriptor.parent = event.target;
|
||||||
|
|
|
@ -84,7 +84,6 @@ describe('Item', () => {
|
||||||
let request = {saleFk: 1, saleQuantity: 1};
|
let request = {saleFk: 1, saleQuantity: 1};
|
||||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
|
||||||
|
|
||||||
$httpBackend.when('PATCH', `Sales/${request.saleFk}/`).respond();
|
$httpBackend.when('PATCH', `Sales/${request.saleFk}/`).respond();
|
||||||
$httpBackend.expect('PATCH', `Sales/${request.saleFk}/`).respond();
|
$httpBackend.expect('PATCH', `Sales/${request.saleFk}/`).respond();
|
||||||
controller.changeQuantity(request);
|
controller.changeQuantity(request);
|
||||||
|
@ -112,20 +111,20 @@ describe('Item', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('denyRequest()', () => {
|
describe('onDenyAccept()', () => {
|
||||||
it(`should perform a query and call vnApp.showSuccess(), refresh(), hide() and set denyObservation to null in the controller`, () => {
|
it(`should deny the request`, () => {
|
||||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
const request = {
|
||||||
|
id: 1,
|
||||||
|
response: 'new'
|
||||||
|
};
|
||||||
|
|
||||||
const request = {id: 1};
|
const url = `TicketRequests/:id/deny`;
|
||||||
const expectedResult = {isOk: false, attenderFk: 106, response: 'Denied!'};
|
$httpBackend.expectRoute('POST', url).respond({response: 'denied'});
|
||||||
controller.selectedRequest = request;
|
|
||||||
|
|
||||||
$httpBackend.when('POST', `TicketRequests/${request.id}/deny`).respond(expectedResult);
|
controller.onDenyAccept(request);
|
||||||
$httpBackend.expect('POST', `TicketRequests/${request.id}/deny`).respond(expectedResult);
|
|
||||||
controller.denyRequest('accept');
|
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
expect(request.response).toBe('denied');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue