Skip to content

Commit

Permalink
XIVY-14417 Fix condition in embedded sub
Browse files Browse the repository at this point in the history
  • Loading branch information
ivy-lli committed Feb 19, 2025
1 parent 5e079d5 commit b75e115
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,21 @@ describe('Condition', () => {
test('to', () => {
expect(Condition.to(conditions)).toEqual(altConditions);
});

const embeddedConditions: Condition[] = [
{ fid: 'S0-f1', expression: 'false' },
{ fid: 'S0-f8', expression: '' }
];

test('embedded condition', () => {
const ref: ConnectorRef = {
name: 'flow',
pid: 'asdf-S0-f8',
source: { name: 'alternative', pid: 'f5', type: altType },
target: { name: 'end', pid: 'f7', type: altType }
};
const expected = cloneObject(embeddedConditions);
expected[1].target = ref.target;
expect(Condition.replace(cloneObject(embeddedConditions), ref)).toEqual(expected);
});
});
2 changes: 1 addition & 1 deletion packages/inscription-view/src/utils/pid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('PID', () => {
test('field guid', () => {
expect(PID.fieldId(pid)).toEqual('');
expect(PID.fieldId(pid + '-f01')).toEqual('f01');
expect(PID.fieldId(pid + '-S01-f01')).toEqual('f01');
expect(PID.fieldId(pid + '-S01-f01')).toEqual('S01-f01');
});

test('create child', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/inscription-view/src/utils/pid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export namespace PID {
}

export function fieldId(pid: string): string {
const lastSeparator = pid.lastIndexOf(SEPARATOR);
const lastSeparator = pid.indexOf(SEPARATOR);
if (lastSeparator === -1) {
return '';
}
Expand Down

0 comments on commit b75e115

Please sign in to comment.