-
Notifications
You must be signed in to change notification settings - Fork 36
Fix CI failing tests #464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix CI failing tests #464
Changes from all commits
367609b
dc1514c
b84f086
59c5869
57c3683
765c7d4
da54ab4
2a7d64c
daacbcf
89818f0
69d7167
f083306
b0d2962
e1258b2
d1b381d
89cb477
c016ff2
3c4441c
c191a27
9c356d7
c1a1e5b
ac0e877
ffd1a23
124c491
b94e0c8
d04261b
cf5c465
825f0ba
e17f90b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module.exports = { | ||
| presets: [['@babel/preset-env', {targets: {node: 'current'}}]], | ||
| }; | ||
|
ddooley marked this conversation as resolved.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -293,6 +293,8 @@ class Validator { | |
| // Issue: parse can fail on decimal but menu has "Missing" | ||
| if (parsed === undefined) { | ||
| parse_error = `Value does not match format for ${slotType.uri}`; | ||
| // We do not process any nested anyOf, allOf, etc. | ||
| return parse_error | ||
|
Comment on lines
+296
to
+297
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The test suite expects us to return this error immediately, so we must return parse error here. Otherwise we will try to process the Previously, there was a |
||
|
|
||
| //if (!(anyOfValidators.length || allOfValidators.length || exactlyOneOfValidators.length || noneOfValidators.length)) { | ||
| // return parse_error; | ||
|
|
@@ -325,8 +327,10 @@ class Validator { | |
| return 'Value does not match pattern'; | ||
| } | ||
|
|
||
| // Here slotType value tested and is ok! | ||
| continue; | ||
| // The below code was preventing the remaining code from being | ||
| // reached, which included processing any_of, all_of, etc. | ||
| // // Here slotType value tested and is ok! | ||
| // continue; | ||
|
ddooley marked this conversation as resolved.
|
||
| } | ||
|
|
||
| // Here value didn't parse to slotType | ||
|
|
@@ -379,17 +383,21 @@ class Validator { | |
| } | ||
| } | ||
|
|
||
| if ( | ||
| anyOfValidators.length || | ||
| allOfValidators.length || | ||
| exactlyOneOfValidators.length || | ||
| noneOfValidators.length | ||
| ) { | ||
| // We passed validation here which means a parse error can be overriden | ||
| } else if (parse_error.length) { | ||
| //There were no other ranges besides basic slotType so | ||
| return parse_error; | ||
| } | ||
| // The below code seems to imply that we can ignore parse errors, as | ||
| // long as nested anyOfs, allOfs, etc. are valid. The test suite seems | ||
| // to want something different, so we now return parse error | ||
| // immediately further up in the code. | ||
| // if ( | ||
| // anyOfValidators.length || | ||
| // allOfValidators.length || | ||
| // exactlyOneOfValidators.length || | ||
| // noneOfValidators.length | ||
| // ) { | ||
| // // We passed validation here which means a parse error can be overriden | ||
| // } else if (parse_error.length) { | ||
| // //There were no other ranges besides basic slotType so | ||
| // return parse_error; | ||
| // } | ||
| } | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -187,8 +187,16 @@ export function slotNamesForTitlesMap(fields) { | |
| const fieldSymbolsAtIndex = fieldSymbolsAtIndexMap(fields); | ||
| let tempObject = {}; | ||
| for (let index in fieldSymbolsAtIndex) { | ||
| tempObject[fieldSymbolsAtIndex[index].slotTitle] = | ||
| fieldSymbolsAtIndex[index].slotName; | ||
| // The below code was running into issues when slotTitle did not exist | ||
| // tempObject[fieldSymbolsAtIndex[index].slotTitle] = | ||
| // fieldSymbolsAtIndex[index].slotName; | ||
|
|
||
| const slotName = fieldSymbolsAtIndex[index].slotName; | ||
| let slotTitle = fieldSymbolsAtIndex[index].slotTitle; | ||
| // If slotTitle not specified; use slotName as slotTitle | ||
| slotTitle = slotTitle === undefined ? slotName : slotTitle; | ||
|
|
||
| tempObject[slotTitle] = slotName; | ||
|
Comment on lines
+194
to
+199
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this what we want? A test was failing previously because the |
||
| } | ||
| return tempObject; | ||
| } | ||
|
|
@@ -206,15 +214,28 @@ export function slotTitleForNameMap(fields) { | |
| export function findFieldIndex(fields, key, translationMap = {}) { | ||
| // First try to find a direct match. | ||
| let index = fields.findIndex((f) => { | ||
| return f.name === key || f.alias === key; | ||
| // Consider the following situation: | ||
| // `key === undefined` | ||
| // `f = {'name': 'a', 'title': 'a'}` | ||
| // If we do not check whether `f` has `name` or `alias`, then: | ||
| // 1) `f.name === key || f.alias === key` | ||
| // 2) `'a' === undefined || undefined === undefined` | ||
| // 3) `false || true` | ||
| // 4) `true` --> direct match | ||
| // i.e., we directly match `undefined` to a defined field with name `a` | ||
|
ddooley marked this conversation as resolved.
|
||
| const sameName = Object.hasOwn(f, 'name') && f.name === key; | ||
| const sameAlias = Object.hasOwn(f, 'alias') && f.alias === key; | ||
| return sameName || sameAlias; | ||
| }); | ||
|
|
||
| // If no direct match, try to find a match through the translation map. | ||
| if (index < 0 && translationMap[key]) { | ||
| const untranslatedKey = translationMap[key]; | ||
| index = fields.findIndex( | ||
| (f) => f.name === untranslatedKey || f.alias === untranslatedKey | ||
| ); | ||
| const translatedKey = translationMap[key]; | ||
| index = fields.findIndex((f) => { | ||
| const sameName = Object.hasOwn(f, 'name') && f.name === translatedKey; | ||
| const sameAlias = Object.hasOwn(f, 'alias') && f.alias === translatedKey; | ||
| return sameName || sameAlias; | ||
| }); | ||
| } | ||
|
|
||
| return index; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.