Fixed failing tests

This commit is contained in:
ThaumRystra
2025-01-16 16:24:56 +02:00
parent a2d2f43bed
commit 0bf8fdc6d3
79 changed files with 268 additions and 649 deletions

View File

@@ -85,7 +85,7 @@ const ActionSchema = createPropertySchema({
},
'resources.itemsConsumed.$._id': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
autoValue() {
if (!this.isSet) return Random.id();
}
@@ -100,7 +100,7 @@ const ActionSchema = createPropertySchema({
},
'resources.itemsConsumed.$.itemId': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
optional: true,
},
'resources.attributesConsumed': {
@@ -113,7 +113,7 @@ const ActionSchema = createPropertySchema({
},
'resources.attributesConsumed.$._id': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
autoValue() {
if (!this.isSet) return Random.id();
}
@@ -137,7 +137,7 @@ const ActionSchema = createPropertySchema({
},
'resources.conditions.$._id': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
autoValue() {
if (!this.isSet) return Random.id();
}

View File

@@ -247,7 +247,7 @@ const ComputedOnlyAttributeSchema = createPropertySchema({
},
'damageTriggerIds.before.$': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
},
'damageTriggerIds.after': {
type: Array,
@@ -255,7 +255,7 @@ const ComputedOnlyAttributeSchema = createPropertySchema({
},
'damageTriggerIds.after.$': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
},
'damageTriggerIds.afterChildren': {
type: Array,
@@ -263,7 +263,7 @@ const ComputedOnlyAttributeSchema = createPropertySchema({
},
'damageTriggerIds.afterChildren.$': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
},
// Triggers that fire when this property is used to make a check
'checkTriggerIds': {
@@ -277,7 +277,7 @@ const ComputedOnlyAttributeSchema = createPropertySchema({
},
'checkTriggerIds.before.$': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
},
'checkTriggerIds.after': {
type: Array,
@@ -285,7 +285,7 @@ const ComputedOnlyAttributeSchema = createPropertySchema({
},
'checkTriggerIds.after.$': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
},
'checkTriggerIds.afterChildren': {
type: Array,
@@ -293,7 +293,7 @@ const ComputedOnlyAttributeSchema = createPropertySchema({
},
'checkTriggerIds.afterChildren.$': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
},
});

View File

@@ -67,7 +67,7 @@ const ComputedOnlyBuffSchema = createPropertySchema({
},
'appliedBy.id': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
},
'appliedBy.collection': {
type: String,

View File

@@ -40,7 +40,7 @@ const ClassSchema = createPropertySchema({
},
'extraTags.$._id': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
autoValue() {
if (!this.isSet) return Random.id();
}

View File

@@ -73,7 +73,7 @@ const ItemSchema = createPropertySchema({
},
'ammoTriggerIds.before.$': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
},
'ammoTriggerIds.after': {
type: Array,
@@ -81,7 +81,7 @@ const ItemSchema = createPropertySchema({
},
'ammoTriggerIds.after.$': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
},
'ammoTriggerIds.afterChildren': {
type: Array,
@@ -89,7 +89,7 @@ const ItemSchema = createPropertySchema({
},
'ammoTriggerIds.afterChildren.$': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
},
});

View File

@@ -29,7 +29,7 @@ const PointBuySchema = createPropertySchema({
},
'values.$._id': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
autoValue() {
if (!this.isSet) return Random.id();
}

View File

@@ -37,7 +37,7 @@ const SlotSchema = createPropertySchema({
},
'extraTags.$._id': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
autoValue() {
if (!this.isSet) return Random.id();
}

View File

@@ -94,7 +94,7 @@ const TriggerSchema = createPropertySchema({
},
'extraTags.$._id': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
autoValue() {
if (!this.isSet) return Random.id();
}

View File

@@ -4,7 +4,7 @@ import { TypedSimpleSchema } from '/imports/api/utility/TypedSimpleSchema';
const AdjustmentSchema = TypedSimpleSchema.from({
_id: {
type: String,
max: 17,
max: 32,
autoValue() {
if (!this.isSet) return Random.id();
}

View File

@@ -34,7 +34,7 @@ const TagTargetingSchema = TypedSimpleSchema.from({
},
'extraTags.$._id': {
type: String,
regEx: SimpleSchema.RegEx.Id,
max: 32,
autoValue() {
if (!this.isSet) return Random.id();
}

View File

@@ -1,48 +0,0 @@
import { applyNestedSetProperties } from '/imports/api/parenting/parentingFunctions';
/**
* Take a forest of props, which can have sub-props nested in children: [], and return a list of
* clean props with correct tree and ancestry data
* @param props
* @returns
*/
export function propsFromForest(
props,
creatureId = Random.id(),
parentId = undefined,
recursionDepth = 0
) {
const result = [];
props.forEach(prop => {
const children = prop.children;
// Check the property has a type
if (!prop.type) {
throw new Error('Type is required on every property, not found on doc: ' + JSON.stringify(prop, null, 2));
}
// Create the clean doc
const doc = {
...prop,
left: result.length,
root: { id: creatureId, collection: 'creatures' },
};
if (parentId) {
doc.parentId = parentId;
}
if (!doc._id) {
doc._id = Random.id();
}
delete doc.children;
// Add the doc to the result and ancestry
result.push(doc);
if (children) {
result.push(...propsFromForest(children, creatureId, doc._id, recursionDepth + 1));
}
});
// Apply the nested set properties on the top level
if (recursionDepth === 0) {
applyNestedSetProperties(result);
}
return result;
}