mirror of
https://github.com/bitwarden/browser
synced 2025-12-21 02:33:46 +00:00
Additional test fixes.
This commit is contained in:
@@ -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(
|
||||||
name: "name2",
|
mockUser2,
|
||||||
email: "email2@example.com",
|
mockAccountInfoWith({
|
||||||
emailVerified: false,
|
name: "name2",
|
||||||
});
|
email: "email2@example.com",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
await accountService.addAccount(mockUser3, {
|
await accountService.addAccount(
|
||||||
name: "name3",
|
mockUser3,
|
||||||
email: "name3@example.com",
|
mockAccountInfoWith({
|
||||||
emailVerified: false,
|
name: "name3",
|
||||||
});
|
email: "name3@example.com",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
const lockSpy = jest.spyOn(sut, "lock").mockResolvedValue(undefined);
|
const lockSpy = jest.spyOn(sut, "lock").mockResolvedValue(undefined);
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
email: "email",
|
...mockAccountInfoWith({
|
||||||
emailVerified: false,
|
email: "email",
|
||||||
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,
|
||||||
email: "email2",
|
...mockAccountInfoWith({
|
||||||
emailVerified: false,
|
email: "email2",
|
||||||
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(
|
||||||
email: "email2",
|
userId2,
|
||||||
emailVerified: false,
|
mockAccountInfoWith({
|
||||||
name: "name2",
|
email: "email2",
|
||||||
});
|
name: "name2",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
const mockFn = jest.fn().mockReturnValue(of(AuthenticationStatus.Locked));
|
const mockFn = jest.fn().mockReturnValue(of(AuthenticationStatus.Locked));
|
||||||
sut.authStatusFor$ = mockFn;
|
sut.authStatusFor$ = mockFn;
|
||||||
|
|||||||
@@ -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,
|
||||||
email: null,
|
...mockAccountInfoWith({
|
||||||
emailVerified: false,
|
email: null,
|
||||||
name: null,
|
name: null,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
accountService.accounts$ = of(
|
accountService.accounts$ = of(
|
||||||
|
|||||||
@@ -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,
|
||||||
email: "test@example.com",
|
...mockAccountInfoWith({
|
||||||
name: `Test Name ${userId}`,
|
email: "test@example.com",
|
||||||
emailVerified: false,
|
name: `Test Name ${userId}`,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
await awaitAsync();
|
await awaitAsync();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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,
|
||||||
email: "email",
|
...mockAccountInfoWith({
|
||||||
emailVerified: false,
|
email: "email",
|
||||||
name: "name",
|
name: "name",
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Initial encrypted state
|
// Initial encrypted state
|
||||||
|
|||||||
Reference in New Issue
Block a user