xiaowu_95660 (Discord #general) asked for a way to check in one account
right now where its daily check-in switch is, without turning the switch.
- provider: a checkiner can be held to one account (`only`), and
CheckInAccount(ctx, by, key) runs the same claim path once for it, for
WorkBuddy, Trae, MiniMax, Qoder and every plugin with a check-in.
CheckinOff is not read or written.
- gui: POST /api/usage/checkin-account {By, Key}. Settings' daily check-in
group (built-ins and plugins) gets a "Check in now" row under its
accounts. One account checks in at once; several open the app menu to
pick one. The line says done, already checked in, not eligible,
inactive, captcha, own-app or the failure. Only quotas reload, so
Settings isn't redrawn under the button.
- The row and press live in the lazy checkinnow.js (core budget unchanged,
three check-in comments cut). Once loaded it draws at once, so a redraw
by the switch doesn't shorten the page for a moment.
- Strings in zh, zh-TW, ja, de. provider-plugins.md says how it works.
Run at befdfa72b (on origin/main d89f03aa9; 4ffd5b96d, the Cursor min line, landed after), on mote:
- gofmt -l clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet of
internal/provider and internal/gui ok.
- go test ./internal/provider ok. go test ./internal/gui: only
TestMainWindowCorners/macOS_26_SDK red, the same at base de7953e3b
(#3949, macOS 27 box).
- GUI, chromium and webkit, every language, narrow widths: checkin-now-
account (new), checkin-account, plugin-checkin, checkin-reason,
checkin-reason-once, checkin-early-done, usage-checkin,
qoder-checkin-recheck, settings-groups, settings-lines-wrap,
click-scroll, old-webkit, i18n-keys: 252 of 252 ok.
- Earlier at the pre-rebase head: warm-now webkit 440 en/ja/de click
timeouts (#4322) and segs-press-redraw (#4566) red, both the same at the
base.
Broken by hand: without the `only` branch in reaches(),
TestCheckinOneAccountNow goes red (every account is claimed). Loading
checkinnow.js after every redraw made checkin-account's "the switch moved
the page" red on webkit 420 zh/zh-TW/ja; fixed as above.
Not tried: the whole GUI suite (another session's full suite was running
on mote); a press against a real account (no real claim was made).
73 lines
2.2 KiB
Go
73 lines
2.2 KiB
Go
package provider
|
|
|
|
import (
|
|
"context"
|
|
"slices"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/yetone/magpie/internal/settings"
|
|
)
|
|
|
|
// Check in now for one account (xiaowu_95660: 手动签到一次) asks that
|
|
// account alone, once, even one left out of the daily check-in, and
|
|
// changes no switch: the other account is neither asked nor said, a
|
|
// second press the same day is answered from the claim, and the left-out
|
|
// account stays left out.
|
|
func TestCheckinOneAccountNow(t *testing.T) {
|
|
signIn(t)
|
|
f := &fakeWBCheckin{active: true}
|
|
srv := f.serve(t)
|
|
now := time.Date(2026, 11, 2, 3, 0, 0, 0, time.UTC)
|
|
w := wbCheckinFixture(t, srv, &now)
|
|
one := w.accounts()[0]
|
|
two := one
|
|
two.User, two.creds.UID = "second", "u2"
|
|
w.accounts = func() []wbAccount { return []wbAccount{one, two} }
|
|
ctx := context.Background()
|
|
leaveOut(t, "workbuddy|u2")
|
|
|
|
c := w.checkiner()
|
|
c.only = "workbuddy|u2"
|
|
rs := c.checkinNow(ctx, true)
|
|
if len(rs) != 1 || rs[0].User != "second" || rs[0].Outcome != CheckinClaimed || !rs[0].Asked {
|
|
t.Fatalf("pressed for the left-out account: %+v", rs)
|
|
}
|
|
s0, cl0 := f.counts()
|
|
if cl0 != 1 {
|
|
t.Fatalf("claims %d, want 1 (the other account asked too?)", cl0)
|
|
}
|
|
if off := settings.Load().CheckinOff; !slices.Equal(off, []string{"workbuddy|u2"}) {
|
|
t.Fatalf("the press changed the switch: %v", off)
|
|
}
|
|
|
|
// pressed again the same day: the claim stands, the vendor not asked
|
|
rs = c.checkinNow(ctx, true)
|
|
if len(rs) != 1 || rs[0].Asked || !rs[0].Checked() {
|
|
t.Fatalf("second press: %+v", rs)
|
|
}
|
|
if s, cl := f.counts(); s != s0 || cl != cl0 {
|
|
t.Fatalf("second press asked: status %d, claims %d", s, cl)
|
|
}
|
|
|
|
// the daily loop still leaves it out and checks the other in
|
|
f.mu.Lock()
|
|
f.checked = false
|
|
f.mu.Unlock()
|
|
rs = w.checkinNow(ctx, false)
|
|
if len(rs) != 1 || rs[0].User != "旅行者" || !rs[0].Asked {
|
|
t.Fatalf("the loop after the press: %+v", rs)
|
|
}
|
|
}
|
|
|
|
// A press for an account no check-in reaches answers nothing.
|
|
func TestCheckinAccountNowUnknown(t *testing.T) {
|
|
signIn(t)
|
|
if rs := CheckInAccount(context.Background(), "", "workbuddy|nobody"); len(rs) != 0 {
|
|
t.Fatalf("unknown account: %+v", rs)
|
|
}
|
|
if rs := CheckInAccount(context.Background(), "", ""); len(rs) != 0 {
|
|
t.Fatalf("no key: %+v", rs)
|
|
}
|
|
}
|