+
{session.activeAccount?.handle ?? "none"}
+
{session.primaryAccount?.handle ?? "none"}
+
{session.activeDid ?? "none"}
+
+ );
+}
+
+describe("AppSessionProvider", () => {
+ beforeEach(() => {
+ getAppBootstrapMock.mockReset();
+ loginMock.mockReset();
+ logoutMock.mockReset();
+ switchAccountMock.mockReset();
+ getUnreadCountMock.mockReset();
+ listenMock.mockReset();
+ getUnreadCountMock.mockResolvedValue(0);
+ });
+
+ it("keeps active account, primary account, and viewer identity in sync across bootstrap refreshes", async () => {
+ let accountSwitchListener: (() => void) | undefined;
+
+ getAppBootstrapMock.mockResolvedValueOnce({
+ activeSession: { did: "did:plc:alice", handle: "alice.test" },
+ accountList: [{ active: true, did: "did:plc:alice", handle: "alice.test", pdsUrl: "https://alice.pds" }, {
+ active: false,
+ did: "did:plc:bob",
+ handle: "bob.test",
+ pdsUrl: "https://bob.pds",
+ }],
+ }).mockResolvedValueOnce({
+ activeSession: { did: "did:plc:bob", handle: "bob.test" },
+ accountList: [{ active: false, did: "did:plc:alice", handle: "alice.test", pdsUrl: "https://alice.pds" }, {
+ active: true,
+ did: "did:plc:bob",
+ handle: "bob.test",
+ pdsUrl: "https://bob.pds",
+ }],
+ });
+
+ listenMock.mockImplementation((event: string, callback: () => void) => {
+ if (event === ACCOUNT_SWITCH_EVENT) {
+ accountSwitchListener = callback;
+ }
+
+ if (event === NOTIFICATIONS_UNREAD_COUNT_EVENT) {
+ return Promise.resolve(() => {});
+ }
+
+ return Promise.resolve(() => {});
+ });
+
+ render(() => (
+