E2E fixes, model bug fixes, Nightmare getProperty extensions
This commit is contained in:
parent
74e234a099
commit
4607bce91e
|
@ -149,8 +149,10 @@ export default class CrudModel extends ModelProxy {
|
|||
let update = [];
|
||||
let remove = [];
|
||||
|
||||
let pk = this.primaryKey;
|
||||
|
||||
for (let row of this.removed)
|
||||
remove.push(row[this.primaryKey]);
|
||||
remove.push(row.$orgRow[pk]);
|
||||
|
||||
for (let row of this._data) {
|
||||
if (row.$isNew) {
|
||||
|
@ -163,7 +165,10 @@ export default class CrudModel extends ModelProxy {
|
|||
let data = {};
|
||||
for (let prop in row.$oldData)
|
||||
data[prop] = row[prop];
|
||||
update.push(data);
|
||||
update.push({
|
||||
data,
|
||||
where: {[pk]: row.$orgRow[pk]}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@ export class Filtrable {
|
|||
*
|
||||
* @property {String|Array<String>|Function} order The sort specification
|
||||
*/
|
||||
export class Sortable {
|
||||
}
|
||||
export class Sortable {}
|
||||
|
||||
/**
|
||||
* Paginable model.
|
||||
|
@ -75,7 +74,7 @@ export default class ModelProxy extends DataModel {
|
|||
this.proxiedData = new Array(value.length);
|
||||
|
||||
for (let i = 0; i < value.length; i++)
|
||||
this.proxiedData[i] = this.createRow(Object.assign({}, value[i]), i);
|
||||
this.proxiedData[i] = this.createRow(Object.assign({}, value[i]), i, value[i]);
|
||||
} else
|
||||
this.proxiedData = null;
|
||||
|
||||
|
@ -119,7 +118,7 @@ export default class ModelProxy extends DataModel {
|
|||
return index;
|
||||
}
|
||||
|
||||
createRow(obj, index) {
|
||||
createRow(obj, index, orgRow) {
|
||||
let proxy = new Proxy(obj, {
|
||||
set: (obj, prop, value) => {
|
||||
if (prop.charAt(0) !== '$' && value !== obj[prop] && !obj.$isNew) {
|
||||
|
@ -134,6 +133,7 @@ export default class ModelProxy extends DataModel {
|
|||
});
|
||||
Object.assign(proxy, {
|
||||
$orgIndex: index,
|
||||
$orgRow: orgRow,
|
||||
$oldData: null,
|
||||
$isNew: false
|
||||
});
|
||||
|
@ -155,17 +155,18 @@ export default class ModelProxy extends DataModel {
|
|||
let orgData = this.orgData;
|
||||
if (!data) return;
|
||||
|
||||
for (let row of this.removed) {
|
||||
for (let row of data) {
|
||||
if (row.$isNew) {
|
||||
let data = {};
|
||||
let orgRow = {};
|
||||
for (let prop in row)
|
||||
if (prop.charAt(0) !== '$')
|
||||
data[prop] = row[prop];
|
||||
row.$orgIndex = orgData.push(data) - 1;
|
||||
orgRow[prop] = row[prop];
|
||||
row.$orgIndex = orgData.push(orgRow) - 1;
|
||||
row.$orgRow = orgRow;
|
||||
row.$isNew = false;
|
||||
} else if (row.$oldData)
|
||||
for (let prop in row.$oldData)
|
||||
orgData[row.$orgIndex][prop] = row[prop];
|
||||
row.$orgRow[prop] = row[prop];
|
||||
}
|
||||
|
||||
let removed = this.removed;
|
||||
|
|
|
@ -44,6 +44,21 @@ Nightmare.action('parsedUrl', function(done) {
|
|||
});
|
||||
});
|
||||
|
||||
Nightmare.action('getProperty', function(selector, property, done) {
|
||||
this.evaluate_now((selector, property) => {
|
||||
return document.querySelector(selector)[property];
|
||||
}, done, selector, property);
|
||||
});
|
||||
|
||||
Nightmare.action('waitProperty', function(selector, property, done) {
|
||||
this.wait((selector, property) => {
|
||||
let element = document.querySelector(selector);
|
||||
return element && element[property] != null && element[property] !== '';
|
||||
}, selector, property)
|
||||
.getProperty(selector, property)
|
||||
.then(result => done(null, result), done);
|
||||
});
|
||||
|
||||
Nightmare.action('getInnerText', function(selector, done) {
|
||||
this.wait(selector)
|
||||
.evaluate_now(function(elementToSelect) {
|
||||
|
|
|
@ -63,21 +63,22 @@ describe('Item', () => {
|
|||
return nightmare
|
||||
.click(selectors.itemTags.tagsButton)
|
||||
.wait(selectors.itemTags.firstTagDisabled)
|
||||
.click(selectors.itemTax.taxButton)
|
||||
.waitToClick(selectors.itemTax.taxButton)
|
||||
.waitForTextInInput(selectors.itemTax.firstClassSelect, 'general')
|
||||
.waitForTextInInput(selectors.itemTax.firstClassSelect, 'reduced')
|
||||
.getInputValue(selectors.itemTax.firstClassSelect)
|
||||
.then(result => {
|
||||
expect(result).toEqual('General VAT');
|
||||
expect(result).toEqual('Reduced VAT');
|
||||
return nightmare
|
||||
.getInputValue(selectors.itemTax.secondClassSelect);
|
||||
})
|
||||
.then(result => {
|
||||
expect(result).toEqual('Reduced VAT');
|
||||
expect(result).toEqual('General VAT');
|
||||
return nightmare
|
||||
.getInputValue(selectors.itemTax.thirdClassSelect);
|
||||
})
|
||||
.then(result => {
|
||||
expect(result).toEqual('General VAT');
|
||||
expect(result).toEqual('Reduced VAT');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -60,142 +60,62 @@ describe('Item', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it(`should confirm the first select is the expected one`, () => {
|
||||
it(`should reload tags form to check that the changes are saved`, () => {
|
||||
return nightmare
|
||||
.click(selectors.itemBasicData.basicDataButton)
|
||||
.wait(selectors.itemBasicData.nameInput)
|
||||
.click(selectors.itemTags.tagsButton)
|
||||
.waitForTextInInput(selectors.itemTags.firstTagSelect, 'Diámetro')
|
||||
.getInputValue(selectors.itemTags.firstTagSelect)
|
||||
.then(result => {
|
||||
expect(result).toEqual('Diámetro');
|
||||
});
|
||||
.wait('vn-item-tags');
|
||||
});
|
||||
|
||||
it(`should confirm the first value is the expected one`, () => {
|
||||
return nightmare
|
||||
.waitForTextInInput(selectors.itemTags.firstValueInput, '50')
|
||||
.getInputValue(selectors.itemTags.firstValueInput)
|
||||
.then(result => {
|
||||
expect(result).toEqual('50');
|
||||
});
|
||||
it(`should confirm the first row data is the expected one`, async() => {
|
||||
let tag = await nightmare.getProperty(selectors.itemTags.firstTagSelect, 'value');
|
||||
let value = await nightmare.getProperty(selectors.itemTags.firstValueInput, 'value');
|
||||
let relevancy = await nightmare.getProperty(selectors.itemTags.firstRelevancyInput, 'value');
|
||||
|
||||
expect(tag).toEqual('Ancho de la base');
|
||||
expect(value).toEqual('50');
|
||||
expect(relevancy).toEqual('1');
|
||||
});
|
||||
|
||||
it(`should confirm the first relevancy is the expected one`, () => {
|
||||
return nightmare
|
||||
.waitForTextInInput(selectors.itemTags.firstRelevancyInput, '1')
|
||||
.getInputValue(selectors.itemTags.firstRelevancyInput)
|
||||
.then(result => {
|
||||
expect(result).toEqual('1');
|
||||
});
|
||||
it(`should confirm the second row data is the expected one`, async() => {
|
||||
let tag = await nightmare.getProperty(selectors.itemTags.secondTagSelect, 'value');
|
||||
let value = await nightmare.getProperty(selectors.itemTags.secondValueInput, 'value');
|
||||
let relevancy = await nightmare.getProperty(selectors.itemTags.secondRelevancyInput, 'value');
|
||||
|
||||
expect(tag).toEqual('Variedad');
|
||||
expect(value).toEqual('Gem1');
|
||||
expect(relevancy).toEqual('2');
|
||||
});
|
||||
|
||||
it(`should confirm the second select is the expected one`, () => {
|
||||
return nightmare
|
||||
.waitForTextInInput(selectors.itemTags.secondTagSelect, 'Variedad')
|
||||
.getInputValue(selectors.itemTags.secondTagSelect)
|
||||
.then(result => {
|
||||
expect(result).toEqual('Variedad');
|
||||
});
|
||||
it(`should confirm the second row data is the expected one`, async() => {
|
||||
let tag = await nightmare.getProperty(selectors.itemTags.thirdTagSelect, 'value');
|
||||
let value = await nightmare.getProperty(selectors.itemTags.thirdValueInput, 'value');
|
||||
let relevancy = await nightmare.getProperty(selectors.itemTags.thirdRelevancyInput, 'value');
|
||||
|
||||
expect(tag).toEqual('Longitud(cm)');
|
||||
expect(value).toEqual('5');
|
||||
expect(relevancy).toEqual('3');
|
||||
});
|
||||
|
||||
it(`should confirm the second value is the expected one`, () => {
|
||||
return nightmare
|
||||
.waitForTextInInput(selectors.itemTags.secondValueInput, 'Gem1')
|
||||
.getInputValue(selectors.itemTags.secondValueInput)
|
||||
.then(result => {
|
||||
expect(result).toEqual('Gem1');
|
||||
});
|
||||
it(`should confirm the fourth row data is the expected one`, async() => {
|
||||
let tag = await nightmare.getProperty(selectors.itemTags.fourthTagSelect, 'value');
|
||||
let value = await nightmare.getProperty(selectors.itemTags.fourthValueInput, 'value');
|
||||
let relevancy = await nightmare.getProperty(selectors.itemTags.fourthRelevancyInput, 'value');
|
||||
|
||||
expect(tag).toEqual('Proveedor');
|
||||
expect(value).toEqual('Marvel1');
|
||||
expect(relevancy).toEqual('4');
|
||||
});
|
||||
|
||||
it(`should confirm the second relevancy is the expected one`, () => {
|
||||
return nightmare
|
||||
.waitForTextInInput(selectors.itemTags.secondRelevancyInput, '2')
|
||||
.getInputValue(selectors.itemTags.secondRelevancyInput)
|
||||
.then(result => {
|
||||
expect(result).toEqual('2');
|
||||
});
|
||||
});
|
||||
it(`should confirm the fifth row data is the expected one`, async() => {
|
||||
let tag = await nightmare.getProperty(selectors.itemTags.fifthTagSelect, 'value');
|
||||
let value = await nightmare.getProperty(selectors.itemTags.fifthValueInput, 'value');
|
||||
let relevancy = await nightmare.getProperty(selectors.itemTags.fifthRelevancyInput, 'value');
|
||||
|
||||
it(`should confirm the third select is the expected one`, () => {
|
||||
return nightmare
|
||||
.waitForTextInInput(selectors.itemTags.thirdTagSelect, 'Longitud(cm)')
|
||||
.getInputValue(selectors.itemTags.thirdTagSelect)
|
||||
.then(result => {
|
||||
expect(result).toEqual('Longitud(cm)');
|
||||
});
|
||||
});
|
||||
|
||||
it(`should confirm the third value is the expected one`, () => {
|
||||
return nightmare
|
||||
.waitForTextInInput(selectors.itemTags.thirdValueInput, '5')
|
||||
.getInputValue(selectors.itemTags.thirdValueInput)
|
||||
.then(result => {
|
||||
expect(result).toEqual('5');
|
||||
});
|
||||
});
|
||||
|
||||
it(`should confirm the third relevancy is the expected one`, () => {
|
||||
return nightmare
|
||||
.waitForTextInInput(selectors.itemTags.thirdRelevancyInput, '3')
|
||||
.getInputValue(selectors.itemTags.thirdRelevancyInput)
|
||||
.then(result => {
|
||||
expect(result).toEqual('3');
|
||||
});
|
||||
});
|
||||
|
||||
it(`should confirm the fourth select is the expected one`, () => {
|
||||
return nightmare
|
||||
.waitForTextInInput(selectors.itemTags.fourthTagSelect, 'Proveedor')
|
||||
.getInputValue(selectors.itemTags.fourthTagSelect)
|
||||
.then(result => {
|
||||
expect(result).toEqual('Proveedor');
|
||||
});
|
||||
});
|
||||
|
||||
it(`should confirm the fourth value is the expected one`, () => {
|
||||
return nightmare
|
||||
.waitForTextInInput(selectors.itemTags.fourthValueInput, 'Marvel1')
|
||||
.getInputValue(selectors.itemTags.fourthValueInput)
|
||||
.then(result => {
|
||||
expect(result).toEqual('Marvel1');
|
||||
});
|
||||
});
|
||||
|
||||
it(`should confirm the fourth relevancy is the expected one`, () => {
|
||||
return nightmare
|
||||
.waitForTextInInput(selectors.itemTags.fourthRelevancyInput, '4')
|
||||
.getInputValue(selectors.itemTags.fourthRelevancyInput)
|
||||
.then(result => {
|
||||
expect(result).toEqual('4');
|
||||
});
|
||||
});
|
||||
|
||||
it(`should confirm the fifth select is the expected one`, () => {
|
||||
return nightmare
|
||||
.waitForTextInInput(selectors.itemTags.fifthTagSelect, 'Color')
|
||||
.getInputValue(selectors.itemTags.fifthTagSelect)
|
||||
.then(result => {
|
||||
expect(result).toEqual('Color');
|
||||
});
|
||||
});
|
||||
|
||||
it(`should confirm the fifth value is the expected one`, () => {
|
||||
return nightmare
|
||||
.waitForTextInInput(selectors.itemTags.fifthValueInput, 'Yellow')
|
||||
.getInputValue(selectors.itemTags.fifthValueInput)
|
||||
.then(result => {
|
||||
expect(result).toEqual('Yellow');
|
||||
});
|
||||
});
|
||||
|
||||
it(`should confirm the fifth relevancy is the expected one`, () => {
|
||||
return nightmare
|
||||
.waitForTextInInput(selectors.itemTags.fifthRelevancyInput, '5')
|
||||
.getInputValue(selectors.itemTags.fifthRelevancyInput)
|
||||
.then(result => {
|
||||
expect(result).toEqual('5');
|
||||
});
|
||||
expect(tag).toEqual('Color');
|
||||
expect(value).toEqual('Yellow');
|
||||
expect(relevancy).toEqual('5');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -49,7 +49,6 @@ describe('Ticket', () => {
|
|||
.waitToClick(selectors.ticketNotes.firstNoteRemoveButton)
|
||||
.waitToClick(selectors.ticketNotes.addNoteButton)
|
||||
.waitToClick(selectors.ticketNotes.firstNoteSelect)
|
||||
.waitForTextInElement(selectors.ticketNotes.firstNoteSelectSecondOption, 'observation two')
|
||||
.waitToClick(selectors.ticketNotes.firstNoteSelectSecondOption)
|
||||
.type(selectors.ticketNotes.firstDescriptionInput, 'description')
|
||||
.click(selectors.ticketNotes.submitNotesButton)
|
||||
|
@ -64,12 +63,11 @@ describe('Ticket', () => {
|
|||
.click(selectors.ticketPackages.packagesButton)
|
||||
.wait(selectors.ticketPackages.firstPackageSelect)
|
||||
.click(selectors.ticketNotes.notesButton)
|
||||
.waitForTextInInput(selectors.ticketNotes.firstNoteSelect, 'observation two')
|
||||
.getInputValue(selectors.ticketNotes.firstNoteSelect)
|
||||
.waitProperty(selectors.ticketNotes.firstNoteSelect, 'value')
|
||||
.then(result => {
|
||||
expect(result).toEqual('observation two');
|
||||
expect(result).toEqual('observation one');
|
||||
return nightmare
|
||||
.getInputValue(selectors.ticketNotes.firstDescriptionInput);
|
||||
.getProperty(selectors.ticketNotes.firstDescriptionInput, 'value');
|
||||
})
|
||||
.then(result => {
|
||||
expect(result).toEqual('description');
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
"requires": true,
|
||||
"dependencies": {
|
||||
"@types/node": {
|
||||
"version": "8.10.32",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.32.tgz",
|
||||
"integrity": "sha512-8OfXpkB3E0jhpcpyVlqJDV5mkXlrsJrDZR7q0uss8SBdW8IxNdx/J2o5m7cM2qbFzyd/o+aV5Z4OJcIukI6UlA==",
|
||||
"version": "8.10.36",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.36.tgz",
|
||||
"integrity": "sha512-SL6KhfM7PTqiFmbCW3eVNwVBZ+88Mrzbuvn9olPsfv43mbiWaFY+nRcz/TGGku0/lc2FepdMbImdMY1JrQ+zbw==",
|
||||
"dev": true
|
||||
},
|
||||
"@uirouter/angularjs": {
|
||||
|
@ -4407,7 +4407,7 @@
|
|||
},
|
||||
"jsonfile": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
|
||||
"integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
@ -5525,21 +5525,6 @@
|
|||
"typedarray": "^0.0.6"
|
||||
}
|
||||
},
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
|
||||
"dev": true
|
||||
},
|
||||
"process-nextick-args": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
|
||||
|
@ -5548,7 +5533,7 @@
|
|||
},
|
||||
"readable-stream": {
|
||||
"version": "2.3.6",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
@ -17380,7 +17365,7 @@
|
|||
},
|
||||
"readable-stream": {
|
||||
"version": "1.1.14",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
|
||||
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
|
||||
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
@ -21864,7 +21849,6 @@
|
|||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
|
@ -22033,7 +22017,6 @@
|
|||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ module.exports = function(Self) {
|
|||
try {
|
||||
let promises = [];
|
||||
actions.update.forEach(toUpdate => {
|
||||
promises.push(this.upsert(toUpdate, options));
|
||||
promises.push(this.upsertWithWhere(toUpdate.where, toUpdate.data, options));
|
||||
});
|
||||
await Promise.all(promises);
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in New Issue