Qoder's plugin 0.2.32 (magpie-community/plugins 74be632) says why no check-in was offered: it asked with this machine's own device identity and Qoder offered no campaign, and Qoder desktop can claim one it shows. magpie dropped a hook's message for inactive and ineligible and showed only "No check-in event now". Now: - GUI: the Usage card's row reads "<label> · <message>", wrapped under the label rather than cut off with "…" (data-why, as a failed row's reason wraps, #821); Settings' check-in line under the plugin's switch carries it too. A result without a message reads as before. No new i18n keys: the message is the plugin's own text, as for failed rows. - TUI: the Usage cell is too narrow, so it adds "c says why"; c's flash carries the message (checkinWhy). - CLI: `magpie accounts checkin` prints it after the label. - The Qoder mover's min is 0.2.32 (npm view --prefer-online: 0.2.32). - docs/subsystems/provider-plugins.md says how the message is shown. Run at this tree (based on origin/maindd1e8822d): - go test -timeout 45m ./... (tee'd, grepped): every package ok but internal/handoff, whose TestTakeOnlyAFreshOfferForThisProgram could not bind a unix socket under my long scratch TMPDIR (path over 104 bytes); with the default TMPDIR internal/handoff is ok. - gofmt -l: clean; go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: clean. - GUI, chromium and webkit: checkin-reason (new: en, zh, zh-TW, ja, de; 900 and 440px), plugin-checkin, qoder-checkin-recheck, usage-checkin, checkin-account, checkin-early-done, usage-quota-head, i18n-keys: 155/157. The 2 reds are usage-checkin's "webkit en/zh: Settings has a Qoder check-in tab", red the same on a fresh origin/maina9a001a7a(#2549, #3091). - TestCoreScriptBudget: app.js 1,343,313 of 1,343,324, no raise. Rebased on origin/main4683a0382(a9a001a7a's app.js line, 4683a0382's provider change) and run again at this head: internal/gui (budget: 1,343,323 of 1,343,324), internal/cli, internal/tui and the whole internal/provider ok; the same 8 GUI files in both engines, 155/157, the same two #2549/#3091 reds. Broken by hand: app.js's change reverted, checkin-reason goes red on the reason; app.css's reverted, red on the wrap; checkinWhy returning "" in internal/cli and internal/tui, TestCheckinSaysWhyNoneWasOffered red in each. Not tried: a real Qoder account offered no campaign (the fixture is the plugin's own text); the real Linux app (WebKitGTK).
44 lines
1.6 KiB
Go
44 lines
1.6 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// plugins#304: an inactive or ineligible check-in says the plugin's (or
|
|
// vendor's) reason beside its label; one without a reason reads as before.
|
|
func TestCheckinSaysWhyNoneWasOffered(t *testing.T) {
|
|
const why = "Qoder check-in: Qoder offered this device's identity no daily credits campaign right now"
|
|
old := checkinAll
|
|
t.Cleanup(func() { checkinAll = old })
|
|
checkinAll = func(context.Context) []provider.WorkBuddyCheckin {
|
|
return []provider.WorkBuddyCheckin{
|
|
{User: "arno", By: "plugin:qoder", Vendor: "Qoder", Outcome: provider.CheckinInactive, Msg: why},
|
|
{User: "lei", By: "trae", Outcome: provider.CheckinIneligible, Msg: "this device has checked in today"},
|
|
{User: "ann", By: "plugin:qoder", Vendor: "Qoder", Outcome: provider.CheckinInactive},
|
|
{User: "bo", By: "plugin:qoder", Vendor: "Qoder", Outcome: provider.CheckinInactive, Msg: why, Again: true},
|
|
}
|
|
}
|
|
out, err := stdoutOf(t, func() error { return checkinWorkBuddy(false) })
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, want := range []string{
|
|
"Qoder arno no check-in event now · " + why,
|
|
"Trae CN lei not eligible for the check-in · this device has checked in today",
|
|
"Qoder bo no check-in event now · " + why + " · magpie asks again later",
|
|
} {
|
|
if !strings.Contains(out, want) {
|
|
t.Errorf("missing %q in\n%s", want, out)
|
|
}
|
|
}
|
|
for _, l := range strings.Split(out, "\n") {
|
|
if strings.Contains(l, "Qoder ann") && !strings.HasSuffix(strings.TrimSpace(l), "ann no check-in event now") {
|
|
t.Errorf("no reason, as before: %q", l)
|
|
}
|
|
}
|
|
}
|