updated e2e
gitea/salix/2003-adress_validate_uee_members This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-01-28 11:56:26 +01:00
parent 184babf14a
commit b0ec7ce15b
7 changed files with 57 additions and 23 deletions

View File

@ -6,6 +6,7 @@ import {url as defaultURL} from './config';
export async function getBrowser() {
const browser = await Puppeteer.launch({
args: [
'--no-sandbox',
`--window-size=${ 1920 },${ 1080 }`
],
defaultViewport: null,

View File

@ -103,11 +103,13 @@ export default {
streetAddressInput: '[ng-model="$ctrl.address.street"]',
postcodeInput: '[ng-model="$ctrl.address.postalCode"]',
cityInput: '[ng-model="$ctrl.address.city"]',
provinceAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.provinceFk"]',
agencyAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.agencyModeFk"]',
provinceAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.provinceId"]',
agencyAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.agencyModeId"]',
phoneInput: '[ng-model="$ctrl.address.phone"]',
mobileInput: '[ng-model="$ctrl.address.mobile"]',
defaultAddress: 'vn-client-address-index div:nth-child(1) div[name="street"]',
incotermsAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.incotermsId"]',
customsAgentAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.customsAgentId"]',
secondMakeDefaultStar: 'vn-client-address-index vn-card div:nth-child(2) vn-icon-button[icon="star_border"]',
firstEditAddress: 'vn-client-address-index div:nth-child(1) > a',
secondEditAddress: 'vn-client-address-index div:nth-child(2) > a',

View File

@ -26,7 +26,7 @@ describe('Client Add address path', () => {
it('should receive an error after clicking save button as consignee, street and town fields are empty', async() => {
await page.waitToClick(selectors.clientAddresses.defaultCheckboxInput);
await page.autocompleteSearch(selectors.clientAddresses.provinceAutocomplete, 'Province one');
await page.autocompleteSearch(selectors.clientAddresses.provinceAutocomplete, 'Province five');
await page.write(selectors.clientAddresses.cityInput, 'Valencia');
await page.write(selectors.clientAddresses.postcodeInput, '46000');
await page.autocompleteSearch(selectors.clientAddresses.agencyAutocomplete, 'Entanglement');
@ -38,12 +38,29 @@ describe('Client Add address path', () => {
expect(result).toEqual('Some fields are invalid');
});
it(`should create a new address with all it's data`, async() => {
it(`should receive an error after clicking save button as consignee, incoterms and customsAgent are empty`, async() => {
await page.write(selectors.clientAddresses.consigneeInput, 'Bruce Bunner');
await page.write(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York');
await page.waitToClick(selectors.clientAddresses.saveButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Incoterms is required for a non UEE member');
});
it(`should receive an error after clicking save button as consignee, incoterms and customsAgent are empty`, async() => {
await page.autocompleteSearch(selectors.clientAddresses.incotermsAutocomplete, 'Free Alongside Ship');
await page.waitToClick(selectors.clientAddresses.saveButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Customs agent is required for a non UEE member');
});
it(`should create a new address with all it's data`, async() => {
await page.autocompleteSearch(selectors.clientAddresses.customsAgentAutocomplete, 'Agent one');
await page.waitToClick(selectors.clientAddresses.saveButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});

View File

@ -131,14 +131,14 @@
show-field="fiscalName"
value-field="id"
label="Customs agent">
<append>
<vn-icon-button
icon="add_circle"
vn-tooltip="New customs agent"
ng-click="$ctrl.showCustomAgent($event)">
</vn-icon-button>
</append>
</vn-autocomplete>
<vn-icon-button
vn-auto
class="vn-my-md"
icon="add_circle"
vn-tooltip="New customs agent"
ng-click="customAgent.show()">
</vn-icon-button>
</vn-horizontal>
</vn-card>
<vn-button-bar>

View File

@ -40,6 +40,13 @@ export default class Controller extends Component {
});
}
showCustomAgent(event) {
if (event.defaultPrevented) return;
event.preventDefault();
this.$.customAgent.show();
}
onCustomAgentAccept() {
return this.$http.post(`CustomsAgents`, this.newCustomsAgent)
.then(res => this.address.customsAgentFk = res.data.id);

View File

@ -15,7 +15,7 @@
vn-id="model"
url="AddressObservations"
fields="['id', 'addressFk', 'observationTypeFk', 'description']"
link="{addressFk: $ctrl.$stateParams.addressId}"
link="{addressFk: $ctrl.$params.addressId}"
data="observations"
auto-load="true">
</vn-crud-model>
@ -59,7 +59,7 @@
<vn-autocomplete
vn-one
vn-id="province"
ng-model="$ctrl.address.provinceId"
ng-model="$ctrl.address.provinceFk"
url="Provinces"
show-field="name"
value-field="id"
@ -111,7 +111,7 @@
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one
ng-model="$ctrl.address.agencyModeId"
ng-model="$ctrl.address.agencyModeFk"
url="AgencyModes/isActive"
show-field="name"
value-field="id"
@ -132,26 +132,26 @@
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one
ng-model="$ctrl.address.incotermsId"
ng-model="$ctrl.address.incotermsFk"
url="Incoterms"
show-field="name"
value-field="code"
label="Incoterms">
</vn-autocomplete>
<vn-autocomplete vn-one
ng-model="$ctrl.address.customsAgentId"
ng-model="$ctrl.address.customsAgentFk"
url="CustomsAgents"
show-field="fiscalName"
value-field="id"
label="Customs agent">
<append>
<vn-icon-button
icon="add_circle"
vn-tooltip="New customs agent"
ng-click="$ctrl.showCustomAgent($event)">
</vn-icon-button>
</append>
</vn-autocomplete>
<vn-icon-button
vn-auto
class="vn-my-md"
icon="add_circle"
vn-tooltip="New customs agent"
ng-click="customAgent.show()">
</vn-icon-button>
</vn-horizontal>
<vn-title>Notes</vn-title>
<div name="observations">

View File

@ -28,6 +28,13 @@ export default class Controller extends Component {
});
}
showCustomAgent(event) {
if (event.defaultPrevented) return;
event.preventDefault();
this.$.customAgent.show();
}
onCustomAgentAccept() {
return this.$http.post(`CustomsAgents`, this.newCustomsAgent)
.then(res => this.address.customsAgentFk = res.data.id);