test(item_fixedPrice_rate2): backTest and e2e
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b4b7b8e204
commit
502a692521
|
@ -415,8 +415,8 @@ export default {
|
||||||
fourthFixedPrice: 'vn-fixed-price tr:nth-child(5)',
|
fourthFixedPrice: 'vn-fixed-price tr:nth-child(5)',
|
||||||
fourthItemID: 'vn-fixed-price tr:nth-child(5) vn-autocomplete[ng-model="price.itemFk"]',
|
fourthItemID: 'vn-fixed-price tr:nth-child(5) vn-autocomplete[ng-model="price.itemFk"]',
|
||||||
fourthWarehouse: 'vn-fixed-price tr:nth-child(5) vn-autocomplete[ng-model="price.warehouseFk"]',
|
fourthWarehouse: 'vn-fixed-price tr:nth-child(5) vn-autocomplete[ng-model="price.warehouseFk"]',
|
||||||
fourthPPU: 'vn-fixed-price tr:nth-child(5) > td:nth-child(4)',
|
fourthGroupingPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(4)',
|
||||||
fourthPPP: 'vn-fixed-price tr:nth-child(5) > td:nth-child(5)',
|
fourthPackingPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(5)',
|
||||||
fourthHasMinPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(6) > vn-check[ng-model="price.hasMinPrice"]',
|
fourthHasMinPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(6) > vn-check[ng-model="price.hasMinPrice"]',
|
||||||
fourthMinPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(6) > vn-input-number[ng-model="price.minPrice"]',
|
fourthMinPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(6) > vn-input-number[ng-model="price.minPrice"]',
|
||||||
fourthStarted: 'vn-fixed-price tr:nth-child(5) vn-date-picker[ng-model="price.started"]',
|
fourthStarted: 'vn-fixed-price tr:nth-child(5) vn-date-picker[ng-model="price.started"]',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
import selectors from '../../helpers/selectors.js';
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
import getBrowser from '../../helpers/puppeteer';
|
||||||
|
|
||||||
describe('Item fixed prices path', () => {
|
fdescribe('Item fixed prices path', () => {
|
||||||
let browser;
|
let browser;
|
||||||
let page;
|
let page;
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
|
@ -24,8 +24,8 @@ describe('Item fixed prices path', () => {
|
||||||
it('should fill the fixed price data', async() => {
|
it('should fill the fixed price data', async() => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
await page.autocompleteSearch(selectors.itemFixedPrice.fourthWarehouse, 'Warehouse one');
|
await page.autocompleteSearch(selectors.itemFixedPrice.fourthWarehouse, 'Warehouse one');
|
||||||
await page.write(selectors.itemFixedPrice.fourthPPU, '1');
|
await page.writeOnEditableTD(selectors.itemFixedPrice.fourthGroupingPrice, '1');
|
||||||
await page.write(selectors.itemFixedPrice.fourthPPP, '1');
|
await page.writeOnEditableTD(selectors.itemFixedPrice.fourthPackingPrice, '1');
|
||||||
await page.write(selectors.itemFixedPrice.fourthMinPrice, '1');
|
await page.write(selectors.itemFixedPrice.fourthMinPrice, '1');
|
||||||
await page.pickDate(selectors.itemFixedPrice.fourthStarted, now);
|
await page.pickDate(selectors.itemFixedPrice.fourthStarted, now);
|
||||||
await page.pickDate(selectors.itemFixedPrice.fourthEnded, now);
|
await page.pickDate(selectors.itemFixedPrice.fourthEnded, now);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('getRate2', {
|
Self.remoteMethod('getRate2', {
|
||||||
description: 'Return the rate2.',
|
description: 'Return the rate2',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: [
|
accepts: [
|
||||||
{
|
{
|
||||||
|
@ -11,13 +11,13 @@ module.exports = Self => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'rate3',
|
arg: 'rate3',
|
||||||
type: 'object',
|
type: 'number',
|
||||||
description: `The price rate 3`,
|
description: `The price rate 3`,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
type: 'number',
|
type: 'object',
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
|
@ -26,9 +26,14 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.getRate2 = async(fixedPriceId, rate3) => {
|
Self.getRate2 = async(fixedPriceId, rate3, options) => {
|
||||||
|
const myOptions = {};
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const [result] = await Self.rawSql(`SELECT vn.priceFixed_getRate2(?, ?) as rate2`,
|
const [result] = await Self.rawSql(`SELECT vn.priceFixed_getRate2(?, ?) as rate2`,
|
||||||
[fixedPriceId, rate3]);
|
[fixedPriceId, rate3], myOptions);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
|
describe('getRate2()', () => {
|
||||||
|
it(`should return new rate2 if exists rate`, async() => {
|
||||||
|
const tx = await models.FixedPrice.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const fixedPriceId = 1;
|
||||||
|
const rate3 = 2;
|
||||||
|
const result = await models.FixedPrice.getRate2(fixedPriceId, rate3, options);
|
||||||
|
|
||||||
|
expect(result.rate2).toEqual(1.9);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should return null if not exists rate`, async() => {
|
||||||
|
const tx = await models.FixedPrice.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const fixedPriceId = 13;
|
||||||
|
const rate3 = 2;
|
||||||
|
const result = await models.FixedPrice.getRate2(fixedPriceId, rate3, options);
|
||||||
|
|
||||||
|
expect(result.rate2).toEqual(null);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue