From 27f7a4727bce7d56d6cf66eedc7c77245d59540e Mon Sep 17 00:00:00 2001 From: Joshua Horton Date: Tue, 26 Aug 2025 08:52:50 -0500 Subject: [PATCH] change(web): clarify path-last-match assertions --- .../context/alignment-helpers.tests.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/web/src/test/auto/headless/engine/predictive-text/worker-thread/context/alignment-helpers.tests.ts b/web/src/test/auto/headless/engine/predictive-text/worker-thread/context/alignment-helpers.tests.ts index 44bba81c3c..c2f820d949 100644 --- a/web/src/test/auto/headless/engine/predictive-text/worker-thread/context/alignment-helpers.tests.ts +++ b/web/src/test/auto/headless/engine/predictive-text/worker-thread/context/alignment-helpers.tests.ts @@ -14,28 +14,32 @@ import { computeAlignment, EditOperation, getEditPathLastMatch, isSubstitutionAl describe('getEditPathLastMatch', () => { it('returns the last match when no substitutions exist', () => { const path: EditOperation[] = ['delete', 'delete', 'match', 'match', 'match', 'match', 'insert']; - assert.equal(getEditPathLastMatch(path), path.lastIndexOf('match')); + assert.equal(path.lastIndexOf('match'), 5); + assert.equal(getEditPathLastMatch(path), 5); }); it('returns the last match when no substitutions exist left of a "match"', () => { const path: EditOperation[] = ['delete', 'delete', 'match', 'match', 'match', 'match', 'substitute', 'insert']; - assert.equal(getEditPathLastMatch(path), path.lastIndexOf('match')); + assert.equal(path.lastIndexOf('match'), 5); + assert.equal(getEditPathLastMatch(path), 5); }); // is intended to handle application of suggestions. it('returns the last match before a substitute occurring after the first match', () => { // limitation: if there is _anything_ after that last match, the first assertion will fail. + // 0 1 2 3 4 5 6 const path: EditOperation[] = ['delete', 'delete', 'match', 'match', 'substitute', 'match', 'match']; - assert.notEqual(getEditPathLastMatch(path), path.lastIndexOf('match')); - assert.equal(getEditPathLastMatch(path), path.lastIndexOf('match', path.lastIndexOf('substitute'))); + assert.notEqual(getEditPathLastMatch(path), 6); + assert.equal(getEditPathLastMatch(path), 3); }); // is intended to handle complex transforms that include a whitespace and affect prior tokens. it('returns the last match before a substitute occurring after the first match', () => { // limitation: if there is _anything_ after that last match, the first assertion will fail. + // 0 1 2 3 4 5 6 const path: EditOperation[] = ['delete', 'delete', 'match', 'match', 'substitute', 'match', 'substitute']; - assert.notEqual(getEditPathLastMatch(path), path.lastIndexOf('match')); - assert.equal(getEditPathLastMatch(path), path.lastIndexOf('match', path.indexOf('substitute'))); + assert.notEqual(getEditPathLastMatch(path), 5); + assert.equal(getEditPathLastMatch(path), 3); }); });