Add browser match controls
This commit is contained in:
@@ -69,6 +69,9 @@ test("shouldContinueWatchingState keeps polling locked login pages", () => {
|
||||
|
||||
test("default settings include a blank bearer token that can be overridden by harness patching", () => {
|
||||
assert.equal(background.defaultSettings.bearerToken, "");
|
||||
assert.equal(background.defaultSettings.bestMatchOnly, false);
|
||||
assert.equal(background.defaultSettings.requireSchemeMatch, false);
|
||||
assert.equal(background.defaultSettings.sortResults, "quality");
|
||||
});
|
||||
|
||||
test("savePlanForObservedLogin prefers updating an exact username match", () => {
|
||||
@@ -129,3 +132,45 @@ test("savePlanForObservedLogin falls back to saving into the current page group"
|
||||
url: "https://vault.example.invalid/login"
|
||||
});
|
||||
});
|
||||
|
||||
test("applyMatchControls keeps only the strongest quality band when best-match-only is enabled", () => {
|
||||
const filtered = background.applyMatchControls([
|
||||
{ id: "livingston", title: "Livingston Dell", quality: "exact" },
|
||||
{ id: "rusty", title: "Rusty Ryan", quality: "host" },
|
||||
{ id: "linus", title: "Linus Caldwell", quality: "scheme" }
|
||||
], {
|
||||
bestMatchOnly: true,
|
||||
requireSchemeMatch: false,
|
||||
sortResults: "quality"
|
||||
}, "https://vault.example.invalid/login");
|
||||
|
||||
assert.deepEqual(filtered.map((match) => match.id), ["livingston"]);
|
||||
});
|
||||
|
||||
test("applyMatchControls removes explicit scheme mismatches but keeps scheme-less matches", () => {
|
||||
const filtered = background.applyMatchControls([
|
||||
{ id: "yen", title: "The Amazing Yen", url: "https://vault.example.invalid/login", quality: "exact" },
|
||||
{ id: "saul", title: "Saul Bloom", url: "http://vault.example.invalid/login", quality: "exact" },
|
||||
{ id: "basher", title: "Basher Tarr", url: "vault.example.invalid", quality: "host" }
|
||||
], {
|
||||
bestMatchOnly: false,
|
||||
requireSchemeMatch: true,
|
||||
sortResults: "quality"
|
||||
}, "https://vault.example.invalid/login");
|
||||
|
||||
assert.deepEqual(filtered.map((match) => match.id), ["yen", "basher"]);
|
||||
});
|
||||
|
||||
test("applyMatchControls sorts by path when requested", () => {
|
||||
const filtered = background.applyMatchControls([
|
||||
{ id: "linus", title: "Linus Caldwell", path: ["Crew", "Inside"] },
|
||||
{ id: "rusty", title: "Rusty Ryan", path: ["Crew", "Casino"] },
|
||||
{ id: "danny", title: "Danny Ocean", path: ["Crew"] }
|
||||
], {
|
||||
bestMatchOnly: false,
|
||||
requireSchemeMatch: false,
|
||||
sortResults: "path"
|
||||
}, "https://vault.example.invalid/login");
|
||||
|
||||
assert.deepEqual(filtered.map((match) => match.id), ["danny", "rusty", "linus"]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user