settings.CheckinOff lists the accounts left out, by their entry in the
vendor's check-in file ("workbuddy|<uid>", "trae-cn|<uid>", a plugin's
"<provider>|<account>"). checkinNow skips them, both in the loop and on
Check in now. provider.CheckinAccounts() lists every account a check-in
reaches; /api/settings carries it as checkinAccounts, and
POST /api/settings/checkin-account {key,on} turns one off or on. A full
/api/settings save keeps the list. Settings shows an Off/On switch per
account under each vendor's Daily check-in row when it has 2 or more
accounts; the Usage card says "Auto check-in is off for this account" and
offers no Check in now for it. en, zh, zh-TW, ja, de.
Run (on 63a361b5f's tree, then targeted again on 7565d93c8):
- go test -tags nogui ./internal/provider -run 'TestCheckinAccount|TestWorkBuddyCheckin|TestTraeCheckin|TestPluginCheckin|TestQoderCheckin|TestMiniMax.*Checkin' : ok
- go test ./internal/gui -run 'TestCheckinAccountSetting|TestSettingsSaveKeeps' : ok
- broken by hand: skipping off accounts (false && off[a.key]), listing On,
the card flag, the /api/settings carry and the dedup each turned the
new tests red
- GUI (playwright, Chromium + WebKit, 1100 and 420, en/zh/zh-TW/ja/de):
checkin-account 40/40, plugin-checkin, usage-checkin, i18n-keys,
warm-at-own, warm-at-times all pass; app.js broken by hand made
checkin-account fail 20/20 in Chromium
Then on 8e6354714 (fresh origin/main):
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows for
provider, gui and settings ok
- go test -tags nogui ./internal/provider ok (260s); ./internal/settings ok
- GUI checkin-account, plugin-checkin, usage-checkin, i18n-keys 91/91
- go test ./internal/gui: everything passed except two timing tests, both
at load average ~180 from other sessions:
- TestMainWindowCorners was killed at its 40s deadline. Filed as #1936.
It passes alone on origin/main 81f587d7b and on this change (13s).
- TestSetAnswersWhileDevinAndProvidersHang hit 14s against its 10s bound
(#1375). Alone it passes (1.1s).
Neither test goes near check-in or settings.CheckinOff. The whole of
./internal/gui passed (506s) on the tree before the rebase.
88 lines
2.6 KiB
Go
88 lines
2.6 KiB
Go
package provider
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/yetone/magpie/internal/settings"
|
|
)
|
|
|
|
// leaveOut saves keys as the accounts left out of their daily check-in.
|
|
func leaveOut(t *testing.T, keys ...string) {
|
|
t.Helper()
|
|
s := settings.Load()
|
|
s.CheckinOff = keys
|
|
if err := settings.Save(s); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
// An account the user left out of the daily check-in (#1902, magicLaLa:
|
|
// 根据每个账号设置是否开启自动签到) is asked nothing, by the loop or a
|
|
// press of Check in now, while its vendor's check-in is on; turned back
|
|
// on, it is checked in at once.
|
|
func TestCheckinAccountLeftOut(t *testing.T) {
|
|
signIn(t)
|
|
f := &fakeWBCheckin{active: true}
|
|
srv := f.serve(t)
|
|
now := time.Date(2026, 10, 13, 3, 0, 0, 0, time.UTC)
|
|
c := wbCheckinFixture(t, srv, &now)
|
|
ctx := context.Background()
|
|
|
|
leaveOut(t, "workbuddy|u1")
|
|
for _, soon := range []bool{false, true} {
|
|
if rs := c.checkinNow(ctx, soon); len(rs) != 0 {
|
|
t.Fatalf("left out, soon %v: %+v", soon, rs)
|
|
}
|
|
}
|
|
if s, cl := f.counts(); s != 0 || cl != 0 {
|
|
t.Fatalf("left out, yet asked: status %d, claims %d", s, cl)
|
|
}
|
|
|
|
// another account's entry leaves this one in
|
|
leaveOut(t, "workbuddy|u2")
|
|
rs := c.checkinNow(ctx, false)
|
|
if len(rs) != 1 || rs[0].Outcome != CheckinClaimed || !rs[0].Asked {
|
|
t.Fatalf("back on: %+v", rs)
|
|
}
|
|
}
|
|
|
|
// Settings lists each account a check-in reaches with its own switch, and
|
|
// the account's Usage card says it is left out.
|
|
func TestCheckinAccountsListed(t *testing.T) {
|
|
home := signIn(t)
|
|
wbTokens.Lock()
|
|
wbTokens.m = map[string]wbCreds{}
|
|
wbTokens.Unlock()
|
|
future := time.Now().Add(24 * time.Hour).UnixMilli()
|
|
writeFile(t, wbAuthFile(home), map[string]any{
|
|
"account": map[string]any{"uid": "u1", "nickname": "旅行者"},
|
|
"auth": map[string]any{"accessToken": "wb-access", "refreshToken": "r", "expiresAt": future, "domain": "www.codebuddy.cn"},
|
|
})
|
|
var mine []CheckinAccount
|
|
for _, a := range CheckinAccounts() {
|
|
if a.Key == "workbuddy|u1" {
|
|
mine = append(mine, a)
|
|
}
|
|
}
|
|
if len(mine) != 1 || mine[0].By != "" || mine[0].User != "旅行者" || !mine[0].On {
|
|
t.Fatalf("listed: %+v", CheckinAccounts())
|
|
}
|
|
qs := WithCheckins([]SubscriptionQuota{{Provider: "workbuddy", User: "旅行者"}})
|
|
if !qs[0].Checkins || qs[0].CheckinOff {
|
|
t.Fatalf("card, on: %+v", qs[0])
|
|
}
|
|
|
|
leaveOut(t, "workbuddy|u1")
|
|
for _, a := range CheckinAccounts() {
|
|
if a.Key == "workbuddy|u1" && a.On {
|
|
t.Fatalf("left out, listed on: %+v", a)
|
|
}
|
|
}
|
|
qs = WithCheckins([]SubscriptionQuota{{Provider: "workbuddy", User: "旅行者"}})
|
|
if !qs[0].Checkins || !qs[0].CheckinOff {
|
|
t.Fatalf("card, left out: %+v", qs[0])
|
|
}
|
|
}
|