diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index f0ccd96e..77342de9 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -1236,6 +1236,20 @@ def log_message(self, *_): # « Avancé », the address left empty, saved with the service chosen above, and read again. press(browser, "transcription-advanced") wait_for(browser, lambda b: b.find_element(By.ID, "transcription-model").is_displayed(), 3) + # One save per setting (#860), as macOS's and GNOME's settings have it: « Avancé » unfolded shows one + # « Enregistrer » and one agreement at most, and that one saves what the page shows — the address + # left empty, the model typed or else the one chosen in the list. + shown_of = ("return arguments[0].filter((id) => { const e = document.getElementById(id); return !!e && e.getClientRects().length > 0; })") + saves, agreements = ["transcription-save", "transcription-own-save"], ["transcription-agreed", "transcription-own-agreed"] + one = browser.execute_script(shown_of, saves) + check("« Avancé » unfolded: one « Enregistrer » shown, one agreement at most (#860)", + len(one) == 1 and len(browser.execute_script(shown_of, agreements)) <= 1, [one, browser.execute_script(shown_of, agreements)]) + if one: + press(browser, one[0]) + kept = wait_for(browser, lambda b: "cet ordinateur transcrira" in b.execute_script(said), 5) + check("nothing typed under « Avancé »: that « Enregistrer » saves the service chosen above, the model chosen in its list (#860)", + kept and 'transcription_model = "vendor/scribe"' in window.file.read_text() and f'transcription_provider = "{stand}"' in window.file.read_text(), + (browser.execute_script(said), window.file.read_text())) check("« Avancé », its address left empty: the service chosen above shown standing in", browser.find_element(By.ID, "transcription-provider").get_attribute("placeholder") == stand, browser.find_element(By.ID, "transcription-provider").get_attribute("placeholder")) @@ -1550,6 +1564,8 @@ def log_message(self, *_): own.send_keys("https://hears.example/v1") away_asked = wait_for(browser, lambda b: b.execute_script(own_agreement), 3) check("one's own address: no agreement for this computer, one for a host elsewhere (#859)", here_none and away_asked, [here_none, away_asked]) + both = browser.execute_script("return ['transcription-agreed', 'transcription-own-agreed'].filter((id) => { const e = document.getElementById(id); return !!e && e.getClientRects().length > 0; })") + check("a host elsewhere typed under « Avancé »: one agreement shown, its own (#860)", both == ["transcription-own-agreed"], both) own.clear() browser.execute_script("document.getElementById('transcription-where').scrollIntoView({block: 'start'})") shot_themed(browser, "d95-transcription-service-light", "light") diff --git a/modules/shell/ui/window.js b/modules/shell/ui/window.js index 2186b183..0dc4ae05 100644 --- a/modules/shell/ui/window.js +++ b/modules/shell/ui/window.js @@ -2578,13 +2578,22 @@ function showSettings(shown, minutes, words) { const [modelsWrap, serviceModels] = guidedList("transcription-models", words.service_model, locked); const [agreeWrap, agreeBox, agreeHost, agreeShown] = agreement("transcription-agreed"); const saveService = guidedButton("transcription-save", words.service_save, true, locked); + // One « Enregistrer » and one agreement at a time (#860): the service's, « Avancé » folded; unfolded, + // its own, which saves what the page shows. + let listedShown = false; + const paintSaves = () => { + const open = guided.transcription.advanced; + saveService.hidden = !listedShown || open; + agreeShown(listedShown && !open); + }; // The models listed with its key, the one saved chosen. const shownListed = (models) => { serviceModels.replaceChildren(); for (const id of models) guidedOption(serviceModels, id, modelSaid(id)); if (models.includes(shown.transcription_model)) serviceModels.value = shown.transcription_model; - modelsWrap.hidden = saveService.hidden = models.length === 0; - agreeShown(models.length > 0); + modelsWrap.hidden = models.length === 0; + listedShown = models.length > 0; + paintSaves(); }; // This service's last answer, said again; else the model saved with it — the others come with its key. const shownSaved = () => { @@ -2595,8 +2604,9 @@ function showSettings(shown, minutes, words) { if (answer?.models) return shownListed(answer.models); serviceModels.replaceChildren(); if (saved) guidedOption(serviceModels, shown.transcription_model, modelSaid(shown.transcription_model)); - modelsWrap.hidden = saveService.hidden = !saved; - agreeShown(!!saved); + modelsWrap.hidden = !saved; + listedShown = !!saved; + paintSaves(); }; shownSaved(); guidedKeyTested("transcription", words, locked, { servicePick, key: serviceKey, keyTest, keySaid, modelsPick: serviceModels }, @@ -2619,6 +2629,11 @@ function showSettings(shown, minutes, words) { }); const ownSave = guidedButton("transcription-own-save", words.service_save, false, locked); const [hearToggle, hearAdvanced] = guidedAdvanced("transcription", words, own, [addressWrap, modelWrap, ownAgreeWrap, ownSave]); + hearToggle.addEventListener("click", paintSaves); + paintSaves(); + // What « Avancé »'s « Enregistrer » saves: its model typed, or else — its address left empty, the + // service chosen above — the model chosen in that service's list (#860). + const ownModel = () => serviceModel.value.trim() || (address.value.trim() ? "" : serviceModels.value); const serviceSaid = element("p", "says"); serviceSaid.id = "transcription-said"; serviceSaid.setAttribute("role", "status"); @@ -2647,7 +2662,7 @@ function showSettings(shown, minutes, words) { serviceSaid.textContent = saved; }; saveService.addEventListener("click", () => saveHearing(hearing().address, serviceModels.value, serviceKey.value, agreeBox, null, serviceModels)); - ownSave.addEventListener("click", () => saveHearing(ownAddress(), serviceModel.value, serviceKey.value, ownAgreeBox, address, serviceModel)); + ownSave.addEventListener("click", () => saveHearing(ownAddress(), ownModel(), serviceKey.value, ownAgreeBox, address, serviceModel)); const testService = element("button", "open", words.service_test); testService.type = "button"; testService.id = "transcription-test";