refs #5728 remove add, quit e2e
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Satorres 2023-06-08 10:30:03 +02:00
parent 8b92b35e29
commit 0afc26e20c
7 changed files with 0 additions and 250 deletions

View File

@ -67,25 +67,6 @@ describe('Entry import, create and edit buys path', () => {
await page.waitForNumberOfElements(selectors.entryBuys.anyBuyLine, 1);
});
it('should add a new buy', async() => {
await page.waitToClick(selectors.entryBuys.addBuyButton);
await page.write(selectors.entryBuys.secondBuyPackingPrice, '999');
await page.write(selectors.entryBuys.secondBuyGroupingPrice, '999');
await page.write(selectors.entryBuys.secondBuyPrice, '999');
await page.write(selectors.entryBuys.secondBuyGrouping, '999');
await page.write(selectors.entryBuys.secondBuyPacking, '999');
await page.write(selectors.entryBuys.secondBuyWeight, '999');
await page.write(selectors.entryBuys.secondBuyStickers, '999');
await page.autocompleteSearch(selectors.entryBuys.secondBuyPackage, '1');
await page.write(selectors.entryBuys.secondBuyQuantity, '999');
await page.autocompleteSearch(selectors.entryBuys.secondBuyItem, '1');
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
await page.waitForNumberOfElements(selectors.entryBuys.anyBuyLine, 2);
});
it('should edit the newest buy and check data', async() => {
await page.clearInput(selectors.entryBuys.secondBuyPackingPrice);
await page.waitForTimeout(250);

View File

@ -1,165 +0,0 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
module.exports = Self => {
Self.remoteMethodCtx('addBuy', {
description: 'Inserts a new buy for the current entry',
accessType: 'WRITE',
accepts: [{
arg: 'id',
type: 'number',
required: true,
description: 'The entry id',
http: {source: 'path'}
},
{
arg: 'itemFk',
type: 'number',
required: true
},
{
arg: 'quantity',
type: 'number',
required: true
},
{
arg: 'packageFk',
type: 'string',
required: true
},
{
arg: 'packing',
type: 'number',
},
{
arg: 'grouping',
type: 'number'
},
{
arg: 'weight',
type: 'number',
},
{
arg: 'stickers',
type: 'number',
},
{
arg: 'price2',
type: 'number',
},
{
arg: 'price3',
type: 'number',
},
{
arg: 'buyingValue',
type: 'number'
}],
returns: {
type: 'object',
root: true
},
http: {
path: `/:id/addBuy`,
verb: 'POST'
}
});
Self.addBuy = async(ctx, options) => {
const conn = Self.dataSource.connector;
let tx;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const models = Self.app.models;
ctx.args.entryFk = ctx.args.id;
// remove unwanted properties
delete ctx.args.id;
delete ctx.args.ctx;
const newBuy = await models.Buy.create(ctx.args, myOptions);
const filter = {
fields: [
'id',
'itemFk',
'stickers',
'packing',
'grouping',
'quantity',
'packageFk',
'weight',
'buyingValue',
'price2',
'price3'
],
include: {
relation: 'item',
scope: {
fields: [
'id',
'typeFk',
'name',
'size',
'minPrice',
'tag5',
'value5',
'tag6',
'value6',
'tag7',
'value7',
'tag8',
'value8',
'tag9',
'value9',
'tag10',
'value10',
'groupingMode'
],
include: {
relation: 'itemType',
scope: {
fields: ['code', 'description']
}
}
}
}
};
const stmts = [];
let stmt;
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc');
stmt = new ParameterizedSQL(
`CREATE TEMPORARY TABLE tmp.buyRecalc
(INDEX (id))
ENGINE = MEMORY
SELECT ? AS id`, [newBuy.id]);
stmts.push(stmt);
stmts.push('CALL buy_recalcPrices()');
const sql = ParameterizedSQL.join(stmts, ';');
await conn.executeStmt(sql, myOptions);
const buy = await models.Buy.findById(newBuy.id, filter, myOptions);
if (tx) await tx.commit();
return buy;
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -1,42 +0,0 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('entry addBuy()', () => {
const activeCtx = {
accessToken: {userId: 18},
};
const ctx = {
req: activeCtx
};
const entryId = 2;
it('should create a new buy for the given entry', async() => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
const itemId = 4;
const quantity = 10;
ctx.args = {
id: entryId,
itemFk: itemId,
quantity: quantity,
packageFk: 3
};
const tx = await models.Entry.beginTransaction({});
const options = {transaction: tx};
try {
const newBuy = await models.Entry.addBuy(ctx, options);
expect(newBuy.itemFk).toEqual(itemId);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -3,7 +3,6 @@ module.exports = Self => {
require('../methods/entry/filter')(Self);
require('../methods/entry/getEntry')(Self);
require('../methods/entry/getBuys')(Self);
require('../methods/entry/addBuy')(Self);
require('../methods/entry/importBuys')(Self);
require('../methods/entry/importBuysPreview')(Self);
require('../methods/entry/lastItemBuys')(Self);

View File

@ -222,13 +222,6 @@
</vn-data-viewer>
<div fixed-bottom-right>
<vn-vertical style="align-items: center;">
<vn-button class="round md vn-mb-sm"
ng-click="model.insert({})"
icon="add"
vn-tooltip="Add buy"
tooltip-position="left"
vn-bind="+">
</vn-button>
<a ui-sref="entry.card.buy.import" >
<vn-button class="round md vn-mb-sm"
icon="publish"

View File

@ -13,11 +13,6 @@ export default class Controller extends Section {
query: `Buys/${buy.id}`,
method: 'patch'
};
} else {
options = {
query: `Entries/${this.entry.id}/addBuy`,
method: 'post'
};
}
this.$http[options.method](options.query, buy).then(res => {
if (!res.data) return;

View File

@ -25,17 +25,6 @@ describe('Entry buy', () => {
controller.saveBuy(buy);
$httpBackend.flush();
});
it(`should call the entry addBuy post route if the received buy has no ID`, () => {
controller.entry = {id: 1};
const buy = {itemFk: 1, quantity: 1, packageFk: 1};
const query = `Entries/${controller.entry.id}/addBuy`;
$httpBackend.expectPOST(query).respond(200);
controller.saveBuy(buy);
$httpBackend.flush();
});
});
describe('deleteBuys()', () => {