Skip to content
Merged
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
12 changes: 10 additions & 2 deletions tests/native-profile-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,10 @@ describe("native main profile transactions", () => {
]);
}, 10_000);

// This rollback case uses the same encrypted-vault and SQLite setup as the
// transaction test above. Hosted macOS can complete the product recovery
// successfully after Bun's 5 s default, so the harness must not become the
// shorter deadline.
test("a read-back mismatch restores the exact source and removes the journal", async () => {
const f = await enrolledFixture();
const authPath = f.manager.context.authPath;
Expand All @@ -1087,7 +1091,7 @@ describe("native main profile transactions", () => {
expect(readFileSync(join(f.codexHome, "auth.json"), "utf8")).toBe(f.source);
expect((await failing.doctor()).recoveryPending).toBe(false);
expect((await failing.list()).activeProfileId).toBe(f.sourceProfile.id);
});
}, 10_000);

test("rollback verification failure retains the encrypted recovery journal and never claims success", async () => {
const f = await enrolledFixture();
Expand All @@ -1113,6 +1117,10 @@ describe("native main profile transactions", () => {
expect(journal).not.toContain("opaque-refresh-target");
});

// The rejection is immediate once the injected process probe runs, but the
// shared enrollment fixture still performs encrypted-vault and SQLite setup.
// Hosted macOS can push that setup past Bun's 5 s default under full-suite
// load, so keep the harness budget above the manager's own lock deadline.
test("normal switch rejects a busy native Codex process before publishing any transaction file", async () => {
const f = await enrolledFixture();
const blocked = new NativeProfileManager({
Expand All @@ -1126,7 +1134,7 @@ describe("native main profile transactions", () => {
expect(readFileSync(blocked.context.authPath, "utf8")).toBe(f.source);
expect(existsSync(blocked.context.journalPath)).toBe(false);
expect((await blocked.list()).activeProfileId).toBe(f.sourceProfile.id);
});
}, 10_000);

test("vault-write failure after auth replacement restores exact source and removes the journal", async () => {
const f = await enrolledFixture();
Expand Down
Loading