mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 17:53:39 +00:00
* Use account service to track accounts and active account * Remove state service active account Observables. * Add email verified to account service * Do not store account info on logged out accounts * Add account activity tracking to account service * Use last account activity from account service * migrate or replicate account service data * Add `AccountActivityService` that handles storing account last active data * Move active and next active user to account service * Remove authenticated accounts from state object * Fold account activity into account service * Fix builds * Fix desktop app switch * Fix logging out non active user * Expand helper to handle new authenticated accounts location * Prefer view observable to tons of async pipes * Fix `npm run test:types` * Correct user activity sorting test * Be more precise about log out messaging * Fix dev compare errors All stored values are serializable, the next step wasn't necessary and was erroring on some types that lack `toString`. * If the account in unlocked on load of lock component, navigate away from lock screen * Handle no users case for auth service statuses * Specify account to switch to * Filter active account out of inactive accounts * Prefer constructor init * Improve comparator * Use helper methods internally * Fixup component tests * Clarify name * Ensure accounts object has only valid userIds * Capitalize const values * Prefer descriptive, single-responsibility guards * Update libs/common/src/state-migrations/migrate.ts Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com> * Fix merge * Add user Id validation activity for undefined was being set, which was resulting in requests for the auth status of `"undefined"` (string) userId, due to key enumeration. These changes stop that at both locations, as well as account add for good measure. --------- Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { mock } from "jest-mock-extended";
|
|
|
|
import { mockAccountServiceWith, trackEmissions } from "../../../../spec";
|
|
import { UserId } from "../../../types/guid";
|
|
import { SingleUserStateProvider } from "../user-state.provider";
|
|
|
|
import { DefaultActiveUserStateProvider } from "./default-active-user-state.provider";
|
|
|
|
describe("DefaultActiveUserStateProvider", () => {
|
|
const singleUserStateProvider = mock<SingleUserStateProvider>();
|
|
const userId = "userId" as UserId;
|
|
const accountInfo = {
|
|
id: userId,
|
|
name: "name",
|
|
email: "email",
|
|
emailVerified: false,
|
|
};
|
|
const accountService = mockAccountServiceWith(userId, accountInfo);
|
|
let sut: DefaultActiveUserStateProvider;
|
|
|
|
beforeEach(() => {
|
|
sut = new DefaultActiveUserStateProvider(accountService, singleUserStateProvider);
|
|
});
|
|
|
|
afterEach(() => {
|
|
jest.resetAllMocks();
|
|
});
|
|
|
|
it("should track the active User id from account service", () => {
|
|
const emissions = trackEmissions(sut.activeUserId$);
|
|
|
|
accountService.activeAccountSubject.next(undefined);
|
|
accountService.activeAccountSubject.next(accountInfo);
|
|
|
|
expect(emissions).toEqual([userId, undefined, userId]);
|
|
});
|
|
});
|