| index 008d596..c102dd4 100644 |
| --- a/internal/browsertest/cards_test.go |
| +++ b/internal/browsertest/cards_test.go |
| @@ -228,12 +228,15 @@ func statusShownJS(id string) string { |
| if (t.scrollWidth <= t.clientWidth) p.push("the title is not cut short"); |
| // The status is cut short only once the title is down to its least |
| // (measured to the fraction of a pixel: a sliver less already draws |
| - // an ellipsis). |
| - const drawn = s.getBoundingClientRect().width; |
| - s.style.flex = "none"; |
| - const whole = s.getBoundingClientRect().width; |
| - s.style.flex = ""; |
| - if (whole - drawn > 0.01 && t.getBoundingClientRect().width > parseFloat(getComputedStyle(t).minWidth) + 1) p.push("the status is cut short before the title: " + drawn + "px of " + whole); |
| + // an ellipsis). Its whole width is a copy's, set beside it with no |
| + // cap and no shrinking. |
| + const drawn = s.getBoundingClientRect().width, copy = s.cloneNode(true); |
| + copy.style.cssText = "position: absolute; visibility: hidden; flex: none; max-width: none; min-width: 0; width: max-content"; |
| + s.parentElement.append(copy); |
| + const whole = copy.getBoundingClientRect().width; |
| + copy.remove(); |
| + const title = t.getBoundingClientRect().width, least = parseFloat(getComputedStyle(t).minWidth); |
| + if (whole - drawn > 0.01 && title > least + 0.5) p.push("the status is cut short (" + drawn + "px of " + whole + ") while the title is " + title + "px, more than its least " + least); |
| if (!j.querySelector(".pill-link")) p.push("no link"); |
| const pill = j.querySelector(".pill").getBoundingClientRect(), log = document.querySelector("#ask-panel .thread").getBoundingClientRect(); |
| if (pill.right > log.right + 0.5) p.push("the pill overflows the chat"); |
| @@ -263,9 +266,14 @@ func TestAskJobStatusStaysVisible(t *testing.T) { |
| chromedp.Poll[chromedp.Void](readJS, chromedp.WithPollingTimeout(5*time.Second))) |
| } |
| id := f.AskJob(title) |
| - for _, st := range []struct{ state, result, label string }{{"ready", "Ready to try", "Try it"}, {"done", "Done", "Open your site"}} { |
| + for _, st := range []struct{ state, result, label string }{ |
| + {"ready", "Ready to try", "Try it"}, |
| + {"done", "Done", "Open your site"}, |
| + {"ready", "Ready to try on a phone, a tablet and a computer", "Try it"}, |
| + {"done", "Done, and live for everyone who visits", "Open your site"}, |
| + } { |
| f.SetJob(id, st.state, st.result, "One sentence more.", equipo.Link{Label: st.label, URL: "https://site.example.test/"}) |
| - drive(t, rig, chromedp.Poll[chromedp.Void](`document.querySelector('#ask-panel li.job')?.dataset.state === "`+st.state+`"`, |
| + drive(t, rig, chromedp.Poll[chromedp.Void](`document.querySelector('#ask-panel li.job .pill-stage')?.textContent === `+strconv.Quote(st.result), |
| chromedp.WithPollingTimeout(10*time.Second))) |
| // Measured in the page's own font, once it has loaded. |
| drive(t, rig, chromedp.Poll[chromedp.Void](`document.fonts.status === "loaded"`, chromedp.WithPollingTimeout(10*time.Second)), |
| @@ -273,7 +281,7 @@ func TestAskJobStatusStaysVisible(t *testing.T) { |
| if got := harness.Evaluate[string](rig, statusShownJS(id)); got != "" { |
| t.Errorf("%s, %s: %s", view.name, st.state, got) |
| } |
| - mobileShot(t, rig, "job-"+st.state+"-"+view.name) |
| + mobileShot(t, rig, "job-"+st.state+"-"+strconv.Itoa(len(st.result))+"-"+view.name) |
| } |
| }) |
| } |