feat: preselect adaptive repository identity

This commit is contained in:
vorotamoroz
2026-08-02 07:48:33 +00:00
parent dd8c795210
commit 9715d44fb6
2 changed files with 85 additions and 2 deletions
@@ -462,6 +462,60 @@ describe("SetupManager", () => {
expect(nextSettings).toEqual(expect.objectContaining({ ...bucketSettings, remoteType: REMOTE_MINIO }));
});
it("preselects a repository identity during fresh Adaptive Object Storage onboarding", async () => {
const { manager, setting, dialogManager } = createSetupManager();
dialogManager.openWithExplicitCancel
.mockResolvedValueOnce({
endpoint: "https://storage.example",
accessKey: "key",
secretKey: "secret",
bucket: "notes",
region: "auto",
bucketPrefix: "",
useCustomRequestHandler: false,
bucketCustomHeaders: "",
forcePathStyle: true,
expectedRepositoryId: "",
journalFormat: "adaptive-v1",
packReadPolicy: "whole-pack",
})
.mockResolvedValueOnce(true);
await manager.onBucketManualSetup(UserMode.NewUser, setting.currentSettings());
const current = setting.currentSettings();
expect(current.expectedRepositoryId).toMatch(/^[A-Za-z0-9_-]{43}$/u);
const activeProfile = current.remoteConfigurations[current.activeConfigurationId];
expect(activeProfile?.uri).toContain(`expectedRepositoryId=${current.expectedRepositoryId}`);
});
it("leaves an existing-device Adaptive Object Storage attachment on trust on first use", async () => {
const { manager, setting, dialogManager } = createSetupManager();
dialogManager.openWithExplicitCancel
.mockResolvedValueOnce({
endpoint: "https://storage.example",
accessKey: "key",
secretKey: "secret",
bucket: "notes",
region: "auto",
bucketPrefix: "",
useCustomRequestHandler: false,
bucketCustomHeaders: "",
forcePathStyle: true,
expectedRepositoryId: "",
journalFormat: "adaptive-v1",
packReadPolicy: "whole-pack",
})
.mockResolvedValueOnce(true);
await manager.onBucketManualSetup(UserMode.ExistingUser, setting.currentSettings());
const current = setting.currentSettings();
expect(current.expectedRepositoryId).toBe("");
const activeProfile = current.remoteConfigurations[current.activeConfigurationId];
expect(activeProfile?.uri).not.toContain("expectedRepositoryId=");
});
it("creates and selects a P2P profile during fresh manual onboarding", async () => {
const { manager, setting, dialogManager } = createSetupManager();
setting.settings = {