Refactor #1418 claim.action Mover casilla mana
gitea/salix/dev This commit looks good Details

This commit is contained in:
Bernat 2019-06-04 11:00:05 +02:00
parent 7fce2e233c
commit 62f4abf6ed
6 changed files with 46 additions and 29 deletions

View File

@ -474,7 +474,6 @@ export default {
},
claimBasicData: {
claimStateAutocomplete: 'vn-claim-basic-data vn-autocomplete[field="$ctrl.claim.claimStateFk"]',
isPaidWithManaCheckbox: 'vn-check[field="$ctrl.claim.isChargedToMana"] md-checkbox',
responsabilityInputRange: 'vn-input-range',
observationInput: 'vn-textarea[field="$ctrl.claim.observation"] textarea',
saveButton: `${components.vnSubmit}`
@ -510,8 +509,8 @@ export default {
thirdLineDestination: 'vn-claim-action vn-tr:nth-child(3) vn-autocomplete[field="saleClaimed.claimDestinationFk"]',
firstDeleteLine: 'vn-claim-action vn-tr:nth-child(1) vn-icon-button[icon="delete"]',
secondDeleteLine: 'vn-claim-action vn-tr:nth-child(2) vn-icon-button[icon="delete"]',
thirdDeleteLine: 'vn-claim-action vn-tr:nth-child(3) vn-icon-button[icon="delete"]'
thirdDeleteLine: 'vn-claim-action vn-tr:nth-child(3) vn-icon-button[icon="delete"]',
isPaidWithManaCheckbox: 'vn-check[field="$ctrl.claim.isChargedToMana"] md-checkbox'
},
ordersIndex: {
searchResult: 'vn-order-index vn-card > div > vn-table > div > vn-tbody > a.vn-tr',

View File

@ -11,10 +11,9 @@ describe('Claim edit basic data path', () => {
.accessToSection('claim.card.basicData');
});
it(`should edit claim state, is paid with mana and observation fields`, async() => {
it(`should edit claim state and observation fields`, async() => {
const result = await nightmare
.autocompleteSearch(selectors.claimBasicData.claimStateAutocomplete, 'Gestionado')
.waitToClick(selectors.claimBasicData.isPaidWithManaCheckbox)
.clearTextarea(selectors.claimBasicData.observationInput)
.write(selectors.claimBasicData.observationInput, 'edited observation')
.waitToClick(selectors.claimBasicData.saveButton)
@ -40,13 +39,6 @@ describe('Claim edit basic data path', () => {
expect(result).toEqual('Gestionado');
});
it('should confirm the Is paid with mana checkbox is checked', async() => {
const result = await nightmare
.checkboxState(selectors.claimBasicData.isPaidWithManaCheckbox);
expect(result).toBe('checked');
});
it('should confirm the claim observation was edited', async() => {
const result = await nightmare
.waitToGetProperty(selectors.claimBasicData.observationInput, 'value');
@ -57,7 +49,6 @@ describe('Claim edit basic data path', () => {
it(`should edit the claim to leave it untainted`, async() => {
const result = await nightmare
.autocompleteSearch(selectors.claimBasicData.claimStateAutocomplete, 'Pendiente')
.waitToClick(selectors.claimBasicData.isPaidWithManaCheckbox)
.clearTextarea(selectors.claimBasicData.observationInput)
.write(selectors.claimBasicData.observationInput, 'Observation one')
.waitToClick(selectors.claimBasicData.saveButton)

View File

@ -1,7 +1,7 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Claim edit basic data path', () => {
describe('Claim action path', () => {
const nightmare = createNightmare();
beforeAll(() => {
@ -60,4 +60,20 @@ describe('Claim edit basic data path', () => {
expect(result).toEqual('Data saved!');
});
it('should check the Is paid with mana checkbox', async() => {
const result = await nightmare
.waitToClick(selectors.claimAction.isPaidWithManaCheckbox)
.waitForSnackbar();
expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
});
it('should confirm the Is paid with mana checkbox is checked', async() => {
const result = await nightmare
.reloadSection('claim.card.action')
.checkboxState(selectors.claimAction.isPaidWithManaCheckbox);
expect(result).toBe('checked');
});
});

View File

@ -37,6 +37,16 @@
on-change="$ctrl.saveResponsibility(value)">
</vn-input-range>
</vn-tool-bar>
<vn-one
style = "text-align:right">
<vn-check
vn-one
label="Is paid with mana"
field="$ctrl.claim.isChargedToMana"
vn-acl="salesAssistant"
on-change="$ctrl.saveMana(value)">
</vn-check>
</vn-one>
</vn-horizontal>
<vn-table model="model">
<vn-thead>

View File

@ -173,6 +173,13 @@ class Controller {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
});
}
saveMana(value) {
let query = `/api/Claims/${this.$stateParams.id}/updateClaim`;
this.$http.post(query, {isChargedToMana: value}).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
});
}
}
Controller.$inject = ['$stateParams', '$scope', '$http', '$translate', 'vnApp'];

View File

@ -18,6 +18,15 @@
label="Client"
order="id">
</vn-autocomplete>
<vn-date-picker
vn-one
disabled="true"
label="Created"
model="$ctrl.claim.created"
ini-options="{enableTime: true, dateFormat: 'd-m-Y', time_24hr: true}">
</vn-date-picker>
</vn-horizontal>
<vn-horizontal pad-small-v>
<vn-autocomplete
vn-one
disabled="false"
@ -29,15 +38,6 @@
where="{role: 'employee'}"
label="Worker">
</vn-autocomplete>
<vn-date-picker
vn-one
disabled="true"
label="Created"
model="$ctrl.claim.created"
ini-options="{enableTime: true, dateFormat: 'd-m-Y', time_24hr: true}">
</vn-date-picker>
</vn-horizontal>
<vn-horizontal pad-small-v>
<vn-autocomplete
vn-one
field="$ctrl.claim.claimStateFk"
@ -47,12 +47,6 @@
label="Claim state"
vn-focus>
</vn-autocomplete>
<vn-check
vn-one
label="Is paid with mana"
field="$ctrl.claim.isChargedToMana"
vn-acl="salesAssistant">
</vn-check>
</vn-horizontal>
</vn-horizontal>
<vn-horizontal pad-small-v>