Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions frontend/e2e/wails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ test("language selection switches to English and persists", async ({ page }) =>
await expect(page.getByRole("combobox", { name: "Language" })).toHaveText("English");
});

// This build has no login items, so its autostart probe fails on every read.
// The field stays disabled until the settings have loaded, which makes it the
// check that the probe did not fail the whole read.
test("settings load in a build that cannot probe autostart", async ({ page }) => {
await page.goto("/#/settings");
await expect(page.getByRole("spinbutton", { name: "备份历史版本数" })).toBeEnabled();
await expect(page.getByRole("spinbutton", { name: "备份历史版本数" })).toHaveValue("3");
});

// The task centre is position: fixed at the viewport's lower-left corner, so it
// takes no space in the sidebar's flex column. When the sidebar did not reserve
// room for it, the rows margin-top: auto pushes to the bottom ended up
Expand Down
9 changes: 7 additions & 2 deletions internal/binding/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,13 @@ func (s *RuntimeService) GetSettings(ctx context.Context) (app.Settings, error)
if err != nil || s.autostart.IsEnabled == nil {
return settings, err
}
settings.Autostart, err = s.autostart.IsEnabled()
return settings, err
// The login item is a separate system from the settings file, and a server
// build has none, so its probe always fails. The stored value stands in then;
// SaveSettings still reports the failure when the user tries to change it.
if enabled, probeErr := s.autostart.IsEnabled(); probeErr == nil {
settings.Autostart = enabled
}
return settings, nil
}

// SaveSettings persists the download preferences and returns what was stored.
Expand Down
27 changes: 27 additions & 0 deletions internal/binding/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,33 @@ func TestRuntimeServiceAppliesAutostartCallbacks(t *testing.T) {
}
}

// A server build has no login items, so its probe always fails. That must not
// take the backup and terminal settings down with it: they come from a file the
// probe has nothing to do with.
func TestGetSettingsSurvivesAFailingAutostartProbe(t *testing.T) {
core := providerCore(t, nil)
retention, stored := 7, true
if _, err := core.UpdateSettings(context.Background(), app.SettingsPatch{BackupRetention: &retention, Autostart: &stored}); err != nil {
t.Fatal(err)
}
service := &RuntimeService{
core: core,
autostart: AutostartCallbacks{
IsEnabled: func() (bool, error) { return false, errors.New("autostart is not supported on this platform") },
},
}
got, err := service.GetSettings(context.Background())
if err != nil {
t.Fatalf("GetSettings failed with the probe: %v", err)
}
if got.BackupRetention != retention {
t.Fatalf("BackupRetention = %d, want %d", got.BackupRetention, retention)
}
if !got.Autostart {
t.Fatal("Autostart did not fall back to the stored value")
}
}

func TestOpenRegistrationUsesConfiguredProviderURL(t *testing.T) {
var opened string
service := NewProviderService(providerCore(t, nil), func(value string) error {
Expand Down
Loading