refs #4945 nombre temporal removed
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alexandre Riera 2023-01-17 10:01:49 +01:00
parent abf4c4e59b
commit 4e1c43eb4d
7 changed files with 50 additions and 18 deletions

View File

@ -428,6 +428,7 @@ export default {
},
itemCreateView: {
temporalName: 'vn-item-create vn-textfield[ng-model="$ctrl.item.provisionalName"]',
priority: 'vn-input-number[ng-model="$ctrl.item.priority"]',
type: 'vn-autocomplete[ng-model="$ctrl.item.typeFk"]',
intrastat: 'vn-autocomplete[ng-model="$ctrl.item.intrastatFk"]',
origin: 'vn-autocomplete[ng-model="$ctrl.item.originFk"]',
@ -521,7 +522,7 @@ export default {
},
itemLog: {
anyLineCreated: 'vn-item-log > vn-log vn-tbody > vn-tr',
fifthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(5) table tr:nth-child(3) td.after',
fourthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(4) table tr:nth-child(3) td.after',
},
ticketSummary: {
header: 'vn-ticket-summary > vn-card > h5',

View File

@ -36,11 +36,20 @@ describe('Item Create', () => {
await page.waitForState('item.create');
});
it('should create the Infinity Gauntlet item', async() => {
it('should throw an error when insert an invalid priority', async() => {
await page.write(selectors.itemCreateView.temporalName, 'Infinity Gauntlet');
await page.autocompleteSearch(selectors.itemCreateView.type, 'Crisantemo');
await page.autocompleteSearch(selectors.itemCreateView.intrastat, 'Coral y materiales similares');
await page.autocompleteSearch(selectors.itemCreateView.origin, 'Holand');
await page.overwrite(selectors.itemCreateView.priority, '100');
await page.waitToClick(selectors.itemCreateView.createButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Valid priorities');
});
it('should create the Infinity Gauntlet item', async() => {
await page.overwrite(selectors.itemCreateView.priority, '2');
await page.waitToClick(selectors.itemCreateView.createButton);
const message = await page.waitForSnackbar();

View File

@ -48,17 +48,17 @@ describe('Item log path', () => {
await page.accessToSection('item.card.log');
});
it(`should confirm the log is showing 5 entries`, async() => {
it(`should confirm the log is showing 4 entries`, async() => {
await page.waitForSelector(selectors.itemLog.anyLineCreated);
const anyLineCreatedCount = await page.countElement(selectors.itemLog.anyLineCreated);
expect(anyLineCreatedCount).toEqual(5);
expect(anyLineCreatedCount).toEqual(4);
});
it(`should confirm the log is showing the intrastat for the created item`, async() => {
const fifthLineCreatedProperty = await page
.waitToGetProperty(selectors.itemLog.fifthLineCreatedProperty, 'innerText');
const fourthLineCreatedProperty = await page
.waitToGetProperty(selectors.itemLog.fourthLineCreatedProperty, 'innerText');
expect(fifthLineCreatedProperty).toEqual('Coral y materiales similares');
expect(fourthLineCreatedProperty).toEqual('Coral y materiales similares');
});
});

View File

@ -37,7 +37,9 @@ module.exports = Self => {
'typeFk',
'intrastatFk',
'originFk',
'relevancy'
'relevancy',
'priority',
'tag'
];
for (const key in params) {
@ -46,10 +48,14 @@ module.exports = Self => {
}
try {
const validPriorities = new Set([1, 2, 3]);
if (!validPriorities.has(params.priority))
throw new UserError(`Valid priorities: ${[...validPriorities]}`);
const provisionalName = params.provisionalName;
delete params.provisionalName;
const itemType = await models.ItemType.findById(params.typeFk, myOptions);
const itemType = await models.ItemType.findById(params.typeFk, {fields: ['isLaid']}, myOptions);
params.isLaid = itemType.isLaid;
@ -63,13 +69,14 @@ module.exports = Self => {
await Self.rawSql(query, null, myOptions);
let nameTag = await models.Tag.findOne({where: {name: 'Nombre temporal'}});
const nameTag = await models.Tag.findById(params.tag, {fields: ['id']}, myOptions);
let newTags = [];
newTags.push({itemFk: item.id, tagFk: nameTag.id, value: provisionalName, priority: '2'});
newTags.push({itemFk: item.id, tagFk: nameTag.id, value: provisionalName, priority: item.priority});
typeTags.forEach(typeTag => {
newTags.push({itemFk: item.id, tagFk: typeTag.tagFk, value: '', priority: typeTag.priority});
if (nameTag.id != typeTag.tagFk)
newTags.push({itemFk: item.id, tagFk: typeTag.tagFk, value: '', priority: typeTag.priority});
});
await models.ItemTag.create(newTags, myOptions);

View File

@ -11,7 +11,8 @@ describe('item new()', () => {
originFk: 1,
provisionalName: 'planta',
typeFk: 2,
relevancy: 0
priority: 2,
tag: 1
};
let item = await models.Item.new(itemParams, options);
@ -20,7 +21,7 @@ describe('item new()', () => {
item.isLaid = itemType.isLaid;
const temporalNameTag = await models.Tag.findOne({where: {name: 'Nombre temporal'}}, options);
const temporalNameTag = await models.Tag.findById(itemParams.tag, {fields: ['id']}, options);
const temporalName = await models.ItemTag.findOne({
where: {
@ -31,7 +32,7 @@ describe('item new()', () => {
item = await models.Item.findById(item.id, null, options);
itemType = await models.ItemType.findById(item.typeFk, options);
itemType = await models.ItemType.findById(item.typeFk, {fields: ['isLaid']}, options);
item.isLaid = itemType.isLaid;

View File

@ -16,10 +16,22 @@
<vn-card class="vn-pa-lg">
<vn-horizontal>
<vn-textfield
label="Temporal name"
ng-model="$ctrl.item.provisionalName"
label="Temporal name"
ng-model="$ctrl.item.provisionalName"
vn-focus>
</vn-textfield>
<vn-autocomplete
ng-model="$ctrl.item.tag"
translate-fields="['name']"
url="Tags"
show-field="name"
value-field="id"
label="Tag">
</vn-autocomplete>
<vn-input-number
label="Priority"
ng-model="$ctrl.item.priority">
</vn-input-number>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete

View File

@ -5,7 +5,9 @@ class Controller extends Section {
constructor($element, $) {
super($element, $);
this.item = {
relevancy: 0
relevancy: 0,
priority: 2,
tag: 1
};
}