gui tests: TestPluginsClashRows reads the rows once the plugins' names are in, as #1178 now names them from Cached (#1178)

With #1178 the Installed rows name a plugin's subscriptions from
plugin.Cached rather than asking the plugins on every read, and Cached
asks them again in the background once the plugins change. The clash
test added a plugin, preferred one and removed one, and checked each
op's own answer for the serving plugin's names: that answer is drawn
before the background ask ends, so the row had no names and the clash
only its id ("fakeco", not "FakeCo"). The clashes themselves come from
the plugins as loaded and were right. The test now waits for Cached's
refresh (plugin.Refreshed) and reads /api/plugins after each change.

Run on this tree (origin/main e1b70c13d plus #1178): gofmt, go vet
(darwin, GOOS=linux -tags nogui, GOOS=windows), the three builds, and
go test -tags nogui -count=1 ./internal/library/ ./internal/gui/
./internal/plugin/ under a sandbox HOME, green; TestPluginsClashRows
-count=3 green. GUI on the merged tree: plugin-*, library-rtk*, i18n-*
and gui-zh-tw/ja/de in Chromium and WebKit, 380/380. Break checks:
ReadRTK given rtkAgents(nil) again fails TestReadRTKDetectsTheAgentsOnce
(detected 2 times). Putting plugin.Providers back into pluginsState
does NOT fail TestPluginsStateNamesWithoutAsking: with no Bun the
Running()/HasBun() gate skips the block, so that test proves the names
come from Cached but not that the host is never asked.
This commit is contained in:
yetone
2026-10-13 14:29:52 +08:00
parent e0a3b8c60a
commit d45b207577
+12 -3
View File
@@ -71,8 +71,17 @@ func TestPluginsClashRows(t *testing.T) {
}
return out
}
// the rows' provider names are the plugins' as last asked (Cached),
// asked again in the background once the plugins change: the list as
// it stands once that answer is in
answered := func(path string, body any) map[string]row {
t.Helper()
do(path, body)
plugin.Refreshed()
return do("/api/plugins", nil)
}
do("/api/plugins/add", map[string]string{"spec": mine})
rows := do("/api/plugins/add", map[string]string{"spec": theirs})
rows := answered("/api/plugins/add", map[string]string{"spec": theirs})
check := func(rows map[string]row, by string) {
t.Helper()
for spec, other := range map[string]string{mine: theirs, theirs: mine} {
@@ -86,10 +95,10 @@ func TestPluginsClashRows(t *testing.T) {
}
}
check(rows, theirs)
check(do("/api/plugins/prefer", map[string]string{"spec": mine, "provider": "fakeco"}), mine)
check(answered("/api/plugins/prefer", map[string]string{"spec": mine, "provider": "fakeco"}), mine)
check(do("/api/plugins", nil), mine)
// removing theirs leaves mine alone, and no clash to say
rows = do("/api/plugins/remove", map[string]string{"spec": theirs})
rows = answered("/api/plugins/remove", map[string]string{"spec": theirs})
if r, ok := rows[mine]; !ok || len(r.Clashes) != 0 || len(r.Providers) != 1 || len(rows) != 1 {
t.Fatalf("after removing theirs, rows = %+v", rows)
}