Measure refresh latency independently and retain intended result selection
This commit is contained in:
1 parent
373ed1ed49
commit
8b993b23d7
7 files changed
+188
-11
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { ResultSelection } from '../src/selection-state.ts';
|
||||
|
||||
test('restores intended result after temporary absence across empty and fallback responses', () => {
|
||||
const selection = new ResultSelection();
|
||||
selection.begin('supplier/all');
|
||||
assert.equal(selection.resolve(['supplier', 'retry']), 0);
|
||||
assert.equal(selection.resolve(['retry']), 0);
|
||||
assert.equal(selection.resolve([]), -1);
|
||||
assert.equal(selection.resolve(['retry', 'supplier']), 1);
|
||||
});
|
||||
|
||||
test('explicit user navigation supersedes the hidden result even when choosing the fallback', () => {
|
||||
const selection = new ResultSelection();
|
||||
selection.begin('supplier/all');
|
||||
selection.resolve(['supplier', 'retry']);
|
||||
selection.resolve(['retry']);
|
||||
selection.choose('retry');
|
||||
assert.equal(selection.resolve(['supplier', 'retry']), 1);
|
||||
});
|
||||
|
||||
test('changed query or filters reset intent, while same-scope retries retain it', () => {
|
||||
const selection = new ResultSelection();
|
||||
selection.begin('supplier/all');
|
||||
selection.resolve(['supplier', 'retry']);
|
||||
selection.choose('retry');
|
||||
selection.begin('supplier/all');
|
||||
assert.equal(selection.resolve(['supplier', 'retry']), 1);
|
||||
selection.begin('supplier/code');
|
||||
assert.equal(selection.resolve(['code', 'retry']), 0);
|
||||
selection.begin('garden/code');
|
||||
assert.equal(selection.resolve(['garden', 'code']), 0);
|
||||
selection.begin('');
|
||||
selection.begin('garden/code');
|
||||
assert.equal(selection.resolve(['code', 'garden']), 0);
|
||||
});
|
||||
|
||||
test('initially empty search establishes its first choice only when results arrive', () => {
|
||||
const selection = new ResultSelection();
|
||||
selection.begin('new/all');
|
||||
assert.equal(selection.resolve([]), -1);
|
||||
assert.equal(selection.resolve(['new', 'other']), 0);
|
||||
assert.equal(selection.resolve(['other', 'new']), 1);
|
||||
});
|
||||
Reference in new issue
Block a user