1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-21 02:33:46 +00:00

Additional test fixes.

This commit is contained in:
Todd Martin
2025-12-10 08:57:06 -05:00
parent ac09fca041
commit 82831a46bb
5 changed files with 49 additions and 38 deletions

View File

@@ -8,7 +8,7 @@ import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/key-
import { VaultTimeoutSettingsService } from "@bitwarden/common/key-management/vault-timeout"; import { VaultTimeoutSettingsService } from "@bitwarden/common/key-management/vault-timeout";
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service"; import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
import { SystemService } from "@bitwarden/common/platform/abstractions/system.service"; import { SystemService } from "@bitwarden/common/platform/abstractions/system.service";
import { mockAccountServiceWith } from "@bitwarden/common/spec"; import { mockAccountServiceWith, mockAccountInfoWith } from "@bitwarden/common/spec";
import { UserId } from "@bitwarden/common/types/guid"; import { UserId } from "@bitwarden/common/types/guid";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction"; import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
@@ -79,17 +79,21 @@ describe("DefaultLockService", () => {
); );
it("locks the active account last", async () => { it("locks the active account last", async () => {
await accountService.addAccount(mockUser2, { await accountService.addAccount(
mockUser2,
mockAccountInfoWith({
name: "name2", name: "name2",
email: "email2@example.com", email: "email2@example.com",
emailVerified: false, }),
}); );
await accountService.addAccount(mockUser3, { await accountService.addAccount(
mockUser3,
mockAccountInfoWith({
name: "name3", name: "name3",
email: "name3@example.com", email: "name3@example.com",
emailVerified: false, }),
}); );
const lockSpy = jest.spyOn(sut, "lock").mockResolvedValue(undefined); const lockSpy = jest.spyOn(sut, "lock").mockResolvedValue(undefined);

View File

@@ -10,6 +10,7 @@ import {
makeStaticByteArray, makeStaticByteArray,
mockAccountServiceWith, mockAccountServiceWith,
trackEmissions, trackEmissions,
mockAccountInfoWith,
} from "../../../spec"; } from "../../../spec";
import { ApiService } from "../../abstractions/api.service"; import { ApiService } from "../../abstractions/api.service";
import { MessagingService } from "../../platform/abstractions/messaging.service"; import { MessagingService } from "../../platform/abstractions/messaging.service";
@@ -58,9 +59,10 @@ describe("AuthService", () => {
const accountInfo = { const accountInfo = {
status: AuthenticationStatus.Unlocked, status: AuthenticationStatus.Unlocked,
id: userId, id: userId,
...mockAccountInfoWith({
email: "email", email: "email",
emailVerified: false,
name: "name", name: "name",
}),
}; };
beforeEach(() => { beforeEach(() => {
@@ -112,9 +114,10 @@ describe("AuthService", () => {
const accountInfo2 = { const accountInfo2 = {
status: AuthenticationStatus.Unlocked, status: AuthenticationStatus.Unlocked,
id: Utils.newGuid() as UserId, id: Utils.newGuid() as UserId,
...mockAccountInfoWith({
email: "email2", email: "email2",
emailVerified: false,
name: "name2", name: "name2",
}),
}; };
const emissions = trackEmissions(sut.activeAccountStatus$); const emissions = trackEmissions(sut.activeAccountStatus$);
@@ -131,11 +134,13 @@ describe("AuthService", () => {
it("requests auth status for all known users", async () => { it("requests auth status for all known users", async () => {
const userId2 = Utils.newGuid() as UserId; const userId2 = Utils.newGuid() as UserId;
await accountService.addAccount(userId2, { await accountService.addAccount(
userId2,
mockAccountInfoWith({
email: "email2", email: "email2",
emailVerified: false,
name: "name2", name: "name2",
}); }),
);
const mockFn = jest.fn().mockReturnValue(of(AuthenticationStatus.Locked)); const mockFn = jest.fn().mockReturnValue(of(AuthenticationStatus.Locked));
sut.authStatusFor$ = mockFn; sut.authStatusFor$ = mockFn;

View File

@@ -109,9 +109,10 @@ describe("VaultTimeoutService", () => {
if (globalSetups?.userId) { if (globalSetups?.userId) {
accountService.activeAccountSubject.next({ accountService.activeAccountSubject.next({
id: globalSetups.userId as UserId, id: globalSetups.userId as UserId,
...mockAccountInfoWith({
email: null, email: null,
emailVerified: false,
name: null, name: null,
}),
}); });
} }
accountService.accounts$ = of( accountService.accounts$ = of(

View File

@@ -1,6 +1,6 @@
import { firstValueFrom } from "rxjs"; import { firstValueFrom } from "rxjs";
import { FakeStateProvider, awaitAsync } from "../../../spec"; import { FakeStateProvider, awaitAsync, mockAccountInfoWith } from "../../../spec";
import { FakeAccountService } from "../../../spec/fake-account-service"; import { FakeAccountService } from "../../../spec/fake-account-service";
import { UserId } from "../../types/guid"; import { UserId } from "../../types/guid";
import { CloudRegion, Region } from "../abstractions/environment.service"; import { CloudRegion, Region } from "../abstractions/environment.service";
@@ -28,16 +28,14 @@ describe("EnvironmentService", () => {
beforeEach(async () => { beforeEach(async () => {
accountService = new FakeAccountService({ accountService = new FakeAccountService({
[testUser]: { [testUser]: mockAccountInfoWith({
name: "name", name: "name",
email: "email", email: "email",
emailVerified: false, }),
}, [alternateTestUser]: mockAccountInfoWith({
[alternateTestUser]: {
name: "name", name: "name",
email: "email", email: "email",
emailVerified: false, }),
},
}); });
stateProvider = new FakeStateProvider(accountService); stateProvider = new FakeStateProvider(accountService);
@@ -47,9 +45,10 @@ describe("EnvironmentService", () => {
const switchUser = async (userId: UserId) => { const switchUser = async (userId: UserId) => {
accountService.activeAccountSubject.next({ accountService.activeAccountSubject.next({
id: userId, id: userId,
...mockAccountInfoWith({
email: "test@example.com", email: "test@example.com",
name: `Test Name ${userId}`, name: `Test Name ${userId}`,
emailVerified: false, }),
}); });
await awaitAsync(); await awaitAsync();
}; };

View File

@@ -11,6 +11,7 @@ import {
FakeStateProvider, FakeStateProvider,
awaitAsync, awaitAsync,
mockAccountServiceWith, mockAccountServiceWith,
mockAccountInfoWith,
} from "../../../../spec"; } from "../../../../spec";
import { KeyGenerationService } from "../../../key-management/crypto"; import { KeyGenerationService } from "../../../key-management/crypto";
import { EncryptService } from "../../../key-management/crypto/abstractions/encrypt.service"; import { EncryptService } from "../../../key-management/crypto/abstractions/encrypt.service";
@@ -71,9 +72,10 @@ describe("SendService", () => {
accountService.activeAccountSubject.next({ accountService.activeAccountSubject.next({
id: mockUserId, id: mockUserId,
...mockAccountInfoWith({
email: "email", email: "email",
emailVerified: false,
name: "name", name: "name",
}),
}); });
// Initial encrypted state // Initial encrypted state