diff --git a/web/src/test/auto/headless/engine/predictive-text/worker-thread/correction-search/search-quotient-spur.tests.ts b/web/src/test/auto/headless/engine/predictive-text/worker-thread/correction-search/search-quotient-spur.tests.ts index 0f58b4fbbd..189790b7d3 100644 --- a/web/src/test/auto/headless/engine/predictive-text/worker-thread/correction-search/search-quotient-spur.tests.ts +++ b/web/src/test/auto/headless/engine/predictive-text/worker-thread/correction-search/search-quotient-spur.tests.ts @@ -76,6 +76,13 @@ describe('SearchQuotientSpur', () => { assert.deepEqual(extendedPath.bestExample, {text: 't', p: 0.5}); assert.deepEqual(extendedPath.parents, [rootPath]); assert.deepEqual(extendedPath.inputs, leadEdgeDistribution); + assert.deepEqual(extendedPath.sourceIdentifiers, [ + { + trueTransform: leadEdgeDistribution[0].sample, + inputStartIndex: 0, + bestProbFromSet: leadEdgeDistribution[0].p + } + ]); // Assert the root is unchanged. assert.equal(rootPath.inputCount, 0); @@ -121,6 +128,17 @@ describe('SearchQuotientSpur', () => { assert.deepEqual(length2Path.bestExample, {text: 'tr', p: leadEdgeDistribution[0].p * tailEdgeDistribution[0].p}); assert.deepEqual(length2Path.parents, [length1Path]); assert.deepEqual(length2Path.inputs, tailEdgeDistribution); + assert.deepEqual(length2Path.sourceIdentifiers, [ + { + trueTransform: leadEdgeDistribution[0].sample, + inputStartIndex: 0, + bestProbFromSet: leadEdgeDistribution[0].p + }, { + trueTransform: tailEdgeDistribution[0].sample, + inputStartIndex: 0, + bestProbFromSet: tailEdgeDistribution[0].p + } + ]); assert.equal(length1Path.inputCount, 1); assert.isNumber(length1Path.spaceId); @@ -130,6 +148,21 @@ describe('SearchQuotientSpur', () => { assert.deepEqual(length1Path.inputs, leadEdgeDistribution); }); + it('throws if input and input-source transition IDs mismatch', () => { + const rootPath = new LegacyQuotientRoot(testModel); + + const leadEdgeDistribution = [ + {sample: {insert: 't', deleteLeft: 0, id: 13 }, p: 0.5}, + {sample: {insert: 'a', deleteLeft: 0, id: 13 }, p: 0.3}, + {sample: {insert: 'o', deleteLeft: 0, id: 13 }, p: 0.2} + ]; + + assert.throws(() => new LegacyQuotientSpur(rootPath, leadEdgeDistribution, { + ...leadEdgeDistribution[0], + sample: {...leadEdgeDistribution[0].sample, id: 15} + })); + }); + it('may extend with a Transform inserting multiple codepoints', () => { const rootPath = new LegacyQuotientRoot(testModel); @@ -167,6 +200,17 @@ describe('SearchQuotientSpur', () => { assert.deepEqual(length2Path.bestExample, {text: 'tri', p: leadEdgeDistribution[0].p * tailEdgeDistribution[0].p}); assert.deepEqual(length2Path.parents, [length1Path]); assert.deepEqual(length2Path.inputs, tailEdgeDistribution); + assert.deepEqual(length2Path.sourceIdentifiers, [ + { + trueTransform: leadEdgeDistribution[0].sample, + inputStartIndex: 0, + bestProbFromSet: leadEdgeDistribution[0].p + }, { + trueTransform: tailEdgeDistribution[0].sample, + inputStartIndex: 0, + bestProbFromSet: tailEdgeDistribution[0].p + } + ]); assert.equal(length1Path.inputCount, 1); assert.isNumber(length1Path.spaceId);