diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 50f848c03..255fd35ef 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -10818,8 +10818,12 @@ function renderModels(p) { // becomes the only pick. A served one clicked used to be left out, // the rest of what was served picked in its place, so a click on // the one model wanted ticked every other (#681) + // once one is picked the provider serves its picks, so the last + // unpicked leaves none, not the vendor's list again (#1831, kchen0x: + // unpicking it went back to exposing every model) c.onclick = () => { draft.chosen = on ? draft.chosen.filter((x) => x !== m.id) : [...draft.chosen, m.id]; + draft.none = true; draw(); }; chips.append(c); @@ -10833,7 +10837,7 @@ function renderModels(p) { c.title = t("Added by hand"); tested(c, id); menu(c, id); - c.onclick = () => { draft.chosen = draft.chosen.filter((x) => x !== id); draw(); }; + c.onclick = () => { draft.chosen = draft.chosen.filter((x) => x !== id); draft.none = true; draw(); }; chips.append(c); } if (!p.models.length && !draft.chosen.length) chips.append(el("span", "hint", t("The vendor's list is empty. Fetch models again, or type a model id."))); @@ -10843,10 +10847,11 @@ function renderModels(p) { drawNames(); drawFold(); drawWorkOn(); + drawServes(); why.textContent = decideOnly(p) ? t("Agents never see them: a routing group picks one as its classifier.") : !draft.chosen.length && draft.none ? t("None selected: no agent or routing group uses its models. Its balance and usage still show. Click a model to pick it.") - : draft.unlisted ? t(draft.chosen.length ? "Agents don't see them: only the routing groups they are in use them." : "Agents don't see them: the routing groups they are in use the vendor's list, up to {n} (dashed). Select none to use none of them.", { n: 24 }) - : t(draft.chosen.length ? "Agents see the models picked." : "None picked: agents see the vendor's list, up to {n} (dashed). Click a model to pick just it, or Select none to use none of them while its balance and usage still show.", { n: 24 }); + : draft.unlisted ? t(draft.chosen.length ? "Agents don't see them: only the routing groups they are in use them." : "Vendor's list: agents don't see it, the routing groups its models are in use up to {n} of it (dashed). Click a model to pick just it.", { n: 24 }) + : t(draft.chosen.length ? "Agents see the models picked." : "Vendor's list: agents see up to {n} of its models (dashed), and those it lists later. Click a model to pick just it.", { n: 24 }); drawLost(); }; // those of its models in no routing group, while it is kept for groups: @@ -11180,6 +11185,31 @@ function renderModels(p) { } names.scrollTop = top; }; + // what the provider serves, said in so many words (#1831, kchen0x: with + // none picked it served every model, with one picked that one, and with + // that one unpicked every model again, while Select none served none and + // looked nearly the same): the vendor's list, or the models picked, none + // when none are. A click on a model, Select all or Select none is + // "Picked"; only "Vendor's list" goes back to the vendor's list + const serves = el("div", "segs mserves"); + const servesOpts = [["list", "Vendor's list", "Serve the vendor's list, up to {n} of it (dashed), models it lists later too"], ["picked", "Picked only", "Serve only the models picked: none while none are, its balance and usage still shown"]].map(([v, name, tip]) => { + const b = el("button", "opt", t(name)); + b.dataset.serves = v; + b.title = t(tip, { n: 24 }); + b.onclick = () => { + if (v === "list") { draft.chosen = []; draft.typed = ""; draft.none = false; } + else if (!draft.chosen.length) draft.none = true; + draw(); + }; + serves.append(b); + return b; + }); + const servesMode = () => draft.chosen.length || draft.none ? "picked" : "list"; + const drawServes = () => { + const now = servesMode(); + for (const b of servesOpts) { b.classList.toggle("on", b.dataset.serves === now); b.setAttribute("aria-pressed", b.dataset.serves === now); } + if (serves.isConnected) slide(serves, "serves"); + }; // every model at once (those the filter shows, when there is one), or none const bulk = el("div", "mbulk"); const allOn = el("button", "text action", t("Select all")); @@ -11188,6 +11218,7 @@ function renderModels(p) { const f = (q?.value || "").trim().toLowerCase(); const ids = p.models.filter((m) => !f || m.id.toLowerCase().includes(f) || (m.name || "").toLowerCase().includes(f) || (m.default || "").toLowerCase().includes(f)).map((m) => m.id); draft.chosen = [...draft.chosen, ...ids.filter((id) => !draft.chosen.includes(id))]; + draft.none = true; draw(); }; const allOff = el("button", "text action", t("Select none")); @@ -11204,6 +11235,7 @@ function renderModels(p) { freeOn.onclick = () => { const f = (q?.value || "").trim().toLowerCase(); draft.chosen = p.models.filter((m) => isFree(m) && (!f || m.id.toLowerCase().includes(f) || (m.name || "").toLowerCase().includes(f) || (m.default || "").toLowerCase().includes(f))).map((m) => m.id); + draft.none = true; draw(); }; bulk.append(freeOn); @@ -11223,6 +11255,7 @@ function renderModels(p) { const [ids, bad] = failedPicks(); if (!bad.length) return; draft.chosen = ids.filter((id) => !bad.includes(id)); + draft.none = true; draw(); status(t(bad.length === 1 ? "Unpicked 1 model that didn't answer" : "Unpicked {n} models that didn't answer", { n: bad.length }), "ok"); }; @@ -11235,6 +11268,7 @@ function renderModels(p) { workOn.title = bad ? t("Unpick the models whose last test failed; those that answered, and those not tested, stay picked") : t("Every picked model that was tested answered"); }; + if (!decideOnly(p)) { box.append(serves); queueMicrotask(drawServes); } if (q || p.models.length > 1) { if (q) { q.oninput = draw; bulk.prepend(q); } box.append(bulk); diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index 31d8a8478..d2bcf0272 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -3995,9 +3995,7 @@ const I18N = { "Pick {group}": "选 {group}", "{provider} is used only through routing groups: agents reach {model} by picking {group}.": "{provider} 设为只通过路由分组使用:选 {group} 即可用到 {model}。", "{provider} is used only through routing groups, and {model} is in none, so no agent can use it. Make a group of it, or untick “Only through routing groups” in {provider}'s models.": "{provider} 设为只通过路由分组使用,而 {model} 不在任何分组中,没有 Agent 能用它。可为它建分组,或在 {provider} 的模型中取消勾选「只通过路由分组使用」。", - "None picked: agents see the vendor's list, up to {n} (dashed). Click a model to pick just it, or Select none to use none of them while its balance and usage still show.": "未勾选:Agent 看到供应商的列表,最多 {n} 个(虚线框)。点击模型可单选;点「全不选」则不使用任何模型,余额和用量照常显示。", "None selected: no agent or routing group uses its models. Its balance and usage still show. Click a model to pick it.": "全不选:Agent 和路由分组都不使用它的模型,余额和用量照常显示。点击模型可勾选。", - "Agents don't see them: the routing groups they are in use the vendor's list, up to {n} (dashed). Select none to use none of them.": "Agent 看不到这些模型:它们所在的路由分组使用供应商的列表,最多 {n} 个(虚线框)。点「全不选」则一个都不使用。", "Routing groups use it: none are picked, so the vendor's list is used": "路由分组会用到它:没有勾选任何模型时,用的是供应商的列表", "Click to pick just this model": "点击只选这个模型", "Agents see it: none are picked, so the vendor's list is used": "Agent 能看到它:没有勾选任何模型时,用的是供应商的列表", @@ -4251,6 +4249,12 @@ const I18N = { "1 skill in {src}": "{src} 中有 1 个技能", "{n} skills in {src}": "{src} 中有 {n} 个技能", "Select none": "全不选", + "Vendor's list": "供应商列表", + "Picked only": "仅所选", + "Serve the vendor's list, up to {n} of it (dashed), models it lists later too": "提供供应商的列表,最多 {n} 个(虚线框),之后新上的模型也包括在内", + "Serve only the models picked: none while none are, its balance and usage still shown": "只提供勾选的模型:一个都没勾时不提供任何模型,余额和用量照常显示", + "Vendor's list: agents don't see it, the routing groups its models are in use up to {n} of it (dashed). Click a model to pick just it.": "供应商列表:Agent 看不到,模型所在的路由分组最多使用其中 {n} 个(虚线框)。点击模型可单选。", + "Vendor's list: agents see up to {n} of its models (dashed), and those it lists later. Click a model to pick just it.": "供应商列表:Agent 看到最多 {n} 个模型(虚线框),之后新上的也会看到。点击模型可单选。", "Free only": "只选免费", "Pick only the free models (those the filter shows), unpicking the others": "只选中免费模型(有筛选时只选筛出来的),其余取消选中", "Working only": "只选可用", @@ -8629,9 +8633,7 @@ const I18N = { "Pick {group}": "選 {group}", "{provider} is used only through routing groups: agents reach {model} by picking {group}.": "{provider} 設為只透過路由分組使用:選 {group} 即可用到 {model}。", "{provider} is used only through routing groups, and {model} is in none, so no agent can use it. Make a group of it, or untick “Only through routing groups” in {provider}'s models.": "{provider} 設為只透過路由分組使用,而 {model} 不在任何分組中,沒有 Agent 能用它。可為它建分組,或在 {provider} 的模型中取消勾選「只透過路由分組使用」。", - "None picked: agents see the vendor's list, up to {n} (dashed). Click a model to pick just it, or Select none to use none of them while its balance and usage still show.": "未勾選:Agent 看到供應商的列表,最多 {n} 個(虛線框)。點選模型可單選;點「全不選」則不使用任何模型,餘額和用量照常顯示。", "None selected: no agent or routing group uses its models. Its balance and usage still show. Click a model to pick it.": "全不選:Agent 和路由分組都不使用它的模型,餘額和用量照常顯示。點選模型可勾選。", - "Agents don't see them: the routing groups they are in use the vendor's list, up to {n} (dashed). Select none to use none of them.": "Agent 看不到這些模型:它們所在的路由分組使用供應商的列表,最多 {n} 個(虛線框)。點「全不選」則一個都不使用。", "Routing groups use it: none are picked, so the vendor's list is used": "路由分組會用到它:沒有勾選任何模型時,用的是供應商的列表", "Click to pick just this model": "點選只選這個模型", "Agents see it: none are picked, so the vendor's list is used": "Agent 能看到它:沒有勾選任何模型時,用的是供應商的列表", @@ -8880,6 +8882,12 @@ const I18N = { "1 skill in {src}": "{src} 中有 1 個技能", "{n} skills in {src}": "{src} 中有 {n} 個技能", "Select none": "全不選", + "Vendor's list": "供應商列表", + "Picked only": "僅所選", + "Serve the vendor's list, up to {n} of it (dashed), models it lists later too": "提供供應商的列表,最多 {n} 個(虛線框),之後新上的模型也包括在內", + "Serve only the models picked: none while none are, its balance and usage still shown": "只提供勾選的模型:一個都沒勾時不提供任何模型,餘額和用量照常顯示", + "Vendor's list: agents don't see it, the routing groups its models are in use up to {n} of it (dashed). Click a model to pick just it.": "供應商列表:Agent 看不到,模型所在的路由分組最多使用其中 {n} 個(虛線框)。點選模型可單選。", + "Vendor's list: agents see up to {n} of its models (dashed), and those it lists later. Click a model to pick just it.": "供應商列表:Agent 看到最多 {n} 個模型(虛線框),之後新上的也會看到。點選模型可單選。", "Free only": "只選免費", "Pick only the free models (those the filter shows), unpicking the others": "只選中免費模型(有篩選時只選篩出來的),其餘取消選中", "Working only": "只選可用", @@ -13279,9 +13287,7 @@ const I18N = { "Pick {group}": "{group} を選択", "{provider} is used only through routing groups: agents reach {model} by picking {group}.": "{provider} はルーティンググループ経由でのみ使われます:{group} を選ぶとエージェントは {model} を使えます。", "{provider} is used only through routing groups, and {model} is in none, so no agent can use it. Make a group of it, or untick “Only through routing groups” in {provider}'s models.": "{provider} はルーティンググループ経由でのみ使われ、{model} はどのグループにも入っていないため、どのエージェントも使えません。これでグループを作成するか、{provider} のモデルで「ルーティンググループ経由のみ」のチェックを外してください。", - "None picked: agents see the vendor's list, up to {n} (dashed). Click a model to pick just it, or Select none to use none of them while its balance and usage still show.": "未選択:エージェントにはベンダーのリストが最大 {n} 件(破線)表示されます。モデルをクリックするとそれだけを選択します。「選択をすべて解除」でどれも使わず、残高と使用量は引き続き表示されます。", "None selected: no agent or routing group uses its models. Its balance and usage still show. Click a model to pick it.": "選択なし:エージェントもルーティンググループもこのモデルを使いません。残高と使用量は引き続き表示されます。モデルをクリックすると選択します。", - "Agents don't see them: the routing groups they are in use the vendor's list, up to {n} (dashed). Select none to use none of them.": "エージェントには見えません:所属するルーティンググループがベンダーのリストを最大 {n} 件(破線)使います。「選択をすべて解除」でどれも使いません。", "Routing groups use it: none are picked, so the vendor's list is used": "ルーティンググループが使います:何も選択されていないため、ベンダーのリストが使われます", "Click to pick just this model": "クリックしてこのモデルだけを選択", "Agents see it: none are picked, so the vendor's list is used": "エージェントに表示されます:何も選択されていないため、ベンダーのリストが使われます", @@ -13531,6 +13537,12 @@ const I18N = { "1 skill in {src}": "{src} に 1 個のスキル", "{n} skills in {src}": "{src} に {n} 個のスキル", "Select none": "選択をすべて解除", + "Vendor's list": "ベンダーのリスト", + "Picked only": "選択したもののみ", + "Serve the vendor's list, up to {n} of it (dashed), models it lists later too": "ベンダーのリストを最大 {n} 件(破線)提供します。後から追加されたモデルも含みます", + "Serve only the models picked: none while none are, its balance and usage still shown": "選択したモデルだけを提供します。何も選択していなければ何も提供せず、残高と使用量は引き続き表示されます", + "Vendor's list: agents don't see it, the routing groups its models are in use up to {n} of it (dashed). Click a model to pick just it.": "ベンダーのリスト:エージェントには表示されず、モデルが属するルーティンググループが最大 {n} 件(破線)を使います。モデルをクリックするとそれだけを選択します。", + "Vendor's list: agents see up to {n} of its models (dashed), and those it lists later. Click a model to pick just it.": "ベンダーのリスト:エージェントにはモデルが最大 {n} 件(破線)表示され、後から追加されたものも表示されます。モデルをクリックするとそれだけを選択します。", "Free only": "無料のみ", "Pick only the free models (those the filter shows), unpicking the others": "無料モデル(フィルタで表示されているもの)だけを選択し、他は選択を解除します", "Working only": "使えるもののみ", @@ -17932,9 +17944,7 @@ const I18N = { "Pick {group}": "{group} wählen", "{provider} is used only through routing groups: agents reach {model} by picking {group}.": "{provider} wird nur über Weiterleitungsgruppen genutzt: Agenten erreichen {model}, indem sie {group} wählen.", "{provider} is used only through routing groups, and {model} is in none, so no agent can use it. Make a group of it, or untick “Only through routing groups” in {provider}'s models.": "{provider} wird nur über Weiterleitungsgruppen genutzt, und {model} ist in keiner, daher kann es kein Agent nutzen. Erstellen Sie eine Gruppe daraus oder entfernen Sie den Haken bei „Nur über Weiterleitungsgruppen“ in den Modellen von {provider}.", - "None picked: agents see the vendor's list, up to {n} (dashed). Click a model to pick just it, or Select none to use none of them while its balance and usage still show.": "Nichts gewählt: Agenten sehen die Liste des Anbieters, bis zu {n} (gestrichelt). Klicken Sie auf ein Modell, um nur dieses zu wählen, oder auf „Keine auswählen“, um keines zu nutzen; Guthaben und Nutzung werden weiter angezeigt.", "None selected: no agent or routing group uses its models. Its balance and usage still show. Click a model to pick it.": "Keine ausgewählt: Weder Agenten noch Weiterleitungsgruppen nutzen seine Modelle. Guthaben und Nutzung werden weiter angezeigt. Klicken Sie auf ein Modell, um es zu wählen.", - "Agents don't see them: the routing groups they are in use the vendor's list, up to {n} (dashed). Select none to use none of them.": "Agenten sehen sie nicht: Die Weiterleitungsgruppen, in denen sie sind, nutzen die Liste des Anbieters, bis zu {n} (gestrichelt). „Keine auswählen“ nutzt keines davon.", "Routing groups use it: none are picked, so the vendor's list is used": "Weiterleitungsgruppen nutzen es: Nichts ist gewählt, daher gilt die Liste des Anbieters", "Click to pick just this model": "Klicken, um nur dieses Modell zu wählen", "Agents see it: none are picked, so the vendor's list is used": "Agenten sehen es: Nichts ist gewählt, daher gilt die Liste des Anbieters", @@ -18184,6 +18194,12 @@ const I18N = { "1 skill in {src}": "1 Skill in {src}", "{n} skills in {src}": "{n} Skills in {src}", "Select none": "Keine auswählen", + "Vendor's list": "Liste des Anbieters", + "Picked only": "Nur gewählte", + "Serve the vendor's list, up to {n} of it (dashed), models it lists later too": "Die Liste des Anbieters anbieten, bis zu {n} Modelle (gestrichelt), auch später hinzukommende", + "Serve only the models picked: none while none are, its balance and usage still shown": "Nur die gewählten Modelle anbieten: keines, solange keines gewählt ist; Guthaben und Nutzung werden weiter angezeigt", + "Vendor's list: agents don't see it, the routing groups its models are in use up to {n} of it (dashed). Click a model to pick just it.": "Liste des Anbieters: Agenten sehen sie nicht, die Weiterleitungsgruppen seiner Modelle nutzen bis zu {n} davon (gestrichelt). Klicken Sie auf ein Modell, um nur dieses zu wählen.", + "Vendor's list: agents see up to {n} of its models (dashed), and those it lists later. Click a model to pick just it.": "Liste des Anbieters: Agenten sehen bis zu {n} seiner Modelle (gestrichelt), auch später hinzukommende. Klicken Sie auf ein Modell, um nur dieses zu wählen.", "Free only": "Nur kostenlose", "Pick only the free models (those the filter shows), unpicking the others": "Nur die kostenlosen Modelle wählen (die der Filter zeigt), die übrigen abwählen", "Working only": "Nur funktionierende", diff --git a/internal/gui/tests/provider-none-picked.test.cjs b/internal/gui/tests/provider-none-picked.test.cjs index 26e962e5f..e159b077d 100644 --- a/internal/gui/tests/provider-none-picked.test.cjs +++ b/internal/gui/tests/provider-none-picked.test.cjs @@ -9,8 +9,11 @@ // again as none (#1818: it was saved as no picks, and the card, the gateway // and the auto groups all served 17). Kept for routing groups alone with // none picked, the models the groups use are drawn dashed too (#1818: drawn -// as none while the groups used them). In every language, Chromium and -// WebKit. +// as none while the groups used them). What it serves is said by a +// two-way control, Vendor's list or Picked only, and the last pick +// unpicked leaves none, as Select none does, not the vendor's list again +// (#1831, kchen0x). In every language, Chromium and WebKit, at 1100 and +// 420 wide. const assert = require("node:assert/strict"); const fs = require("node:fs/promises"); const path = require("node:path"); @@ -52,23 +55,24 @@ function serve(lang, saves) { // hint after Select none; groupsWhy, groupsHint: those kept for routing // groups alone const words = { - en: { save: "Save", selectNone: "Select none", why: "Agents see it: none are picked", hint: "or Select none to use none of them while its balance and usage still show", none: "None selected: no agent or routing group uses its models", groupsWhy: "Routing groups use it: none are picked", groupsHint: "the routing groups they are in use the vendor's list" }, - zh: { save: "保存", selectNone: "全不选", why: "Agent 能看到它:没有勾选任何模型时", hint: "点「全不选」则不使用任何模型,余额和用量照常显示", none: "全不选:Agent 和路由分组都不使用它的模型", groupsWhy: "路由分组会用到它", groupsHint: "它们所在的路由分组使用供应商的列表" }, - "zh-TW": { save: "儲存", selectNone: "全不選", why: "Agent 能看到它:沒有勾選任何模型時", hint: "點「全不選」則不使用任何模型,餘額和用量照常顯示", none: "全不選:Agent 和路由分組都不使用它的模型", groupsWhy: "路由分組會用到它", groupsHint: "它們所在的路由分組使用供應商的列表" }, - ja: { save: "保存", selectNone: "選択をすべて解除", why: "エージェントに表示されます:何も選択されていない", hint: "「選択をすべて解除」でどれも使わず", none: "選択なし:エージェントもルーティンググループも", groupsWhy: "ルーティンググループが使います", groupsHint: "所属するルーティンググループがベンダーのリスト" }, - de: { save: "Speichern", selectNone: "Keine auswählen", why: "Agenten sehen es: Nichts ist gewählt", hint: "„Keine auswählen“, um keines zu nutzen", none: "Keine ausgewählt: Weder Agenten noch Weiterleitungsgruppen", groupsWhy: "Weiterleitungsgruppen nutzen es", groupsHint: "Die Weiterleitungsgruppen, in denen sie sind, nutzen die Liste des Anbieters" }, + en: { save: "Save", selectNone: "Select none", list: "Vendor's list", picked: "Picked only", why: "Agents see it: none are picked", hint: "Vendor's list: agents see up to 24 of its models", none: "None selected: no agent or routing group uses its models", groupsWhy: "Routing groups use it: none are picked", groupsHint: "the routing groups its models are in use up to 24" }, + zh: { save: "保存", selectNone: "全不选", list: "供应商列表", picked: "仅所选", why: "Agent 能看到它:没有勾选任何模型时", hint: "供应商列表:Agent 看到最多 24 个模型", none: "全不选:Agent 和路由分组都不使用它的模型", groupsWhy: "路由分组会用到它", groupsHint: "模型所在的路由分组最多使用其中 24 个" }, + "zh-TW": { save: "儲存", selectNone: "全不選", list: "供應商列表", picked: "僅所選", why: "Agent 能看到它:沒有勾選任何模型時", hint: "供應商列表:Agent 看到最多 24 個模型", none: "全不選:Agent 和路由分組都不使用它的模型", groupsWhy: "路由分組會用到它", groupsHint: "模型所在的路由分組最多使用其中 24 個" }, + ja: { save: "保存", selectNone: "選択をすべて解除", list: "ベンダーのリスト", picked: "選択したもののみ", why: "エージェントに表示されます:何も選択されていない", hint: "エージェントにはモデルが最大 24 件", none: "選択なし:エージェントもルーティンググループも", groupsWhy: "ルーティンググループが使います", groupsHint: "ルーティンググループが最大 24 件" }, + de: { save: "Speichern", selectNone: "Keine auswählen", list: "Liste des Anbieters", picked: "Nur gewählte", why: "Agenten sehen es: Nichts ist gewählt", hint: "Agenten sehen bis zu 24 seiner Modelle", none: "Keine ausgewählt: Weder Agenten noch Weiterleitungsgruppen", groupsWhy: "Weiterleitungsgruppen nutzen es", groupsHint: "Weiterleitungsgruppen seiner Modelle nutzen bis zu 24" }, }; for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { for (const lang of Object.keys(words)) { - const w = words[lang]; - test(`${engine} ${lang}: with none picked, the models agents are served are drawn as served`, async (t) => { + const w = words[lang]; + for (const width of [1100, 420]) { + test(`${engine} ${lang} ${width}: with none picked, the models agents are served are drawn as served`, async (t) => { const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); - const page = await (await browser.newContext({ viewport: { width: 900, height: 760 }, reducedMotion: "reduce" })).newPage(); + const page = await (await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" })).newPage(); t.after(async () => { if (process.env.ARTIFACT_DIR) { await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true }); - await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-provider-none-picked.png`) }); + await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}-provider-none-picked.png`) }); } await browser.close(); }); @@ -83,6 +87,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", const chip = (id) => editor.locator(".mchips .mchip", { hasText: id }); await chip("glm-5.2").waitFor(); const cls = (id) => chip(id).evaluate((c) => [c.classList.contains("on"), c.classList.contains("auto")]); + // which of Vendor's list / Picked only is on, and the control fits + const serves = async () => { + const seg = editor.locator(".mserves"); + const box = await seg.boundingBox(), ed = await editor.boundingBox(); + assert.ok(box && box.x >= ed.x - 1 && box.x + box.width <= ed.x + ed.width + 1, "the control fits the editor"); + return seg.locator(".opt.on").innerText(); + }; // opened with none picked, both are drawn as served, not as picked // (#614: they were drawn ticked, and the next Save made them picks) @@ -92,12 +103,29 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", } assert.equal(await chip("glm-5.2").evaluate((c) => getComputedStyle(c).borderTopStyle), "dashed"); await editor.getByText(w.hint, { exact: false }).waitFor(); + assert.equal(await serves(), w.list); // a served one clicked is picked, alone (#681) await chip("glm-5.2").click(); assert.deepEqual(await cls("glm-5.2"), [true, false]); assert.deepEqual(await cls("glm-5.3-free"), [false, false]); assert.equal(await editor.getByText(w.hint, { exact: false }).count(), 0); + assert.equal(await serves(), w.picked); + // and unpicked, it leaves none picked, which serves none, drawn as + // Select none draws it (#1831: it went back to the vendor's list) + await chip("glm-5.2").click(); + for (const id of ["glm-5.3-free", "glm-5.2"]) assert.deepEqual(await cls(id), [false, false], id + " after the last pick unpicked"); + await editor.getByText(w.none, { exact: false }).waitFor(); + assert.equal(await serves(), w.picked); + // Vendor's list goes back to it + await editor.locator(".mserves .opt", { hasText: w.list }).click(); + for (const id of ["glm-5.3-free", "glm-5.2"]) assert.deepEqual(await cls(id), [false, true], id + " vendor's list again"); + await editor.getByText(w.hint, { exact: false }).waitFor(); + assert.equal(await serves(), w.list); + // Picked only with none picked is none + await editor.locator(".mserves .opt", { hasText: w.picked }).click(); + await editor.getByText(w.none, { exact: false }).waitFor(); + await chip("glm-5.2").click(); // and another clicked joins it await chip("glm-5.3-free").click(); assert.deepEqual(await cls("glm-5.2"), [true, false]); @@ -126,6 +154,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", assert.deepEqual(errors, []); }); + } test(`${engine} ${lang}: kept for routing groups with none picked, the models the groups use are drawn as served`, async (t) => { const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); t.after(() => browser.close());